llist: Return whether list is empty before adding in llist_add()
Extend the llist_add*() functions to return a success indicator, this allows us in the scheduler code to send an IPI if the queue was empty. ( There's no effect on existing users, because the list_add_xxx() functions are inline, thus this will be optimized out by the compiler if not used by callers. ) Signed-off-by: Huang Ying <ying.huang@intel.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1315461646-1379-5-git-send-email-ying.huang@intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@@ -142,8 +142,10 @@ static inline bool llist_empty(const struct llist_head *head)
|
||||
* llist_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: the head for your lock-less list
|
||||
*
|
||||
* Return whether list is empty before adding.
|
||||
*/
|
||||
static inline void llist_add(struct llist_node *new, struct llist_head *head)
|
||||
static inline bool llist_add(struct llist_node *new, struct llist_head *head)
|
||||
{
|
||||
struct llist_node *entry, *old_entry;
|
||||
|
||||
@@ -156,6 +158,8 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
|
||||
break;
|
||||
cpu_relax();
|
||||
}
|
||||
|
||||
return old_entry == NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user