2023-01-18 16:26:24

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH v5 4/7] llist: simplify __llist_del_all

llist_del_all uses xchg, let's use __xchg here.

Signed-off-by: Andrzej Hajda <[email protected]>
---
include/linux/llist.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/llist.h b/include/linux/llist.h
index 85bda2d02d65be..4dc1d185ea98ab 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -50,6 +50,7 @@

#include <linux/atomic.h>
#include <linux/container_of.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/stddef.h>
#include <linux/types.h>

@@ -241,10 +242,7 @@ static inline struct llist_node *llist_del_all(struct llist_head *head)

static inline struct llist_node *__llist_del_all(struct llist_head *head)
{
- struct llist_node *first = head->first;
-
- head->first = NULL;
- return first;
+ return __xchg(&head->first, NULL);
}

extern struct llist_node *llist_del_first(struct llist_head *head);
--
2.34.1


2023-02-27 09:55:58

by Andi Shyti

[permalink] [raw]
Subject: Re: [Intel-gfx] [PATCH v5 4/7] llist: simplify __llist_del_all

Hi Andrzej,

On Wed, Jan 18, 2023 at 04:44:47PM +0100, Andrzej Hajda wrote:
> llist_del_all uses xchg, let's use __xchg here.
>
> Signed-off-by: Andrzej Hajda <[email protected]>

Reviewed-by: Andi Shyti <[email protected]>

Thanks,
Andi

2023-03-12 14:41:26

by tip-bot2 for Jacob Pan

[permalink] [raw]
Subject: [tip: locking/core] llist: simplify __llist_del_all

The following commit has been merged into the locking/core branch of tip:

Commit-ID: ce27b24cbf7f62b74c4cbf807a06f42a14ccf981
Gitweb: https://git.kernel.org/tip/ce27b24cbf7f62b74c4cbf807a06f42a14ccf981
Author: Andrzej Hajda <[email protected]>
AuthorDate: Wed, 18 Jan 2023 16:44:47 +01:00
Committer: Peter Zijlstra <[email protected]>
CommitterDate: Sat, 11 Mar 2023 14:03:59 +01:00

llist: simplify __llist_del_all

llist_del_all uses xchg, let's use __xchg here.

Signed-off-by: Andrzej Hajda <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
include/linux/llist.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/llist.h b/include/linux/llist.h
index 85bda2d..4dc1d18 100644
--- a/include/linux/llist.h
+++ b/include/linux/llist.h
@@ -50,6 +50,7 @@

#include <linux/atomic.h>
#include <linux/container_of.h>
+#include <linux/non-atomic/xchg.h>
#include <linux/stddef.h>
#include <linux/types.h>

@@ -241,10 +242,7 @@ static inline struct llist_node *llist_del_all(struct llist_head *head)

static inline struct llist_node *__llist_del_all(struct llist_head *head)
{
- struct llist_node *first = head->first;
-
- head->first = NULL;
- return first;
+ return __xchg(&head->first, NULL);
}

extern struct llist_node *llist_del_first(struct llist_head *head);