Re: [LTP] [PATCH 1/2] madvise09: restore cgroup v1 memory limits with numeric values
Andrea Cervesato via ltp <[email protected]> Thu, 30 Jul 2026 11:24:20 +0000
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
Hi Li,
> static void memory_pressure_child(void)
> {
> @@ -151,9 +151,17 @@ static void child(void)
> * 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");
> + if (TST_CG_VER_IS_V1(tst_cg, "memory")) {
> + SAFE_CG_PRINTF(tst_cg, "memory.max", "%lld", ori_mem_limit);
> +
> + if (swap_accounting_enabled)
> + SAFE_CG_PRINTF(tst_cg, "memory.swap.max", "%lld", ori_swap_limit);
> + } else {
> + 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);
> @@ -278,10 +286,17 @@ retry:
>
> static void setup(void)
> {
> - if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))
> + if (TST_CG_VER_IS_V1(tst_cg, "memory"))
> + SAFE_CG_SCANF(tst_cg, "memory.max", "%lld", &ori_mem_limit);
> +
> + if (SAFE_CG_HAS(tst_cg, "memory.swap.max")) {
> swap_accounting_enabled = 1;
> - else
> +
> + if (TST_CG_VER_IS_V1(tst_cg, "memory"))
> + SAFE_CG_SCANF(tst_cg, "memory.swap.max", "%lld", &ori_swap_limit);
> + } else {
> tst_res(TINFO, "Swap accounting is disabled");
> + }
I see a pattern inside text function and setup(), maybe we can create
a function that reset memory.max and memory.swap.max in one place.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
--
Mailing list info: https://lists.linux.it/listinfo/ltp