[LTP] [PATCH] memory: rewrite memcg_stress_test into C API
Cyril Hrubis
chrubis@suse.cz
Wed Nov 5 17:45:56 CET 2025
Hi!
> + SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
> +
> + mem_free = SAFE_READ_MEMINFO("MemFree:");
> + mem_avail = SAFE_READ_MEMINFO("MemAvailable:");
> + swap_free = SAFE_READ_MEMINFO("SwapFree:");
> +
> + SAFE_FILE_SCANF("/proc/sys/vm/min_free_kbytes", "%zi", &mem_min);
> +
> + mem_min = mem_min + mem_min / 10;
> + reserved_mem = swap_free > mem_min ? 0 : mem_min;
> +
> + mem_per_proc = mem_free < mem_avail ? mem_free : mem_avail;
We just dropped caches, so mem_free should be close to mem_avail. I
guess that we can use only one of these two.
It looks more or less fine as the replacement, however I find some
things in the test a bit worrisome. For instance the sleep() between
forks of the children will be on some systems enough for the previous
child to finish while on bigger systems (with large RAM) would be too
short. So first of all we should decide if we want to run the children
in serial or in parallel mode and change the code accordingly. As for me
serial mode makes more sense to me, since with parallel mode we are
going to hit OOM under certain conditions.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list