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

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.