Re: [PATCH] mm,oom: Always sleep before retrying.

From: Tetsuo Handa
Date: Fri Jan 01 2016 - 02:55:32 EST


Tetsuo Handa wrote:
> When we entered into "Reclaim has failed us, start killing things"
> state, sleep function is called only when mutex_trylock(&oom_lock)
> in __alloc_pages_may_oom() failed or immediately after returning from
> oom_kill_process() in out_of_memory(). This may be insufficient for
> giving other tasks a chance to run because mutex_trylock(&oom_lock)
> will not fail under non-preemptive UP kernel.

My misunderstanding. I thought cond_resched() is a no-op under
non-preemptive UP kernel.

Calling schedule_timeout_uninterruptible(1) will allow other pending
workqueue items a chance to run if current thread is kworker thread.
But if current thread is one of threads which the OOM victim depends
on, calling it merely delays termination of the OOM victim. Therefore,
nobody can judge whether calling it will help the OOM victim and its
dependent threads to make use of CPU cycles for making progress.
Although always sleeping helps saving CPU cycles under OOM livelock,
we need to give up waiting for the OOM victim at some point (i.e.
trigger kernel panic like panic_on_oom_timeout or choose subsequent
OOM victims).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/