Re: [PATCH 6/8] fs: convert process/thread iterators to for_each_*_rcu

From: Alexey Dobriyan

Date: Tue Sep 08 2026 - 12:43:08 EST


On Fri, Sep 04, 2026 at 04:29:58PM +0800, Ye Liu wrote:
> --- 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)
> 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:

What's going on here?
Now it's RCU unlock after mmdrop().

These scoped guards kind of suck unless you allow infinite line length.

A