Skip to content

Commit

Permalink
llist: llist_add() can use llist_add_batch()
Browse files Browse the repository at this point in the history
llist_add(new, head) can simply use llist_add_batch(new, new, head),
no need to duplicate the code.

This obviously uninlines llist_add() and to me this is a win. But we
can make llist_add_batch() inline if this is desirable, in this case
gcc can notice that new_first == new_last if the caller is llist_add().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrey Vagin <avagin@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Oleg Nesterov authored and Al Viro committed Jul 13, 2013
1 parent fb4214d commit e9a17bd
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions include/linux/llist.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ static inline struct llist_node *llist_next(struct llist_node *node)
return node->next;
}

extern bool llist_add_batch(struct llist_node *new_first,
struct llist_node *new_last,
struct llist_head *head);
/**
* llist_add - add a new entry
* @new: new entry to be added
Expand All @@ -151,13 +154,7 @@ static inline struct llist_node *llist_next(struct llist_node *node)
*/
static inline bool llist_add(struct llist_node *new, struct llist_head *head)
{
struct llist_node *first;

do {
new->next = first = ACCESS_ONCE(head->first);
} while (cmpxchg(&head->first, first, new) != first);

return !first;
return llist_add_batch(new, new, head);
}

/**
Expand All @@ -173,9 +170,6 @@ static inline struct llist_node *llist_del_all(struct llist_head *head)
return xchg(&head->first, NULL);
}

extern bool llist_add_batch(struct llist_node *new_first,
struct llist_node *new_last,
struct llist_head *head);
extern struct llist_node *llist_del_first(struct llist_head *head);

#endif /* LLIST_H */

0 comments on commit e9a17bd

Please sign in to comment.