Skip to content

mm: introduce for_each_process_rcu and for_each_thread_rcu

Ye Liu linux-fsdevel linux-mm linux-pm linux-security-module linux-trace-kernel lkml rcu 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 29 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8mm: introduce for_each_process_rcu and for_each_thread_rcuinclude/linux/sched/signal.h+19 -09 replies
2/8mm/oom_kill: convert process/thread iterators to for_each_*_rcumm/oom_kill.c+5 -152 replies
3/8mm/ksm: convert process iterator to for_each_process_rcumm/ksm.c+1 -32 replies
4/8mm/memory-failure: convert process iterator to for_each_process_rcumm/memory-failure.c+4 -123 replies
5/8kernel: convert process/thread iterators to for_each_*_rcukernel/cpu.c kernel/freezer.c kernel/hung_task.c +6 more+11 -302 replies
6/8fs: convert process/thread iterators to for_each_*_rcufs/proc/base.c fs/resctrl/rdtgroup.c+3 -98 replies
7/8lib: convert process iterator to for_each_process_rculib/is_single_threaded.c+1 -41 reply
8/8security/landlock: convert thread iterator to for_each_thread_rcusecurity/landlock/tsync.c+2 -62 replies

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchMichal HockoJustin SuessGünther NoackSJ ParkMiaohe Lin
1/8A-b
2/8A-b R-b
3/8A-b R-b
4/8A-b A-b
5/8A-b
6/8A-b
7/8A-b
8/8R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [PATCH 0/8] mm: introduce for_each_process_rcu and for_each_thread_rcu

From: Ye Liu <[email protected]>

Introduce for_each_process_rcu(), for_each_thread_rcu() and for_each_process_thread_rcu() macros that combine the existing iteration macros with scoped_guard(rcu), so that the RCU read lock is automatically acquired before iteration and released when the loop exits — including via break, goto, or return.

The rest of the series converts manual rcu_read_lock()/ rcu_read_unlock() and guard(rcu)() pairs across mm/, kernel/, fs/, lib/ and security/ to use the new macros.

Patch 1 may trigger checkpatch "Macros with complex values should be enclosed in parentheses" errors. These are false positives — the scoped_guard() pattern is a control-flow construct, not a multi- statement macro, and the same idiom is used elsewhere in the kernel.

Suggested by Michal Hocko for the oom_kill path [1].

[1] https://lore.kernel.org/all/[email protected]/

Ye Liu (8):
mm: introduce for_each_process_rcu and for_each_thread_rcu mm/oom_kill: convert process/thread iterators to for_each_*_rcu mm/ksm: convert process iterator to for_each_process_rcu mm/memory-failure: convert process iterator to for_each_process_rcu
kernel: convert process/thread iterators to for_each_*_rcu
fs: convert process/thread iterators to for_each_*_rcu
lib: convert process iterator to for_each_process_rcu security/landlock: convert thread iterator to for_each_thread_rcu

 fs/proc/base.c               |  4 +---
 fs/resctrl/rdtgroup.c        |  8 ++------
 include/linux/sched/signal.h | 19 +++++++++++++++++++
 kernel/cpu.c                 |  4 +---
 kernel/freezer.c             |  4 +---
 kernel/hung_task.c           |  7 ++-----
 kernel/locking/lockdep.c     |  4 +---
 kernel/rcu/update.c          |  4 +---
 kernel/sched/core.c          |  3 +--
 kernel/sched/debug.c         |  4 +---
 kernel/trace/fgraph.c        |  8 ++------
 kernel/unwind/deferred.c     |  3 +--
 lib/is_single_threaded.c     |  5 +----
 mm/ksm.c                     |  4 +---
 mm/memory-failure.c          | 16 ++++------------
 mm/oom_kill.c                | 20 +++++---------------
 security/landlock/tsync.c    |  8 ++------
 17 files changed, 46 insertions(+), 79 deletions(-)

--
2.25.1