From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH v5] madvise09: Reset cgroup limits before retrying test
Date: Tue, 14 Jul 2026 07:57:10 +0000 [thread overview]
Message-ID: <20260714075710.894370-1-wakel@google.com> (raw)
In-Reply-To: <20260713114220.4185427-1-wakel@google.com>
When madvise09 enters its retry loop, the cgroup limits (memory.max and
memory.swap.max) configured in the previous run remain active. If the
previous run ended due to memory pressure, the inherited limits will
cause the new child to immediately reclaim MADV_FREE pages. This
results in false-positive failures during test verification.
Reset memory.max unconditionally, and memory.swap.max when swap
accounting is enabled, to "max" at the start of child() to ensure
each retry run begins in an unconstrained cgroup.
Signed-off-by: Wake Liu <wakel@google.com>
---
v5:
- Update commit message description to clarify that memory.swap.max is only
reset when swap accounting is enabled, matching the code logic.
v4:
- Remove redundant SAFE_CG_HAS checks for memory.max and memory.swap.max.
v3:
- Fix commit message layout and length to follow guidelines.
- Use SAFE_CG_PRINT instead of SAFE_CG_PRINTF to fix compile errors.
v2:
- Reset memory limits to max in child.
testcases/kernel/syscalls/madvise/madvise09.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
index 87fe096fb..821d40545 100644
--- a/testcases/kernel/syscalls/madvise/madvise09.c
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -146,6 +146,15 @@ static void child(void)
SAFE_CG_PRINTF(tst_cg, "cgroup.procs", "%d", getpid());
+ /*
+ * Reset cgroup memory limits to default ("max") in case this is a retry run.
+ * Otherwise, the retried child inherits the strict MEM_LIMIT from the previous
+ * run, causing MADV_FREE pages to be dropped immediately before we touch them.
+ */
+ SAFE_CG_PRINT(tst_cg, "memory.max", "max");
+ if (swap_accounting_enabled)
+ SAFE_CG_PRINT(tst_cg, "memory.swap.max", "max");
+
ptr = SAFE_MMAP(NULL, PAGES * page_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
--
2.55.0.795.g602f6c329a-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-07-14 7:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 10:42 [LTP] [PATCH] ltp: syscalls/madvise09: Reset cgroup memory limits before test retries Wake Liu via ltp
2026-07-08 12:25 ` [LTP] " linuxtestproject.agent
2026-07-09 16:05 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-07-10 2:15 ` [LTP] [PATCH v2] " Wake Liu via ltp
2026-07-10 4:56 ` [LTP] " linuxtestproject.agent
2026-07-10 6:52 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-07-13 1:18 ` Wake Liu via ltp
2026-07-13 1:25 ` Wake Liu via ltp
2026-07-13 1:25 ` [LTP] [PATCH v3] madvise09: Reset cgroup limits before retrying test Wake Liu via ltp
2026-07-13 2:44 ` [LTP] " linuxtestproject.agent
2026-07-13 11:23 ` Andrea Cervesato via ltp
2026-07-13 11:42 ` [LTP] [PATCH v4] " Wake Liu via ltp
2026-07-13 14:09 ` [LTP] " linuxtestproject.agent
2026-07-14 7:57 ` Wake Liu via ltp [this message]
2026-07-14 8:06 ` linuxtestproject.agent
2026-07-14 8:09 ` [LTP] [PATCH v5] " Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260714075710.894370-1-wakel@google.com \
--to=ltp@lists.linux.it \
--cc=wakel@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.