All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] sched: introduce for_each_process_rculock and for_each_thread_rculock
@ 2026-09-07  8:13 Ye Liu
  2026-09-07  8:13 ` [PATCH v2 1/8] " Ye Liu
                   ` (8 more replies)
  0 siblings, 9 replies; 49+ messages in thread
From: Ye Liu @ 2026-09-07  8:13 UTC (permalink / raw)
  To: Andrew Morton, Michal Hocko, Peter Zijlstra, Paul E. McKenney,
	Ingo Molnar, Steven Rostedt, Josh Poimboeuf,
	Mickaël Salaün, Oleg Nesterov, Thomas Gleixner
  Cc: Ye Liu, David Hildenbrand, Miaohe Lin, Naoya Horiguchi,
	Rafael J. Wysocki, Günther Noack, Lorenzo Stoakes, SJ Park,
	linux-mm, linux-kernel, linux-pm, rcu, linux-trace-kernel,
	linux-fsdevel, linux-security-module, rientjes, shakeel.butt,
	xu.xin16, chengming.zhou, will, boqun, frederic, neeraj.upadhyay,
	joelagnelf, josh, urezki, juri.lelli, vincent.guittot, tony.luck,
	reinette.chatre, x86, paul, jmorris, serge, pavel, lance.yang,
	mhiramat, pmladek, longman, mathieu.desnoyers, jiangshanlai,
	qiang.zhang, dietmar.eggemann, bsegall, mgorman, vschneid,
	kprateek.nayak, mark.rutland, Dave.Martin, james.morse,
	babu.moger

From: Ye Liu <liuye@kylinos.cn>

Introduce for_each_process_rculock(), for_each_thread_rculock() and
for_each_process_thread_rculock() 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.

Changes since v1 [1]:
  - Rename macros from *_rcu to *_rculock, as suggested by Steven
    Rostedt and acked by Thomas Gleixner, to avoid confusion with
    existing *_rcu() list iterators that expect the caller to hold
    the RCU read lock.
  - Improve the comment on for_each_process_thread_rculock() to
    document that 'break' only exits the inner loop and 'goto' is
    needed to exit both loops (Thomas Gleixner).
  - Rename the stale 'unlock:' label to 'out:' in hung_task.c, as
    noted by Günther Noack.
  - Clarify in patch 4 that page_pgoff() is safe outside the RCU
    read-side critical section (SJ Park).
  - CC all relevant maintainers on every patch (Lorenzo Stoakes).
  - Drop the mm: prefix from patch 1, as the macros are in
    include/linux/sched/signal.h (Michal Hocko).

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 [2].

[1] https://lore.kernel.org/all/20260904083001.553587-1-ye.liu@linux.dev/
[2] https://lore.kernel.org/all/20260813092933.562028-1-ye.liu@linux.dev/

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

 fs/proc/base.c               |  4 +---
 fs/resctrl/rdtgroup.c        |  8 ++------
 include/linux/sched/signal.h | 25 +++++++++++++++++++++++++
 kernel/cpu.c                 |  4 +---
 kernel/freezer.c             |  4 +---
 kernel/hung_task.c           | 11 ++++-------
 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, 54 insertions(+), 81 deletions(-)

Signed-off-by: Ye Liu <liuye@kylinos.cn>

--
2.25.1

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2026-09-09 22:14 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07  8:13 [PATCH v2 0/8] sched: introduce for_each_process_rculock and for_each_thread_rculock Ye Liu
2026-09-07  8:13 ` [PATCH v2 1/8] " Ye Liu
2026-09-07  8:30   ` Lorenzo Stoakes (ARM)
2026-09-07  9:35   ` Oleg Nesterov
2026-09-07 15:42   ` Gregory Price
2026-09-07 21:20   ` SJ Park
2026-09-07  8:13 ` [PATCH v2 2/8] mm/oom_kill: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-07  8:35   ` Lorenzo Stoakes (ARM)
2026-09-07 15:42   ` Gregory Price
2026-09-07  8:13 ` [PATCH v2 3/8] mm/ksm: convert process iterator to for_each_process_rculock Ye Liu
2026-09-07  8:36   ` Lorenzo Stoakes (ARM)
2026-09-07 15:43   ` Gregory Price
2026-09-09 16:11   ` David Hildenbrand (Arm)
2026-09-07  8:13 ` [PATCH v2 4/8] mm/memory-failure: " Ye Liu
2026-09-07 11:05   ` Lorenzo Stoakes (ARM)
2026-09-07 15:43   ` Gregory Price
2026-09-07 21:24   ` SJ Park
2026-09-07  8:13 ` [PATCH v2 5/8] kernel: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-07  8:22   ` sashiko-bot
2026-09-07 12:20   ` Lorenzo Stoakes (ARM)
2026-09-07 15:53   ` Gregory Price
2026-09-07 17:57     ` Oleg Nesterov
2026-09-07 21:05       ` Gregory Price
2026-09-07 21:54         ` Oleg Nesterov
2026-09-07 22:27           ` Gregory Price
2026-09-07 22:44             ` Oleg Nesterov
2026-09-08  2:27           ` K Prateek Nayak
2026-09-08  6:35             ` Oleg Nesterov
2026-09-09 22:14               ` Gregory Price
2026-09-08  7:51     ` Peter Zijlstra
2026-09-07 21:28   ` SJ Park
2026-09-08  6:42   ` Oleg Nesterov
2026-09-08  7:42   ` Peter Zijlstra
2026-09-09 16:09     ` Steven Rostedt
2026-09-09 21:46       ` Peter Zijlstra
2026-09-07  8:13 ` [PATCH v2 6/8] fs: " Ye Liu
2026-09-07  8:23   ` sashiko-bot
2026-09-07 12:27   ` Lorenzo Stoakes (ARM)
2026-09-07 15:47   ` Gregory Price
2026-09-07 21:40   ` SJ Park
2026-09-07  8:13 ` [PATCH v2 7/8] lib: convert process iterator to for_each_process_rculock Ye Liu
2026-09-07 12:27   ` Lorenzo Stoakes (ARM)
2026-09-07 15:47   ` Gregory Price
2026-09-07 21:42   ` SJ Park
2026-09-07  8:13 ` [PATCH v2 8/8] security/landlock: convert thread iterator to for_each_thread_rculock Ye Liu
2026-09-07 12:28   ` Lorenzo Stoakes (ARM)
2026-09-07 15:49   ` Gregory Price
2026-09-07 21:44   ` SJ Park
2026-09-07  8:26 ` [PATCH v2 0/8] sched: introduce for_each_process_rculock and for_each_thread_rculock Lorenzo Stoakes (ARM)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.