Re: [RFC PATCH 0/2] memory.low,min reclaim

From: Roman Gushchin
Date: Mon Apr 23 2018 - 06:38:56 EST


Hi, Greg!

On Sun, Apr 22, 2018 at 01:26:10PM -0700, Greg Thelen wrote:
> Roman's previously posted memory.low,min patches add per memcg effective
> low limit to detect overcommitment of parental limits. But if we flip
> low,min reclaim to bail if usage<{low,min} at any level, then we don't need
> an effective low limit, which makes the code simpler. When parent limits
> are overcommited memory.min will oom kill, which is more drastic but makes
> the memory.low a simpler concept. If memcg a/b wants oom kill before
> reclaim, then give it to them. It seems a bit strange for a/b/memory.low's
> behaviour to depend on a/c/memory.low (i.e. a/b.low is strong unless
> a/b.low+a/c.low exceed a.low).

It's actually not strange: a/b and a/c are sharing a common resource:
a/memory.low.

Exactly as a/b/memory.max and a/c/memory.max are sharing a/memory.max.
If there are sibling cgroups which are consuming memory, a cgroup can't
exceed parent's memory.max, even if its memory.max is grater.

>
> I think there might be a simpler way (ableit it doesn't yet include
> Documentation):
> - memcg: fix memory.low
> - memcg: add memory.min
> 3 files changed, 75 insertions(+), 6 deletions(-)
>
> The idea of this alternate approach is for memory.low,min to avoid reclaim
> if any portion of under-consideration memcg ancestry is under respective
> limit.

This approach has a significant downside: it breaks hierarchical constraints
for memory.low/min. There are two important outcomes:

1) Any leaf's memory.low/min value is respected, even if parent's value
is lower or even 0. It's not possible anymore to limit the amount of
protected memory for a sub-tree.
This is especially bad in case of delegation.

2) If a cgroup has an ancestor with the usage under its memory.low/min,
it becomes protection, even if its memory.low/min is 0. So it becomes
impossible to have unprotected cgroups in protected sub-tree.

Thanks!