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

From: Michal Hocko
Date: Fri Apr 20 2018 - 08:40:56 EST


On Fri 20-04-18 10:23:49, Michal Hocko wrote:
> On Thu 19-04-18 12:34:53, David Rientjes wrote:
[...]
> > I understand the concern, but it's the difference between the victim
> > getting stuck in exit_mmap() and actually taking a long time to free its
> > memory in exit_mmap(). I don't have evidence of the former.
>
> I do not really want to repeat myself. The primary purpose of the oom
> reaper is to provide a _guarantee_ of the forward progress. I do not
> care whether there is any evidences. All I know that lock_page has
> plethora of different dependencies and we cannot clearly state this is
> safe so we _must not_ depend on it when setting MMF_OOM_SKIP.
>
> The way how the oom path was fragile and lockup prone based on
> optimistic assumptions shouldn't be repeated.
>
> That being said, I haven't heard any actual technical argument about why
> locking the munmap path is a wrong thing to do while the MMF_OOM_SKIP
> dependency on the page_lock really concerns me so
>
> Nacked-by: Michal Hocko <mhocko@xxxxxxxx>
>
> If you want to keep the current locking protocol then you really have to
> make sure that the oom reaper will set MMF_OOM_SKIP when racing with
> exit_mmap.

So here is my suggestion for the fix.