Re: user defined OOM policies

From: David Rientjes
Date: Wed Nov 20 2013 - 22:43:04 EST


On Wed, 20 Nov 2013, Luigi Semenzato wrote:

> Chrome OS uses a custom low-memory notification to minimize OOM kills.
> When the notifier triggers, the Chrome browser tries to free memory,
> including by shutting down processes, before the full OOM occurs. But
> OOM kills cannot always be avoided, depending on the speed of
> allocation and how much CPU the freeing tasks are able to use
> (certainly they could be given higher priority, but it get complex).
>
> We may end up using memcg so we can use the cgroup
> memory.pressure_level file instead of our own notifier, but we have no
> need for finer control over OOM kills beyond the very useful kill
> priority. One process at a time is good enough for us.
>

Even with your own custom low-memory notifier or memory.pressure_level,
it's still possible that all memory is depleted and you run into an oom
kill before your userspace had a chance to wakeup and prevent it. I think
what you'll want is either your custom notifier of memory.pressure_level
to do pre-oom freeing but fallback to a userspace oom handler that
prevents kernel oom kills until it ensures userspace did everything it
could to free unneeded memory, do any necessary logging, etc, and do so
over a grace period of memory.oom_delay_millisecs before the kernel
eventually steps in and kills.
--
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/