All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] memcontrol03: Bind to single CPU on systems with 64KB pagesize
@ 2026-09-29  2:23 Wei Gao via ltp
  2026-09-29  4:35 ` [LTP] " linuxtestproject.agent
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Wei Gao via ltp @ 2026-09-29  2:23 UTC (permalink / raw)
  To: ltp; +Cc: Michal Koutný

On multi-CPU systems with 64KB page size (e.g. ppc64le), memcontrol03
intermittently fails with over-reclaim of protected pagecache under
trunk_B:

  memcontrol03.c:104: TINFO: Child 142113 in trunk_G: Allocating anon: 150994944
  memcontrol03.c:121: TPASS: Child 142113 exited
  memcontrol03.c:214: TPASS: Expect: (A/B memory.current=54394880) ~= 52428800
  ...
  memcontrol03.c:104: TINFO: Child 142114 in trunk_G: Allocating anon: 174063616
  memcontrol03.c:116: TPASS: Child 142114 killed by OOM
  memcontrol03.c:230: TFAIL: Expect: (A/B memory.current=43319296) ~= 52428800

In the kernel, per-CPU charge batching (MEMCG_CHARGE_BATCH = 64 pages)
caches up to 64 * 64KB = 4MB per CPU in memcg_stock. On a multi-CPU
system, allocating memory across CPUs allows cached stock charges to
accumulate in ancestor trunk_A (up to 4MB * nr_cpus, e.g. 16MB on a
4-CPU machine). Because trunk_A has memory.max = 200M, this extra stock
pressure forces the reclaimer to evict pagecache in trunk_B down to
~35-43MB instead of the expected ~50MB. Simply enlarging the tolerance
rate further is not good idea.

Bind the test process to a single CPU in setup() when page size is
>= 64KB. This confines stock batching to a single CPU, preventing
multi-CPU stock inflation and ensuring reproducible reclaim behavior.

Signed-off-by: Wei Gao <wegao@suse.com>
---
 .../kernel/controllers/memcg/memcontrol03.c    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index 96224c4ee..6007d5588 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -235,6 +235,23 @@ static void test_memcg_min(void)
 	SAFE_UNLINK(TMPDIR"/tmpfile");
 }
 
+static void setup(void)
+{
+	if (getpagesize() >= 64 * 1024) {
+		cpu_set_t mask;
+		int cpu = sched_getcpu();
+
+		if (cpu < 0)
+			tst_brk(TBROK | TERRNO, "sched_getcpu() failed");
+
+		tst_res(TINFO, "Page size >= 64KB, binding to CPU %d", cpu);
+		CPU_ZERO(&mask);
+		CPU_SET(cpu, &mask);
+		if (sched_setaffinity(0, sizeof(mask), &mask))
+			tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");
+	}
+}
+
 static void cleanup(void)
 {
 	cleanup_sub_groups();
@@ -243,6 +260,7 @@ static void cleanup(void)
 }
 
 static struct tst_test test = {
+	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = test_memcg_min,
 	.mount_device = 1,
-- 
2.55.0


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

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

end of thread, other threads:[~2026-09-30 11:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29  2:23 [LTP] [PATCH v1] memcontrol03: Bind to single CPU on systems with 64KB pagesize Wei Gao via ltp
2026-09-29  4:35 ` [LTP] " linuxtestproject.agent
2026-09-29 17:01 ` [LTP] [PATCH v1] " Michal Koutný via ltp
2026-09-30  3:53 ` [LTP] [PATCH v2 0/2] memcontrol03, memcontrol04: Bind test process to a single CPU Wei Gao via ltp
2026-09-30  3:53   ` [LTP] [PATCH v2 1/2] memcontrol: Add bind_to_current_cpu() helper Wei Gao via ltp
2026-09-30  8:11     ` [LTP] " linuxtestproject.agent
2026-09-30 11:25       ` Wei Gao via ltp
2026-09-30  3:53   ` [LTP] [PATCH v2 2/2] memcontrol03, memcontrol04: Bind test process to a single CPU Wei Gao via ltp
     [not found] ` <20260929-second-foyer-87225078267f@there>
2026-09-30  3:55   ` [LTP] [PATCH v1] memcontrol03: Bind to single CPU on systems with 64KB pagesize Wei Gao via ltp

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.