[LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
Petr Vorel
pvorel@suse.cz
Wed May 27 13:29:11 CEST 2026
Hi Cyril,
> On systems with <= 2GB RAM the test produced sporadic TCONFs. That is
> because even if the test setup does sync() and drops caches the system
> starts fauting in pages immediatelly after caches were dropped. It may
> easily happen that system may fault in a few hundred of MBs of memory
> betwen the write to drop_caches and the time sysinfo() syscall returns.
> The correct fix is to use the MemAvailable metric from /proc/meminfo
> that includes both free memory and caches and is more realistic estimate
> of how much memory can be consumed by a test. We even have helper
> functions in the test library so we simply make use of them.
Thanks for an investigation!
Reviewed-by: Petr Vorel <pvorel@suse.cz>
...
> - sysinfo(&sys_buf_start);
> - if (sys_buf_start.freeram < 2 * CHUNK_SZ) {
> - tst_brk(TCONF, "System RAM is too small (%li bytes needed)",
> - 2 * CHUNK_SZ);
> + long long avail_mem = tst_available_mem();
> + long long avail_swap = tst_available_swap();
> + long long chunk_kb = 2 * CHUNK_SZ / 1024;
> +
> + if (avail_mem < chunk_kb) {
> + tst_brk(TCONF, "System RAM is too small %llikB (%llikB needed)",
> + avail_mem, chunk_kb);
nit: I'd print also the current (not big enough) values (I know that the old code).
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> }
> - if (sys_buf_start.freeswap < 2 * CHUNK_SZ) {
> - tst_brk(TCONF, "System swap is too small (%li bytes needed)",
> - 2 * CHUNK_SZ);
> +
> + if (avail_swap < chunk_kb) {
> + tst_brk(TCONF, "System swap is too small %llikB (%llikB needed)",
> + avail_swap, chunk_kb);
> }
More information about the ltp
mailing list