diff options
author | Petr Mladek <pmladek@suse.com> | 2022-12-08 11:46:56 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2022-12-08 11:46:56 +0100 |
commit | 6b2b0d839acaa84f05a77184370f793752e786e9 (patch) | |
tree | d051c2ca80acc8a442277410d23a2053685f8a85 /lib/llist.c | |
parent | 7365df19e8ff7a031e1557616fc0b3aa6d794d7e (diff) | |
parent | 5074ffbec67ac592614901771d3a15e1198d759d (diff) | |
download | linux-6b2b0d839acaa84f05a77184370f793752e786e9.tar.bz2 |
Merge branch 'rework/console-list-lock' into for-linus
Diffstat (limited to 'lib/llist.c')
-rw-r--r-- | lib/llist.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/llist.c b/lib/llist.c index 611ce4881a87..7d78b736e8af 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -30,7 +30,7 @@ bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, do { new_last->next = first = READ_ONCE(head->first); - } while (cmpxchg(&head->first, first, new_first) != first); + } while (!try_cmpxchg(&head->first, &first, new_first)); return !first; } @@ -52,18 +52,14 @@ EXPORT_SYMBOL_GPL(llist_add_batch); */ struct llist_node *llist_del_first(struct llist_head *head) { - struct llist_node *entry, *old_entry, *next; + struct llist_node *entry, *next; entry = smp_load_acquire(&head->first); - for (;;) { + do { if (entry == NULL) return NULL; - old_entry = entry; next = READ_ONCE(entry->next); - entry = cmpxchg(&head->first, old_entry, next); - if (entry == old_entry) - break; - } + } while (!try_cmpxchg(&head->first, &entry, next)); return entry; } |