Re: [patch] mm, oom: prevent soft lockup on memcg oom for UP systems

From: Tetsuo Handa
Date: Fri Mar 13 2020 - 19:15:58 EST


On 2020/03/14 7:01, David Rientjes wrote:
> The entire issue is that the victim never gets a chance to run because the
> allocator doesn't give it a chance to run on an UP system. Your patch is
> broken because if the victim is current, you've lost your golden
> opportunity to actually exit and ceded control to the allocator that will
> now starve the victim.
>

I still cannot understand. There is no need to give CPU time to OOM victims.
We just need to give CPU time to the OOM reaper kernel thread till the OOM
reaper kernel thread sets MMF_OOM_SKIP to OOM victims. If current thread is
an OOM victim, schedule_timeout_killable(1) will give other threads (including
the OOM reaper kernel thread) CPU time to run. That is similar with your
cond_resched() patch (except that cond_resched() might fail to give other
threads CPU time to run if current thread has realtime priority), isn't it?

So, please explain the mechanism why cond_resched() works but
schedule_timeout_killable(1) cannot work.