Linux Test Project
 help / color / mirror / Atom feed
From: Sebastian Chlad <sebastianchlad@gmail.com>
To: ltp@lists.linux.it
Cc: Sebastian Chlad <sebastian.chlad@suse.com>
Subject: [LTP] [PATCH 1/2] memcg/memcontrol0[34]: Use expected values from the protection model
Date: Sat, 26 Sep 2026 22:44:53 +0200	[thread overview]
Message-ID: <20260926204459.20699-2-sebastianchlad@gmail.com> (raw)
In-Reply-To: <20260926204459.20699-1-sebastianchlad@gmail.com>

From: Sebastian Chlad <sebastian.chlad@suse.com>

memcontrol03 (memory.min) and memcontrol04 (memory.low) still expect
A/B/C ~= 33M and A/B/D ~= 17M after reclaim, which are the values from
the original kselftest. These were never derived from how the kernel
distributes protection among siblings, and the kselftest replaced them
with simulated values for both tests in kernel commit f10b6e9a8e66
("selftests: memcg: adjust expected reclaim values of protected
cgroups"):

  A/B/C  memory.current ~= 29M
  A/B/D  memory.current ~= 21M

(see tools/testing/selftests/cgroup/memcg_protection.m for the model).

Real kernels match the model, so the old D target leaves very little
room below the upper bound of the 20% tolerance. On 6.12 x86_64, 105
iterations of memcontrol03 across ext2, ext3, ext4, xfs and btrfs gave:

  A/B/C  27.5M - 27.9M  (old range 22.0M - 49.5M)
  A/B/D  22.7M - 23.0M  (old range 11.3M - 25.5M)

so A/B/D is already at ~90% of the old limit and small variations in
reclaim push it over. Passing runs on 6.4 ppc64le show the same
picture for both tests (C 22.6M - 32.0M, D 17.6M - 24.2M).

Switch to the model values. Keep the 20% tolerance, which is already
at least as wide as the kselftest's; kernel commit d2def68ae06a
("selftests: memcg: increase error tolerance of child memory.current
check in test_memcg_protection()") raised the kselftest tolerances to
15% (C) and 20% (D) for the same kind of sporadic failures.

This doesn't change the outcome where C is reclaimed far below D while
the unprotected A/B/F keeps its pagecache (seen e.g. on ppc64le with
C ~= 6M and F ~= 13M). That is a protection failure the tests should
keep reporting.

Signed-off-by: Sebastian Chlad <sebastian.chlad@suse.com>
---
 testcases/kernel/controllers/memcg/memcontrol03.c | 13 +++++++------
 testcases/kernel/controllers/memcg/memcontrol04.c | 13 +++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index 96224c4ee..aa94f4999 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -18,9 +18,10 @@
  * memory pressure in it.
  *
  * A/B    memory.current ~= 50M
- * A/B/C  memory.current ~= 33M
- * A/B/D  memory.current ~= 17M
+ * A/B/C  memory.current ~= 29M
+ * A/B/D  memory.current ~= 21M
  * A/B/E  memory.current ~= 0
+ * (for origin of the numbers, see model in memcg_protection.m.)
  *
  * After that it tries to allocate more than there is unprotected
  * memory in A available, and checks that memory.min protects
@@ -217,10 +218,10 @@ static void test_memcg_min(void)
 	for (i = 0; i < ARRAY_SIZE(leaf_cg); i++)
 		SAFE_CG_SCANF(leaf_cg[i], "memory.current", "%ld", c + i);
 
-	TST_EXP_EXPR(values_close(c[0], MB(33), 20),
-		     "(A/B/C memory.current=%ld) ~= %d", c[0], MB(33));
-	TST_EXP_EXPR(values_close(c[1], MB(17), 20),
-		     "(A/B/D memory.current=%ld) ~= %d", c[1], MB(17));
+	TST_EXP_EXPR(values_close(c[0], MB(29), 20),
+		     "(A/B/C memory.current=%ld) ~= %d", c[0], MB(29));
+	TST_EXP_EXPR(values_close(c[1], MB(21), 20),
+		     "(A/B/D memory.current=%ld) ~= %d", c[1], MB(21));
 	TST_EXP_EXPR(values_close(c[2], 0, 1),
 		     "(A/B/E memory.current=%ld) ~= 0", c[2]);
 
diff --git a/testcases/kernel/controllers/memcg/memcontrol04.c b/testcases/kernel/controllers/memcg/memcontrol04.c
index 22ca1df8c..92ab53a51 100644
--- a/testcases/kernel/controllers/memcg/memcontrol04.c
+++ b/testcases/kernel/controllers/memcg/memcontrol04.c
@@ -17,9 +17,10 @@
  * memory pressure in it.
  *
  * A/B    memory.current ~= 50M
- * A/B/C  memory.current ~= 33M
- * A/B/D  memory.current ~= 17M
+ * A/B/C  memory.current ~= 29M
+ * A/B/D  memory.current ~= 21M
  * A/B/E  memory.current ~= 0
+ * (for origin of the numbers, see model in memcg_protection.m.)
  *
  * After that it tries to allocate more than there is unprotected
  * memory in A available, and checks that memory.low protects
@@ -182,10 +183,10 @@ static void test_memcg_low(void)
 	for (i = 0; i < ARRAY_SIZE(leaf_cg); i++)
 		SAFE_CG_SCANF(leaf_cg[i], "memory.current", "%ld", c + i);
 
-	TST_EXP_EXPR(values_close(c[0], MB(33), 20),
-		     "(A/B/C memory.current=%ld) ~= %d", c[C], MB(33));
-	TST_EXP_EXPR(values_close(c[1], MB(17), 20),
-		     "(A/B/D memory.current=%ld) ~= %d", c[D], MB(17));
+	TST_EXP_EXPR(values_close(c[0], MB(29), 20),
+		     "(A/B/C memory.current=%ld) ~= %d", c[C], MB(29));
+	TST_EXP_EXPR(values_close(c[1], MB(21), 20),
+		     "(A/B/D memory.current=%ld) ~= %d", c[D], MB(21));
 	TST_EXP_EXPR(values_close(c[2], 0, 1),
 		     "(A/B/E memory.current=%ld) ~= 0", c[E]);
 	tst_res(TINFO, "A/B/F memory.current=%ld", c[F]);
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-09-26 20:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 20:44 [LTP] [PATCH 0/2] memcg/memcontrol0[34]: Align with the kselftest protection model Sebastian Chlad
2026-09-26 20:44 ` Sebastian Chlad [this message]
2026-09-28  6:27   ` [LTP] [PATCH 1/2] memcg/memcontrol0[34]: Use expected values from the " Wei Gao via ltp
2026-09-29  7:06   ` [LTP] " linuxtestproject.agent
2026-09-30 15:04   ` [LTP] [PATCH 1/2] " Michal Koutný via ltp
2026-09-26 20:44 ` [LTP] [PATCH 2/2] memcg/memcontrol0[34]: Remove protection from the top level group Sebastian Chlad
2026-09-28  6:31   ` Wei Gao via ltp
2026-09-30 15:04   ` Michal Koutný via ltp
2026-09-30 18:36 ` [LTP] [PATCH 0/2] memcg/memcontrol0[34]: Align with the kselftest protection model Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260926204459.20699-2-sebastianchlad@gmail.com \
    --to=sebastianchlad@gmail.com \
    --cc=ltp@lists.linux.it \
    --cc=sebastian.chlad@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox