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

* Re: [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  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 13:06 ` [LTP] " linuxtestproject.agent
  2 siblings, 0 replies; 7+ messages in thread
From: Li Wang @ 2026-05-27 11:22 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Cyril Hrubis wrote:

> 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>

Sounds reasonable.

Reviewed-by: Li Wang <li.wang@linux.dev>

-- 
Regards,
Li Wang

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

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

* Re: [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  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 13:06 ` [LTP] " linuxtestproject.agent
  2 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2026-05-27 11:29 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

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);
>  	}

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

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

* Re: [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  2026-05-27 11:29 ` Petr Vorel
@ 2026-05-27 12:13   ` Cyril Hrubis
  2026-05-27 12:17     ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2026-05-27 12:13 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

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

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

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

* Re: [LTP] [PATCH] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  2026-05-27 12:13   ` Cyril Hrubis
@ 2026-05-27 12:17     ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-27 12:17 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

> 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.

I'm sorry to be blind today. Thanks for doing that.

Kind regards,
Petr

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

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

* Re: [LTP] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  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 13:06 ` linuxtestproject.agent
  2026-05-27 13:24   ` Cyril Hrubis
  2 siblings, 1 reply; 7+ messages in thread
From: linuxtestproject.agent @ 2026-05-27 13:06 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

On Wed, 27 May 2026 12:37:56 +0200, Cyril Hrubis wrote:
> syscalls/madvise06: Fix sporadic not enough RAM TCONFs

> 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.

Three typos in the commit body: "fauting" -> "faulting", "immediatelly"
-> "immediately", "betwen" -> "between".

> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>

Duplicate Reviewed-by tag.

[...]

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

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

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

* Re: [LTP] syscalls/madvise06: Fix sporadic not enough RAM TCONFs
  2026-05-27 13:06 ` [LTP] " linuxtestproject.agent
@ 2026-05-27 13:24   ` Cyril Hrubis
  0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2026-05-27 13:24 UTC (permalink / raw)
  To: linuxtestproject.agent; +Cc: ltp

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.
> 
> Three typos in the commit body: "fauting" -> "faulting", "immediatelly"
> -> "immediately", "betwen" -> "between".

Fixed the typos and pushed.

> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> > Reviewed-by: Petr Vorel <pvorel@suse.cz>
> 
> Duplicate Reviewed-by tag.

How did it pick up this? This wasn't in the orignal patch, only in a
mail reply.

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[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.