[LTP] [PATCH] memcg/functional: fix memcg_failcnt intermittent timeout by disabling swap
Xuewen Wang <[email protected]> Fri, 31 Jul 2026 09:49:53 +0800
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
memcg_failcnt.sh tests the memory.failcnt counter by allocating reclaimable memory (mmap-anon/mmap-file/shm) beyond a tiny cgroup limit (1 page). It relies on the process being OOM-killed so that signal_memcg_process()'s wait loop exits. With swap enabled the kernel usually still OOM-kills the process, but on arm64 reclaim (swap out) sometimes succeeds instead: usage_in_bytes stays at the limit and the process keeps running, so the wait loop times out (TBROK) intermittently. Example failure on arm64 (kernel 6.6): memcg_failcnt 2 TBROK: timed out on memory.usage_in_bytes 4096 0 8192 Disable swap around the allocation and re-enable it afterwards, mirroring what memcg_limit_in_bytes.sh already does for the same reclaimable memory types. Signed-off-by: Xuewen Wang <[email protected]> --- .../controllers/memcg/functional/memcg_failcnt.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh index 3a02d16c2..07d913147 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh @@ -11,11 +11,20 @@ MEMCG_TESTFUNC=do_test MEMCG_SHMMAX=1 TST_TEST_DATA="--mmap-anon --mmap-file --shm" +TST_CLEANUP=do_cleanup + +do_cleanup() +{ + memcg_cleanup + swapon -a 2>/dev/null +} do_test() { ROD echo $MEMORY_LIMIT \> memory.limit_in_bytes + swapoff -a 2>/dev/null + start_memcg_process $2 -s ${MEMORY_TO_ALLOCATE} ROD echo $MEMCG_PROCESS_PID \> tasks @@ -24,6 +33,8 @@ do_test() stop_memcg_process + swapon -a 2>/dev/null + failcnt=$(cat memory.failcnt) if [ $failcnt -gt 0 ]; then tst_res TPASS "memory.failcnt is $failcnt, > 0 as expected" -- 2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp