[PATCH v4] madvise09: Reset cgroup limits before retrying test
Wake Liu via ltp <[email protected]>
| Newsgroups | gmane.linux.ltp |
|---|---|
| Message-ID | <[email protected]> |
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 both memory.max and memory.swap.max to "max" at the start of child() to ensure each retry run begins in an unconstrained cgroup. Signed-off-by: Wake Liu <[email protected]> --- 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