[LTP] [PATCH v3 4/4] memcontrol03, memcontrol04: Bind test process to a single CPU
Wei Gao
wegao@suse.com
Fri Nov 13 05:11:33 CET 2026
On multi-CPU systems, memcontrol03 and memcontrol04 can intermittently
fail 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 charges in per-CPU memcg_stock. On multi-CPU systems (especially
with large page sizes like 64KB on ppc64le where each CPU caches up to
4MB), allocating memory across CPUs allows cached stock charges to
accumulate in ancestor trunk_A. 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.
Set .setup = tst_bind_to_current_cpu in both tests. Since child processes
inherit CPU affinity on fork(), this confines stock batching to a
single CPU across all test children, preventing multi-CPU stock
accumulation and ensuring reproducible reclaim behavior.
Signed-off-by: Wei Gao <wegao@suse.com>
---
testcases/kernel/controllers/memcg/memcontrol03.c | 2 ++
testcases/kernel/controllers/memcg/memcontrol04.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/testcases/kernel/controllers/memcg/memcontrol03.c b/testcases/kernel/controllers/memcg/memcontrol03.c
index 25b84c24e..73d1e7e04 100644
--- a/testcases/kernel/controllers/memcg/memcontrol03.c
+++ b/testcases/kernel/controllers/memcg/memcontrol03.c
@@ -243,6 +243,8 @@ static void cleanup(void)
}
static struct tst_test test = {
+ /* reduce per CPU stocks for more stable results */
+ .setup = tst_bind_to_current_cpu,
.cleanup = cleanup,
.test_all = test_memcg_min,
.mount_device = 1,
diff --git a/testcases/kernel/controllers/memcg/memcontrol04.c b/testcases/kernel/controllers/memcg/memcontrol04.c
index f1e136df4..462782d6d 100644
--- a/testcases/kernel/controllers/memcg/memcontrol04.c
+++ b/testcases/kernel/controllers/memcg/memcontrol04.c
@@ -242,6 +242,8 @@ static void cleanup(void)
}
static struct tst_test test = {
+ /* reduce per CPU stocks for more stable results */
+ .setup = tst_bind_to_current_cpu,
.cleanup = cleanup,
.test_all = test_memcg_low,
.mount_device = 1,
--
2.55.0
More information about the ltp
mailing list