Re: [PATCH 6/6] mm, oom: fortify task_will_free_mem
From: Michal Hocko
Date: Thu May 26 2016 - 10:42:09 EST
On Thu 26-05-16 23:11:47, Tetsuo Handa wrote:
[...]
> > + if (mm) {
> > + rcu_read_lock();
> > + for_each_process(p) {
> > + bool vfork;
> > +
> > + /*
> > + * skip over vforked tasks because they are mostly
> > + * independent and will drop the mm soon
> > + */
> > + task_lock(p);
> > + vfork = p->vfork_done;
> > + task_unlock(p);
> > + if (vfork)
> > + continue;
> > +
> > + if (!__task_will_free_mem(p))
> > + break;
> > + }
> > + rcu_read_unlock();
> > + mmdrop(mm);
>
> Did you forget "if (something) return false;" here?
Dohh, I screwed when cleaning up the code before submission. Thanks for
catching that.
>
> > + }
> > +
>
> If task_will_free_mem() == true is always followed by mark_oom_victim()
> and wake_oom_reaper(), can we call them from here?
I would rather keep the function doing only the check. We never know
when this could be reused somewhere else. All the callsites are quite
trivial so we do not duplicate a lot of code.
---