Skip to content

Commit a214365

Browse files
andy-shevpaulmckrcu
authored andcommitted
rculist: move list_for_each_rcu() to where it belongs
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>
1 parent 42d590d commit a214365

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

include/linux/list.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -686,16 +686,6 @@ static inline void list_splice_tail_init(struct list_head *list,
686686
#define list_for_each(pos, head) \
687687
for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next)
688688

689-
/**
690-
* list_for_each_rcu - Iterate over a list in an RCU-safe fashion
691-
* @pos: the &struct list_head to use as a loop cursor.
692-
* @head: the head for your list.
693-
*/
694-
#define list_for_each_rcu(pos, head) \
695-
for (pos = rcu_dereference((head)->next); \
696-
!list_is_head(pos, (head)); \
697-
pos = rcu_dereference(pos->next))
698-
699689
/**
700690
* list_for_each_continue - continue iteration over a list
701691
* @pos: the &struct list_head to use as a loop cursor.

include/linux/rculist.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)
4242
*/
4343
#define list_bidir_prev_rcu(list) (*((struct list_head __rcu **)(&(list)->prev)))
4444

45+
/**
46+
* list_for_each_rcu - Iterate over a list in an RCU-safe fashion
47+
* @pos: the &struct list_head to use as a loop cursor.
48+
* @head: the head for your list.
49+
*/
50+
#define list_for_each_rcu(pos, head) \
51+
for (pos = rcu_dereference((head)->next); \
52+
!list_is_head(pos, (head)); \
53+
pos = rcu_dereference(pos->next))
54+
4555
/**
4656
* list_tail_rcu - returns the prev pointer of the head of the list
4757
* @head: the head of the list

kernel/cgroup/dmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/mutex.h>
1515
#include <linux/page_counter.h>
1616
#include <linux/parser.h>
17+
#include <linux/rculist.h>
1718
#include <linux/slab.h>
1819

1920
struct dmem_cgroup_region {

0 commit comments

Comments
 (0)