[LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs

Cyril Hrubis chrubis@suse.cz
Wed May 27 14:13:53 CEST 2026


Hi!
> > 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).

Huh? That's what the test does after my changes, we print both avail_mem
and chunk_kb after the change.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list