All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
@ 2026-06-09 15:23 Cyril Hrubis
  2026-06-09 15:59 ` [LTP] " linuxtestproject.agent
  2026-06-10  1:18 ` [LTP] [PATCH] " Li Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Cyril Hrubis @ 2026-06-09 15:23 UTC (permalink / raw)
  To: ltp

Move the runtime checks for minimal amount of memory or swap from the
test setup to the tst_test structure.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/madvise/madvise06.c | 16 ++--------------
 testcases/kernel/syscalls/madvise/madvise09.c |  7 +------
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise06.c b/testcases/kernel/syscalls/madvise/madvise06.c
index 799e5398a..15ef863a8 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -95,20 +95,6 @@ static void setup(void)
 	sync();
 	SAFE_FILE_PRINTF(drop_caches_fname, "3");
 
-	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 (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");
 	SAFE_FILE_PRINTF("/proc/self/oom_score_adj", "%d", -1000);
 
@@ -243,6 +229,8 @@ static struct tst_test test = {
 			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
 		{}
 	},
+	.min_mem_avail = 2 * CHUNK_SZ / TST_MB,
+	.min_swap_avail = 2 * CHUNK_SZ / TST_MB,
 	.needs_cgroup_ctrls = (const char *const []){ "memory", NULL },
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "55231e5c898c"},
diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
index 87fe096fb..182387919 100644
--- a/testcases/kernel/syscalls/madvise/madvise09.c
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -269,17 +269,11 @@ retry:
 
 static void setup(void)
 {
-	long swap_total;
-
 	if (SAFE_CG_HAS(tst_cg, "memory.swap.max"))
 		swap_accounting_enabled = 1;
 	else
 		tst_res(TINFO, "Swap accounting is disabled");
 
-	SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapTotal: %ld", &swap_total);
-	if (swap_total <= 0)
-		tst_brk(TCONF, "MADV_FREE does not work without swap");
-
 	page_size = getpagesize();
 }
 
@@ -288,5 +282,6 @@ static struct tst_test test = {
 	.test_all = run,
 	.needs_root = 1,
 	.forks_child = 1,
+	.min_swap_avail = SWAP_LIMIT / TST_MB,
 	.needs_cgroup_ctrls = (const char *const []){ "memory", NULL },
 };
-- 
2.53.0


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

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

* Re: [LTP] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
  2026-06-09 15:23 [LTP] [PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail Cyril Hrubis
@ 2026-06-09 15:59 ` linuxtestproject.agent
  2026-06-10  1:18 ` [LTP] [PATCH] " Li Wang
  1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-06-09 15:59 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

On Tue, 9 Jun 2026 17:23:05 +0200, Cyril Hrubis wrote:
> syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail

> -	SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapTotal: %ld", &swap_total);
> -	if (swap_total <= 0)
> -		tst_brk(TCONF, "MADV_FREE does not work without swap");
> [...]
> +	.min_swap_avail = SWAP_LIMIT / TST_MB,

The commit message describes this as moving the existing runtime
checks into the tst_test structure, but the madvise09 change is
not an equivalent transformation.

The old code checked SwapTotal > 0, i.e. whether any swap is
configured at all. The new .min_swap_avail check uses SwapFree
and requires at least SWAP_LIMIT / TST_MB = 16 MB of available
swap. This tightens the requirement in two ways: it looks at
free swap rather than total, and it raises the threshold from
"any swap" to 16 MB.

If this is intentional (which seems reasonable since the test
does need swap space), could the commit message mention the
semantic change for madvise09?

Verdict: Needs revision

---
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] 3+ messages in thread

* Re: [LTP] [PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail
  2026-06-09 15:23 [LTP] [PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail Cyril Hrubis
  2026-06-09 15:59 ` [LTP] " linuxtestproject.agent
@ 2026-06-10  1:18 ` Li Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Li Wang @ 2026-06-10  1:18 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Cyril Hrubis wrote:

> Move the runtime checks for minimal amount of memory or swap from the
> test setup to the tst_test structure.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>

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] 3+ messages in thread

end of thread, other threads:[~2026-06-10  1:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 15:23 [LTP] [PATCH] syscalls/madvise: Make use of .min_swap_avail and .min_mem_avail Cyril Hrubis
2026-06-09 15:59 ` [LTP] " linuxtestproject.agent
2026-06-10  1:18 ` [LTP] [PATCH] " Li Wang

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.