Commit 781f7fd9 authored by Huang Ying's avatar Huang Ying Committed by Ingo Molnar

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: default avatarHuang Ying <ying.huang@intel.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1315461646-1379-5-git-send-email-ying.huang@intel.comSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent a3127336
...@@ -142,8 +142,10 @@ static inline bool llist_empty(const struct llist_head *head) ...@@ -142,8 +142,10 @@ static inline bool llist_empty(const struct llist_head *head)
* llist_add - add a new entry * llist_add - add a new entry
* @new: new entry to be added * @new: new entry to be added
* @head: the head for your lock-less list * @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; struct llist_node *entry, *old_entry;
...@@ -156,6 +158,8 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head) ...@@ -156,6 +158,8 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head)
break; break;
cpu_relax(); cpu_relax();
} }
return old_entry == NULL;
} }
/** /**
......
...@@ -34,8 +34,10 @@ ...@@ -34,8 +34,10 @@
* @new_first: first entry in batch to be added * @new_first: first entry in batch to be added
* @new_last: last entry in batch to be added * @new_last: last entry in batch to be added
* @head: the head for your lock-less list * @head: the head for your lock-less list
*
* Return whether list is empty before adding.
*/ */
void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
struct llist_head *head) struct llist_head *head)
{ {
struct llist_node *entry, *old_entry; struct llist_node *entry, *old_entry;
...@@ -49,6 +51,8 @@ void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, ...@@ -49,6 +51,8 @@ void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
break; break;
cpu_relax(); cpu_relax();
} }
return old_entry == NULL;
} }
EXPORT_SYMBOL_GPL(llist_add_batch); EXPORT_SYMBOL_GPL(llist_add_batch);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment