All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm, memcg: Do not high throttle allocators based on wraparound
@ 2020-03-31 15:24 Chris Down
  2020-03-31 15:25   ` Chris Down
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chris Down @ 2020-03-31 15:24 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Jakub Kicinski, linux-mm, cgroups, linux-kernel,
	kernel-team

From: Jakub Kicinski <kuba@kernel.org>

If a cgroup violates its memory.high constraints, we may end
up unduly penalising it. For example, for the following hierarchy:

A:   max high, 20 usage
A/B: 9 high, 10 usage
A/C: max high, 10 usage

We would end up doing the following calculation below when calculating
high delay for A/B:

A/B: 10 - 9 = 1...
A:   20 - PAGE_COUNTER_MAX = 21, so set max_overage to 21.

This gets worse with higher disparities in usage in the parent.

I have no idea how this disappeared from the final version of the patch,
but it is certainly Not Good(tm). This wasn't obvious in testing
because, for a simple cgroup hierarchy with only one child, the result
is usually roughly the same. It's only in more complex hierarchies that
things go really awry (although still, the effects are limited to a
maximum of 2 seconds in schedule_timeout_killable at a maximum).

[chris@chrisdown.name: changelog]

Fixes: e26733e0d0ec ("mm, memcg: throttle allocators based on ancestral memory.high")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Chris Down <chris@chrisdown.name>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: stable@vger.kernel.org # 5.4.x
---
 mm/memcontrol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index eecf003b0c56..75a978307863 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2336,6 +2336,9 @@ static unsigned long calculate_high_delay(struct mem_cgroup *memcg,
 		usage = page_counter_read(&memcg->memory);
 		high = READ_ONCE(memcg->high);
 
+		if (usage <= high)
+			continue;
+
 		/*
 		 * Prevent division by 0 in overage calculation by acting as if
 		 * it was a threshold of 1 page
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-04-15  4:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 15:24 [PATCH] mm, memcg: Do not high throttle allocators based on wraparound Chris Down
2020-03-31 15:25 ` Chris Down
2020-03-31 15:25   ` Chris Down
2020-03-31 15:57 ` Michal Hocko
2020-03-31 15:57   ` Michal Hocko
2020-03-31 17:04   ` Chris Down
2020-03-31 17:04     ` Chris Down
2020-03-31 19:00     ` Chris Down
2020-04-15  4:39 ` Johannes Weiner
2020-04-15  4:39   ` Johannes Weiner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.