lkml.org 
[lkml]   [2011]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -mm -v2 4/5] llist, Return whether list is empty before adding in llist_add
Date
This is needed by irq_work.  And because list_add_xxx functions are
inline, this can be optimized out if not needed by callers.

Signed-off-by: Huang Ying <ying.huang@intel.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
include/linux/llist.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -148,8 +148,10 @@ static inline bool llist_empty(const str
* 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;

@@ -164,6 +166,8 @@ static inline void llist_add(struct llis
break;
cpu_relax();
}
+
+ return old_entry == NULL;
}

/**
@@ -171,8 +175,10 @@ static inline void llist_add(struct llis
* @new_first: first entry in batch to be added
* @new_last: last entry in batch to be added
* @head: the head for your lock-less list
+ *
+ * Return whether list is empty before adding.
*/
-static inline void llist_add_batch(struct llist_node *new_first,
+static inline bool llist_add_batch(struct llist_node *new_first,
struct llist_node *new_last,
struct llist_head *head)
{
@@ -189,6 +195,8 @@ static inline void llist_add_batch(struc
break;
cpu_relax();
}
+
+ return old_entry == NULL;
}

/**

\
 
 \ /
  Last update: 2011-09-08 08:03    [W:0.075 / U:1.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site