Re: [PATCH 6/8] fs: convert process/thread iterators to for_each_*_rcu
From: Oleg Nesterov
Date: Tue Sep 08 2026 - 17:05:00 EST
On 09/08, 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().
Confused... Why do you think so?
I think mmdrop() is called after rcu_read_unlock(), with or without this change.
No?
Oleg.