All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memcontrol: Don't increase effective low/min if no protection needed
@ 2022-10-11 14:30 ` Waiman Long
  0 siblings, 0 replies; 14+ messages in thread
From: Waiman Long @ 2022-10-11 14:30 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Andrew Morton
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Tejun Heo, Chris Down, Waiman Long

Since commit bc50bcc6e00b ("mm: memcontrol: clean up and document
effective low/min calculations"), the effective low/min protections can
be non-zero even if the corresponding memory.low/min values are 0. That
can surprise users to see MEMCG_LOW events even when the memory.low
value is not set. One example is the LTP's memcontrol04 test which fails
because it detects some MEMCG_LOW events for a cgroup with a memory.min
value of 0.

Fix this by updating effective_protection() to not returning a non-zero
low/min protection values if the corresponding memory.low/min values
or those of its parent are 0.

Fixes: bc50bcc6e00b ("mm: memcontrol: clean up and document effective low/min calculations")
Signed-off-by: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 mm/memcontrol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b69979c9ced5..893d4d5e518a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6660,6 +6660,9 @@ static unsigned long effective_protection(unsigned long usage,
 	unsigned long protected;
 	unsigned long ep;
 
+	if (!setting || !parent_effective)
+		return 0UL;	/* No protection is needed */
+
 	protected = min(usage, setting);
 	/*
 	 * If all cgroups at this level combined claim and use more
-- 
2.31.1


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

end of thread, other threads:[~2022-10-17 22:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-11 14:30 [PATCH] mm/memcontrol: Don't increase effective low/min if no protection needed Waiman Long
2022-10-11 14:30 ` Waiman Long
     [not found] ` <20221011143015.1152968-1-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-10-11 15:39   ` Michal Hocko
2022-10-11 15:39     ` Michal Hocko
     [not found]     ` <Y0WOPZxWSnUjzZ8e-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2022-10-11 17:00       ` Waiman Long
2022-10-11 17:00         ` Waiman Long
     [not found]         ` <defdb421-342e-ebcb-d7f0-005559dd1e0d-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-10-11 17:04           ` Tejun Heo
2022-10-11 17:04             ` Tejun Heo
     [not found]             ` <Y0WiIDmPPXYZuHpX-NiLfg/pYEd1N0TnZuCh8vA@public.gmane.org>
2022-10-11 17:14               ` Waiman Long
2022-10-11 17:14                 ` Waiman Long
2022-10-11 19:01               ` Michal Hocko
2022-10-11 19:01                 ` Michal Hocko
2022-10-17 22:46               ` Michal Koutný
2022-10-17 22:46                 ` Michal Koutný

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.