Linux filesystem development
 help / color / mirror / Atom feed
From: Ye Liu <ye.liu@linux.dev>
To: "Andrew Morton" <akpm@linux-foundation.org>,
	"Michal Hocko" <mhocko@suse.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Mickaël Salaün" <mic@digikod.net>
Cc: "Ye Liu" <liuye@kylinos.cn>,
	"David Hildenbrand" <david@kernel.org>,
	"Miaohe Lin" <linmiaohe@huawei.com>,
	"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, rcu@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	"Günther Noack" <gnoack@google.com>
Subject: [PATCH 0/8] mm: introduce for_each_process_rcu and for_each_thread_rcu
Date: Fri,  4 Sep 2026 16:29:52 +0800	[thread overview]
Message-ID: <20260904083001.553587-1-ye.liu@linux.dev> (raw)

From: Ye Liu <liuye@kylinos.cn>

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/20260813092933.562028-1-ye.liu@linux.dev/

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(-)

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

--
2.25.1

             reply	other threads:[~2026-09-04  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  8:29 Ye Liu [this message]
2026-09-04  8:29 ` [PATCH 6/8] fs: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04  9:05   ` Oleg Nesterov
2026-09-04  9:22   ` Lorenzo Stoakes (ARM)
2026-09-04 11:06   ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904083001.553587-1-ye.liu@linux.dev \
    --to=ye.liu@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=gnoack@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=mhocko@suse.com \
    --cc=mic@digikod.net \
    --cc=mingo@redhat.com \
    --cc=nao.horiguchi@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox