Re: [patch v2] mm, oom: fix concurrent munlock and oom reaper unmap

From: Tetsuo Handa
Date: Wed Apr 18 2018 - 10:28:24 EST


Michal Hocko wrote:
> > > > Then, I'm tempted to call __oom_reap_task_mm() before holding mmap_sem for write.
> > > > It would be OK to call __oom_reap_task_mm() at the beginning of __mmput()...
> > >
> > > I am not sure I understand.
> >
> > To reduce possibility of __oom_reap_task_mm() giving up reclaim and
> > setting MMF_OOM_SKIP.
>
> Still do not understand. Do you want to call __oom_reap_task_mm from
> __mmput?

Yes.

> If yes why would you do so when exit_mmap does a stronger
> version of it?

Because memory which can be reclaimed by the OOM reaper is guaranteed
to be reclaimed before setting MMF_OOM_SKIP when the OOM reaper and
exit_mmap() contended, because the OOM reaper (weak reclaim) sets
MMF_OOM_SKIP after one second for safety in case of exit_mmap()
(strong reclaim) failing to make forward progress.