All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] memcg/functional: fix memcg_failcnt intermittent timeout by disabling swap
@ 2026-08-07  1:44 Xuewen Wang
  2026-08-07  2:51 ` [LTP] " linuxtestproject.agent
  2026-08-07  3:28 ` [LTP] [PATCH v3] " Li Wang
  0 siblings, 2 replies; 9+ messages in thread
From: Xuewen Wang @ 2026-08-07  1:44 UTC (permalink / raw)
  To: ltp; +Cc: Xuewen Wang

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 <wangxuewen@kylinos.cn>
---
Changes in v2:
- Drop "2>/dev/null" from swapoff/swapon so that a failure to disable
  swap (or a missing swapoff binary) stays visible, instead of silently
  letting the intermittent timeout recur. Per the LTP AI review, the
  redirect hid the very error this fix relies on, and
  memcg_limit_in_bytes.sh does not redirect stderr either.

Changes in v3:
- Move swapoff to do_setup() and swapon to do_cleanup() per Li Wang,
  instead of wrapping each test iteration with swapoff/swapon in do_test().
---
 .../controllers/memcg/functional/memcg_failcnt.sh  | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
index 3a02d16c2..93e8d4838 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
@@ -11,6 +11,20 @@
 MEMCG_TESTFUNC=do_test
 MEMCG_SHMMAX=1
 TST_TEST_DATA="--mmap-anon --mmap-file --shm"
+TST_SETUP=do_setup
+TST_CLEANUP=do_cleanup
+
+do_setup()
+{
+	memcg_setup
+	swapoff -a
+}
+
+do_cleanup()
+{
+	swapon -a
+	memcg_cleanup
+}
 
 do_test()
 {
-- 
2.25.1


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

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [LTP] [PATCH v2] memcg/functional: fix memcg_failcnt intermittent timeout by disabling swap
@ 2026-08-05  6:40 Xuewen Wang
  2026-08-05  7:40 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 9+ messages in thread
From: Xuewen Wang @ 2026-08-05  6:40 UTC (permalink / raw)
  To: ltp; +Cc: liwang, Xuewen Wang, rpalethorpe

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 <wangxuewen@kylinos.cn>
---
Changes in v2:
- Drop "2>/dev/null" from swapoff/swapon so that a failure to disable
  swap (or a missing swapoff binary) stays visible, instead of silently
  letting the intermittent timeout recur. Per the LTP AI review, the
  redirect hid the very error this fix relies on, and
  memcg_limit_in_bytes.sh does not redirect stderr either.
---
 .../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..9ac3880f6 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
+}
 
 do_test()
 {
 	ROD echo $MEMORY_LIMIT \> memory.limit_in_bytes
 
+	swapoff -a
+
 	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
+
 	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

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [LTP] [PATCH] memcg/functional: fix memcg_failcnt intermittent timeout by disabling swap
@ 2026-07-31  1:49 Xuewen Wang
  2026-07-31  2:46 ` [LTP] " linuxtestproject.agent
  0 siblings, 1 reply; 9+ messages in thread
From: Xuewen Wang @ 2026-07-31  1:49 UTC (permalink / raw)
  To: ltp; +Cc: liwang, Xuewen Wang, rpalethorpe

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 <wangxuewen@kylinos.cn>
---
 .../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

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

end of thread, other threads:[~2026-08-07  6:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07  1:44 [LTP] [PATCH v3] memcg/functional: fix memcg_failcnt intermittent timeout by disabling swap Xuewen Wang
2026-08-07  2:51 ` [LTP] " linuxtestproject.agent
2026-08-07  3:52   ` Li Wang
2026-08-07  5:34     ` Andrea Cervesato via ltp
2026-08-07  6:20       ` Li Wang
2026-08-07  3:28 ` [LTP] [PATCH v3] " Li Wang
  -- strict thread matches above, loose matches on Subject: below --
2026-08-05  6:40 [LTP] [PATCH v2] " Xuewen Wang
2026-08-05  7:40 ` [LTP] " linuxtestproject.agent
2026-07-31  1:49 [LTP] [PATCH] " Xuewen Wang
2026-07-31  2:46 ` [LTP] " linuxtestproject.agent
2026-08-03 13:38   ` Andrea Cervesato 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.