Re: [patch] mm, oom: dump stack of victim when reaping failed

From: David Rientjes
Date: Thu Jan 16 2020 - 16:06:00 EST


On Thu, 16 Jan 2020, Tetsuo Handa wrote:

> > I'm
> > currently tracking a stall in oom reaping where the victim doesn't always
> > have a lock held so we don't know where it's at in the kernel; I'm hoping
> > that a stack for the thread group leader will at least shed some light on
> > it.
> >
>
> This change was already proposed at
> https://lore.kernel.org/linux-mm/20180320122818.GL23100@xxxxxxxxxxxxxx/ .
>

Hmm, seems the patch didn't get followed up on but I obviously agree with
it :)

> And according to that proposal, it is likely i_mmap_lock_write() in dup_mmap()
> in copy_process(). We tried to make that lock killable but we gave it up
> because nobody knows whether it is safe to do make it killable.
>

I haven't encountered that particular problem yet; one problem that I've
found is a victim holding cgroup_threadgroup_rwsem in the exit path,
another problem is the victim not holding any locks at all which is more
concerning (why isn't it making forward progress?). This patch intends to
provide a clue for the latter.

Aside: we may also want to consider the possibility of doing immediate
additional oom killing if the initial victim is too small. We rely on the
oom reaper to solve livelocks like this by freeing memory so that
allocators can drop locks that the victim depends on. If the victim is
too small (we have victims <1MB because of oom_score_adj +1000!) we may
want to consider additional immediate oom killing because it simply won't
free enough memory.