mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Ye Liu <ye.liu@linux.dev>
Cc: Tony Luck <tony.luck@intel.com>,
	 Reinette Chatre <reinette.chatre@intel.com>,
	x86@kernel.org, Christian Brauner <brauner@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Jann Horn <jannh@google.com>,
	 "David Hildenbrand (arm)" <david@kernel.org>,
	"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
	 Alexey Dobriyan <adobriyan@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>, Ye Liu <liuye@kylinos.cn>,
	 Dave Martin <Dave.Martin@arm.com>,
	James Morse <james.morse@arm.com>,
	 Babu Moger <babu.moger@amd.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 6/8] fs: convert process/thread iterators to for_each_*_rcu
Date: Fri, 4 Sep 2026 10:22:32 +0100	[thread overview]
Message-ID: <apqMmyhslEFx8EjT@gremlin> (raw)
In-Reply-To: <20260904083001.553587-7-ye.liu@linux.dev>

Please cc everybody on every patch in the series :) it makes it incredible hard
for me to see context otherwise.

I can already see a comment I'd like to leave on another patch in the series but
it's a total pain for me go retrieve that to do it.

And I worry about acking one bit only to find out a horrible flaw in another
part :P

Can you please make sure to do that on any respin?...

On Fri, Sep 04, 2026 at 04:29:58PM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Replace the manual rcu_read_lock()/rcu_read_unlock() pairs combined
> with for_each_process() and for_each_process_thread() loops in fs/
> with the for_each_*_rcu() macros.

Probably worth mentioning that they hold the RCU lock in a scoped guard over the
operation.

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

In general it looks reasonable to me, but I wonder if you're correctly including
linux/cleanup.h to have the scope guard available...

Anyway can check that on respin with the right cc ;)

> ---
>  fs/proc/base.c        | 4 +---
>  fs/resctrl/rdtgroup.c | 8 ++------
>  2 files changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 6a39de424f62..da36ba73dc17 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1160,8 +1160,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)

Side-note - I wonder if this really belongs in mm/oom_kill.c? Seems really odd
to have it here.

>  	if (mm) {
>  		struct task_struct *p;
>
> -		rcu_read_lock();
> -		for_each_process(p) {
> +		for_each_process_rcu(p) {
>  			if (same_thread_group(task, p))
>  				continue;
>
> @@ -1177,7 +1176,6 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
>  			}
>  			task_unlock(p);
>  		}
> -		rcu_read_unlock();
>  		mmdrop(mm);
>  	}
>  err_unlock:
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 5dcbb0a964e8..3f96d21b84ab 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -709,14 +709,12 @@ int rdtgroup_tasks_assigned(struct rdtgroup *r)
>
>  	lockdep_assert_held(&rdtgroup_mutex);
>
> -	rcu_read_lock();
> -	for_each_process_thread(p, t) {
> +	for_each_process_thread_rcu(p, t) {
>  		if (is_closid_match(t, r) || is_rmid_match(t, r)) {
>  			ret = 1;
>  			break;
>  		}
>  	}
> -	rcu_read_unlock();
>
>  	return ret;
>  }
> @@ -826,15 +824,13 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
>  	struct task_struct *p, *t;
>  	pid_t pid;
>
> -	rcu_read_lock();
> -	for_each_process_thread(p, t) {
> +	for_each_process_thread_rcu(p, t) {
>  		if (is_closid_match(t, r) || is_rmid_match(t, r)) {
>  			pid = task_pid_vnr(t);
>  			if (pid)
>  				seq_printf(s, "%d\n", pid);
>  		}
>  	}
> -	rcu_read_unlock();
>  }
>
>  static int rdtgroup_tasks_show(struct kernfs_open_file *of,
> --
> 2.25.1
>

--
Cheers, Lorenzo

  parent reply	other threads:[~2026-09-04  9:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  8:29 [PATCH 0/8] mm: introduce for_each_process_rcu and for_each_thread_rcu Ye Liu
2026-09-04  8:29 ` [PATCH 1/8] " Ye Liu
2026-09-04 11:03   ` Michal Hocko
2026-09-04 16:25   ` Steven Rostedt
2026-09-04 21:17     ` Thomas Gleixner
2026-09-04 23:07       ` Steven Rostedt
2026-09-05  7:27         ` Thomas Gleixner
2026-09-04  8:29 ` [PATCH 2/8] mm/oom_kill: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:32   ` SJ Park
2026-09-04  8:29 ` [PATCH 3/8] mm/ksm: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:33   ` SJ Park
2026-09-04  8:29 ` [PATCH 4/8] mm/memory-failure: " Ye Liu
2026-09-04 11:05   ` Michal Hocko
2026-09-05  0:39   ` SJ Park
2026-09-04  8:29 ` [PATCH 5/8] kernel: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:06   ` Michal Hocko
2026-09-04 14:14   ` Günther Noack
2026-09-04  8:29 ` [PATCH 6/8] fs: " Ye Liu
2026-09-04  9:05   ` Oleg Nesterov
2026-09-04  9:22   ` Lorenzo Stoakes (ARM) [this message]
2026-09-04 11:06   ` Michal Hocko
2026-09-04  8:29 ` [PATCH 7/8] lib: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:09   ` Michal Hocko
2026-09-04  8:30 ` [PATCH 8/8] security/landlock: convert thread iterator to for_each_thread_rcu Ye Liu
2026-09-04 12:21   ` Justin Suess
2026-09-04 14:17   ` Günther Noack

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=apqMmyhslEFx8EjT@gremlin \
    --to=ljs@kernel.org \
    --cc=Dave.Martin@arm.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=babu.moger@amd.com \
    --cc=brauner@kernel.org \
    --cc=david@kernel.org \
    --cc=james.morse@arm.com \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=oleg@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=rppt@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=ye.liu@linux.dev \
    /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

all inboxes | Powered by JetHome®