From a0f503f0ae0ef34ff0eb5a8250693472ec5ed1f4 Mon Sep 17 00:00:00 2001 From: Huang Ying Date: Thu, 8 Sep 2011 14:00:44 +0800 Subject: [PATCH] --- yaml --- r: 269165 b: refs/heads/master c: a3127336b71f6833d1483c856dce91fe558dc3a9 h: refs/heads/master i: 269163: f923faa39b7c0219ec4b1fd6b44738733b18682d v: v3 --- [refs] | 2 +- trunk/include/linux/llist.h | 7 +++++-- trunk/lib/llist.c | 14 ++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 6d184fc46f3a..1c6fc8642911 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2c30245c65e8ebc3080b75ce65572ab8140bad0b +refs/heads/master: a3127336b71f6833d1483c856dce91fe558dc3a9 diff --git a/trunk/include/linux/llist.h b/trunk/include/linux/llist.h index 65fca1cbf514..ca91875286bf 100644 --- a/trunk/include/linux/llist.h +++ b/trunk/include/linux/llist.h @@ -148,11 +148,14 @@ static inline void llist_add(struct llist_node *new, struct llist_head *head) struct llist_node *entry, *old_entry; entry = head->first; - do { + for (;;) { old_entry = entry; new->next = entry; + entry = cmpxchg(&head->first, old_entry, new); + if (entry == old_entry) + break; cpu_relax(); - } while ((entry = cmpxchg(&head->first, old_entry, new)) != old_entry); + } } /** diff --git a/trunk/lib/llist.c b/trunk/lib/llist.c index b445f2c8596a..6c69f1d14c4b 100644 --- a/trunk/lib/llist.c +++ b/trunk/lib/llist.c @@ -41,11 +41,14 @@ void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, struct llist_node *entry, *old_entry; entry = head->first; - do { + for (;;) { old_entry = entry; new_last->next = entry; + entry = cmpxchg(&head->first, old_entry, new_first); + if (entry == old_entry) + break; cpu_relax(); - } while ((entry = cmpxchg(&head->first, old_entry, new_first)) != old_entry); + } } EXPORT_SYMBOL_GPL(llist_add_batch); @@ -68,13 +71,16 @@ struct llist_node *llist_del_first(struct llist_head *head) struct llist_node *entry, *old_entry, *next; entry = head->first; - do { + for (;;) { if (entry == NULL) return NULL; old_entry = entry; next = entry->next; + entry = cmpxchg(&head->first, old_entry, next); + if (entry == old_entry) + break; cpu_relax(); - } while ((entry = cmpxchg(&head->first, old_entry, next)) != old_entry); + } return entry; }