Re: [PATCH 3/5] oom: clear TIF_MEMDIE after oom_reaper managed to unmap the address space

From: Tetsuo Handa
Date: Thu Feb 04 2016 - 10:08:39 EST


Michal Hocko wrote:
> > > + /*
> > > + * Clear TIF_MEMDIE because the task shouldn't be sitting on a
> > > + * reasonably reclaimable memory anymore. OOM killer can continue
> > > + * by selecting other victim if unmapping hasn't led to any
> > > + * improvements. This also means that selecting this task doesn't
> > > + * make any sense.
> > > + */
> > > + tsk->signal->oom_score_adj = OOM_SCORE_ADJ_MIN;
> > > + exit_oom_victim(tsk);
> >
> > I noticed that updating only one thread group's oom_score_adj disables
> > further wake_oom_reaper() calls due to rough-grained can_oom_reap check at
> >
> > p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN
> >
> > in oom_kill_process(). I think we need to either update all thread groups'
> > oom_score_adj using the reaped mm equally or use more fine-grained can_oom_reap
> > check which ignores OOM_SCORE_ADJ_MIN if all threads in that thread group are
> > dying or exiting.
>
> I do not understand. Why would you want to reap the mm again when
> this has been done already? The mm is shared, right?

The mm is shared between previous victim and next victim, but these victims
are in different thread groups. The OOM killer selects next victim whose mm
was already reaped due to sharing previous victim's memory. We don't want
the OOM killer to select such next victim. Maybe set MMF_OOM_REAP_DONE on
the previous victim's mm and check it instead of TIF_MEMDIE when selecting
a victim? That will also avoid problems caused by clearing TIF_MEMDIE?