Re: upcoming kerneloops.org item: get_page_from_freelist

From: David Rientjes
Date: Tue Jun 30 2009 - 16:51:26 EST


On Tue, 30 Jun 2009, Mel Gorman wrote:

> > This will panic the machine if current is the only user thread running or
> > eligible for oom kill (all others could have mm's with OOM_DISABLE set).
> > Currently, such tasks can exit or kthreads can free memory so that the oom
> > is recoverable.
> >
>
> Good point, would the following be ok instead?
>
> + if (test_tsk_thread_flag(p, TIF_MEMDIE)) {
> + if (p == current) {
> + chosen = ERR_PTR(-1UL);
> + continue;
> + } else
> + return ERR_PTR(-1UL);
>

Yes, if you wanted to allow multiple threads to have TIF_MEMDIE set.

> > The problem with this approach is that it increases the liklihood that
> > memory reserves will be totally depleted when several threads are
> > competing for them.
> >
>
> How so?
>

We automatically oom kill current if it's PF_EXITING to give it TIF_MEMDIE
because we know it's on the exit path, this avoids allowing them to
allocate below the min watermark for the allocation that triggered the
oom, which could be significant.

If several threads are ooming at the same time, which happens quite often
for non-cpuset and non-memcg constrained ooms (and those not restricted to
lowmem), we could now potentially have nr_cpus threads with TIF_MEMDIE set
simultaneously, which increases the liklihood that memory reserves will be
fully depleted after each allocation that triggered the oom killer now
succeeds because of ALLOC_NO_WATERMARKS. This is somewhat mitigated by
the oom killer serialization done on the zonelist, but nothing guarantees
that reserves aren't empty before one of the threads has detached its
->mm.

oom_kill_task() SIGKILLs threads sharing ->mm with different tgid's
instead of giving them access to memory reserves specifically to avoid
this.
--
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/