[LTP] [PATCH v1] swapon01.c: Apply a margin to avoid oom

Wei Gao wegao@suse.com
Thu Mar 14 02:33:20 CET 2024


During our test i find a oom error during test which triggered by
tst_pollute_memory.

kernel: oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=/,mems_allowed=0-1,oom_memcg=/ltp/test-9552,task_memcg=/ltp/test-95520
kernel: Memory cgroup out of memory: Killed process 9575 (swapon01) total-vm:1051484kB, anon-rss:1046572kB, file-rss:1280kB, shmem-rss:0k0

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/swapon/swapon01.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index d406e4bd9..357992525 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -41,7 +41,9 @@ static void setup(void)
 	make_swapfile(SWAP_FILE, 10, 0);
 
 	SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
-	SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM);
+
+	/* Apply a margin to avoid oom during tst_pollute_memory */
+	SAFE_CG_PRINTF(tst_cg, "memory.max", "%lu", TESTMEM + TESTMEM/100);
 }
 
 static struct tst_test test = {
-- 
2.35.3



More information about the ltp mailing list