* + llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch added to mm-nonmm-unstable branch
@ 2022-08-15 1:25 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2022-08-15 1:25 UTC (permalink / raw)
To: mm-commits, ubizjak, akpm
The patch titled
Subject: llist: use try_cmpxchg in llist_add_batch and llist_del_first
has been added to the -mm mm-nonmm-unstable branch. Its filename is
llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Uros Bizjak <ubizjak@gmail.com>
Subject: llist: use try_cmpxchg in llist_add_batch and llist_del_first
Date: Tue, 12 Jul 2022 16:49:17 +0200
Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
llist_add_batch and llist_del_first. x86 CMPXCHG instruction returns
success in ZF flag, so this change saves a compare after cmpxchg.
Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails, enabling further code simplifications.
No functional change intended.
Link: https://lkml.kernel.org/r/20220712144917.4497-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/llist.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
--- a/lib/llist.c~llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first
+++ a/lib/llist.c
@@ -30,7 +30,7 @@ bool llist_add_batch(struct llist_node *
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;
}
_
Patches currently in -mm which might be from ubizjak@gmail.com are
llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
^ permalink raw reply [flat|nested] 2+ messages in thread* + llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch added to mm-nonmm-unstable branch
@ 2022-08-17 17:02 Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2022-08-17 17:02 UTC (permalink / raw)
To: mm-commits, ubizjak, akpm
The patch titled
Subject: llist: Use try_cmpxchg in llist_add_batch and llist_del_first
has been added to the -mm mm-nonmm-unstable branch. Its filename is
llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Uros Bizjak <ubizjak@gmail.com>
Subject: llist: Use try_cmpxchg in llist_add_batch and llist_del_first
Date: Tue, 12 Jul 2022 16:49:17 +0200
Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
llist_add_batch and llist_del_first. x86 CMPXCHG instruction returns
success in ZF flag, so this change saves a compare after cmpxchg.
Also, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails, enabling further code simplifications.
No functional change intended.
Link: https://lkml.kernel.org/r/20220712144917.4497-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/llist.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
--- a/lib/llist.c~llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first
+++ a/lib/llist.c
@@ -30,7 +30,7 @@ bool llist_add_batch(struct llist_node *
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;
}
_
Patches currently in -mm which might be from ubizjak@gmail.com are
llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-17 17:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 1:25 + llist-use-try_cmpxchg-in-llist_add_batch-and-llist_del_first.patch added to mm-nonmm-unstable branch Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2022-08-17 17:02 Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.