aboutsummaryrefslogtreecommitdiffstats
path: root/lib/llist.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/llist.c')
-rw-r--r--lib/llist.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/llist.c b/lib/llist.c
index b445f2c8596a..6c69f1d14c4b 100644
--- a/lib/llist.c
+++ b/lib/llist.c
@@ -41,11 +41,14 @@ void llist_add_batch(struct llist_node *new_first, struct llist_node *new_last,
41 struct llist_node *entry, *old_entry; 41 struct llist_node *entry, *old_entry;
42 42
43 entry = head->first; 43 entry = head->first;
44 do { 44 for (;;) {
45 old_entry = entry; 45 old_entry = entry;
46 new_last->next = entry; 46 new_last->next = entry;
47 entry = cmpxchg(&head->first, old_entry, new_first);
48 if (entry == old_entry)
49 break;
47 cpu_relax(); 50 cpu_relax();
48 } while ((entry = cmpxchg(&head->first, old_entry, new_first)) != old_entry); 51 }
49} 52}
50EXPORT_SYMBOL_GPL(llist_add_batch); 53EXPORT_SYMBOL_GPL(llist_add_batch);
51 54
@@ -68,13 +71,16 @@ struct llist_node *llist_del_first(struct llist_head *head)
68 struct llist_node *entry, *old_entry, *next; 71 struct llist_node *entry, *old_entry, *next;
69 72
70 entry = head->first; 73 entry = head->first;
71 do { 74 for (;;) {
72 if (entry == NULL) 75 if (entry == NULL)
73 return NULL; 76 return NULL;
74 old_entry = entry; 77 old_entry = entry;
75 next = entry->next; 78 next = entry->next;
79 entry = cmpxchg(&head->first, old_entry, next);
80 if (entry == old_entry)
81 break;
76 cpu_relax(); 82 cpu_relax();
77 } while ((entry = cmpxchg(&head->first, old_entry, next)) != old_entry); 83 }
78 84
79 return entry; 85 return entry;
80} 86}