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

From: Alexey Dobriyan

Date: Tue Sep 08 2026 - 13:29:05 EST


On Tue, Sep 08, 2026 at 06:10:17PM +0100, Lorenzo Stoakes (ARM) wrote:
> 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).

OK.

I think naming (and macro) are misguided:
* _rcu means "use under RCU section opened elsewhere",
this one is "I open and close RCU section myself".

* not every 2 lines should be combined into new interface.