Re: [PATCH 3/4] OOM, PM: OOM killed task shouldn't escape PM suspend
From: Michal Hocko
Date: Thu Nov 06 2014 - 08:05:51 EST
On Wed 05-11-14 12:01:11, Tejun Heo wrote:
> On Wed, Nov 05, 2014 at 11:54:28AM -0500, Tejun Heo wrote:
> > > Still not following. How do you want to detect an on-going OOM without
> > > any interface around out_of_memory?
> >
> > I thought you were using oom_killer_allowed_start() outside OOM path.
> > Ugh.... why is everything weirdly structured? oom_killer_disabled
> > implies that oom killer may fail, right? Why is
> > __alloc_pages_slowpath() checking it directly? If whether oom killing
> > failed or not is relevant to its users, make out_of_memory() return an
> > error code. There's no reason for the exclusion detail to leak out of
> > the oom killer proper. The only interface should be disable/enable
> > and whether oom killing failed or not.
>
> And what's implemented is wrong. What happens if oom killing is
> already in progress and then a task blocks trying to write-lock the
> rwsem and then that task is selected as the OOM victim?
But this is nothing new. Suspend hasn't been checking for fatal signals
nor for TIF_MEMDIE since the OOM disabling was introduced and I suppose
even before.
This is not harmful though. The previous OOM kill attempt would kick the
current TASK and mark it with TIF_MEMDIE and retry the allocation. After
OOM is disabled the allocation simply fails. The current will die on its
way out of the kernel. Definitely worth fixing. In a separate patch.
> disable() call must be able to fail.
This would be a way to do it without requiring caller to check for
TIF_MEMDIE explicitly. The fewer of them we have the better.
---