All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
@ 2026-05-27 10:37 Cyril Hrubis
  2026-05-27 11:22 ` Li Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Cyril Hrubis @ 2026-05-27 10:37 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/madvise/madvise06.c | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c
index a9df913fc..969b24984 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -39,7 +39,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <sys/mount.h>
-#include <sys/sysinfo.h>
 #include "tst_test.h"
 
 #define CHUNK_SZ (400*1024*1024L)
@@ -90,22 +89,24 @@ static void meminfo_diag(const char *point)
 
 static void setup(void)
 {
-	struct sysinfo sys_buf_start;
-
 	pg_sz = getpagesize();
 
 	tst_res(TINFO, "dropping caches");
 	sync();
 	SAFE_FILE_PRINTF(drop_caches_fname, "3");
 
-	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);
 	}
-	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);
 	}
 
 	check_path("/proc/self/oom_score_adj");
-- 
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-27 13:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 10:37 [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs Cyril Hrubis
2026-05-27 11:22 ` Li Wang
2026-05-27 11:29 ` Petr Vorel
2026-05-27 12:13   ` Cyril Hrubis
2026-05-27 12:17     ` Petr Vorel
2026-05-27 13:06 ` [LTP] " linuxtestproject.agent
2026-05-27 13:24   ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.