lkml.org 
[lkml]   [2023]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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 <andrzej.hajda@intel.com>
AuthorDate: Wed, 18 Jan 2023 16:44:47 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
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 <andrzej.hajda@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20230118154450.73842-4-andrzej.hajda@intel.com
---
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);
\
 
 \ /
  Last update: 2023-03-27 00:55    [W:0.080 / U:1.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site