]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rculist: move list_for_each_rcu() to where it belongs
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 10 Jul 2025 12:15:28 +0000 (15:15 +0300)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 25 Aug 2025 17:13:26 +0000 (10:13 -0700)
The list_for_each_rcu() relies on the rcu_dereference() API which is not
provided by the list.h. At the same time list.h is a low-level basic header
that must not have dependencies like RCU, besides the fact of the potential
circular dependencies in some cases. With all that said, move RCU related
API to the rculist.h where it belongs.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simona Vetter <simona.vetter@ffwll.ch>
Reviewed-by: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Neeraj Upadhyay (AMD) <neeraj.upadhyay@kernel.org>
Signed-off-by: "Paul E. McKenney" <paulmck@kernel.org>
include/linux/list.h
include/linux/rculist.h
kernel/cgroup/dmem.c

index e7e28afd28f8eef94ab6baec77e69ea104ba0391..e7bdad9b861827e50a1e28202dc077719bf9a740 100644 (file)
@@ -686,16 +686,6 @@ static inline void list_splice_tail_init(struct list_head *list,
 #define list_for_each(pos, head) \
        for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next)
 
-/**
- * list_for_each_rcu - Iterate over a list in an RCU-safe fashion
- * @pos:       the &struct list_head to use as a loop cursor.
- * @head:      the head for your list.
- */
-#define list_for_each_rcu(pos, head)             \
-       for (pos = rcu_dereference((head)->next); \
-            !list_is_head(pos, (head)); \
-            pos = rcu_dereference(pos->next))
-
 /**
  * list_for_each_continue - continue iteration over a list
  * @pos:       the &struct list_head to use as a loop cursor.
index 1b11926ddd47100fb37559b70f8d5c3cc4ef2555..2abba7552605c539cfd0ee1c6a453a99c2e652d1 100644 (file)
@@ -42,6 +42,16 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
  */
 #define list_bidir_prev_rcu(list) (*((struct list_head __rcu **)(&(list)->prev)))
 
+/**
+ * list_for_each_rcu - Iterate over a list in an RCU-safe fashion
+ * @pos:       the &struct list_head to use as a loop cursor.
+ * @head:      the head for your list.
+ */
+#define list_for_each_rcu(pos, head)             \
+       for (pos = rcu_dereference((head)->next); \
+            !list_is_head(pos, (head)); \
+            pos = rcu_dereference(pos->next))
+
 /**
  * list_tail_rcu - returns the prev pointer of the head of the list
  * @head: the head of the list
index 10b63433f05737cc43a87029f2306147283a77ff..e12b946278b6c64d912268fdca6fbc13fad53224 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/mutex.h>
 #include <linux/page_counter.h>
 #include <linux/parser.h>
+#include <linux/rculist.h>
 #include <linux/slab.h>
 
 struct dmem_cgroup_region {