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

From: Lorenzo Stoakes (ARM)

Date: Tue Sep 08 2026 - 13:15:04 EST


On Tue, Sep 08, 2026 at 07:45:15PM +0300, Alexey Dobriyan wrote:
> 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().

No it's not, scoped_guard() is scoped to the for_each_process_rcu() block which
ends before mmdrop(), i.e. the exact same scope as before.

That closing '}' is attached to the if (mm).

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

--
Cheers, Lorenzo