Thread (17 messages) 17 messages, 2 authors, 23d ago

Re: [PATCH v7 11/13] selftests/mm: skip uffd-stress test when nr_pages_per_cpu is zero

From: Sayali Patil <hidden>
Date: 2026-05-21 09:14:04
Also in: linux-kselftest, linux-mm, lkml


On 21/05/26 12:17, Sayali Patil wrote:
quoted hunk ↗ jump to hunk
uffd-stress currently fails when the computed nr_pages_per_cpu
evaluates to zero:

nr_pages_per_cpu = bytes / page_size / nr_parallel

This can occur on systems with large hugepage sizes (e.g. 1GB) and a
high number of CPUs, where the total allocated memory is sufficient
overall but not enough to provide at least one page per cpu.

In such cases, the failure is due to insufficient test resources
rather than incorrect kernel behaviour. Update the test
to treat this condition as a test skip instead of reporting an error.

Fixes: db0f1c138f18 ("selftests/mm: print some details when uffd-stress gets bad params")
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Tested-by: Venkat Rao Bagalkote <redacted>
Signed-off-by: Sayali Patil <redacted>
---
  tools/testing/selftests/mm/uffd-stress.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c
index 43cc79590136..39e13e2078a9 100644
--- a/tools/testing/selftests/mm/uffd-stress.c
+++ b/tools/testing/selftests/mm/uffd-stress.c
@@ -489,9 +489,9 @@ int main(int argc, char **argv)
  
  	gopts->nr_pages_per_cpu = bytes / gopts->page_size / gopts->nr_parallel;
  	if (!gopts->nr_pages_per_cpu) {
-		_err("pages_per_cpu = 0, cannot test (%lu / %lu / %lu)",
-			bytes, gopts->page_size, gopts->nr_parallel);
-		usage();
+		ksft_print_msg("pages_per_cpu = 0, cannot test (%zu / %lu / %lu)\n",
+			       bytes, gopts->page_size, gopts->nr_parallel);
+		return KSFT_SKIP;
  	}
  
  	bounces = atoi(argv[3]);

Hi Andrew,
Can you please apply the below fixlet on top of this patch as suggested 
by Sashiko.

 From aa8f2eea63defd9b9c1342b83838f48e93e1b918 Mon Sep 17 00:00:00 2001
From: Sayali Patil <redacted>
Date: Thu, 21 May 2026 13:32:51 +0530
Subject: [PATCH] [fixlet] selftests/mm: use ksft_exit_skip() instead of
  KSFT_SKIP in uffd-stress

When nr_pages_per_cpu evaluates to zero, the test is skipped by
printing a message and returning KSFT_SKIP manually.

Replace this with ksft_exit_skip(), which prints the skip message
and exits with the correct skip status in a single helper, making
the code consistent with other selftests.

Signed-off-by: Sayali Patil <redacted>
---
  tools/testing/selftests/mm/uffd-stress.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/mm/uffd-stress.c 
b/tools/testing/selftests/mm/uffd-stress.c
index 39e13e2078a9..3401dd6028f0 100644
--- a/tools/testing/selftests/mm/uffd-stress.c
+++ b/tools/testing/selftests/mm/uffd-stress.c
@@ -489,9 +489,8 @@ int main(int argc, char **argv)

  	gopts->nr_pages_per_cpu = bytes / gopts->page_size / gopts->nr_parallel;
  	if (!gopts->nr_pages_per_cpu) {
-		ksft_print_msg("pages_per_cpu = 0, cannot test (%zu / %lu / %lu)\n",
+		ksft_exit_skip("pages_per_cpu = 0, cannot test (%zu / %lu / %lu)\n",
  			       bytes, gopts->page_size, gopts->nr_parallel);
-		return KSFT_SKIP;
  	}

  	bounces = atoi(argv[3]);
-- 
2.52.0


Thanks,
Sayali
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help