Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] selftests/mm: TAP output and global-state fixes
@ 2026-08-15  8:07 Song Hu
  2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Song Hu @ 2026-08-15  8:07 UTC (permalink / raw)
  To: akpm, rppt, sarthak.sharma
  Cc: linux-mm, shuah, david, ljs, liam, vbabka, surenb, mhocko, peterx,
	linux-kselftest, linux-kernel, Song Hu

uffd-wp-mremap and mremap_test never print the TAP header (and mremap_test
skips with a bare exit(KSFT_SKIP) rather than a KTAP skip), so their output
is not valid KTAP; hugetlb-soft-offline toggles enable_soft_offline during
the run and leaves it disabled afterwards.

Tested on x86_64.

Song Hu (3):
  selftests/mm: emit TAP header in uffd-wp-mremap
  selftests/mm: emit TAP header and use TAP skip in mremap_test
  selftests/mm: restore enable_soft_offline in hugetlb-soft-offline

 .../selftests/mm/hugetlb-soft-offline.c       | 35 ++++++----------
 tools/testing/selftests/mm/mremap_test.c      | 41 +++++++++++--------
 tools/testing/selftests/mm/uffd-wp-mremap.c   |  2 +
 3 files changed, 37 insertions(+), 41 deletions(-)

---

Changes in v2, per review feedback from Mike Rapoport, Sarthak Sharma and
the Sashiko AI review Andrew Morton pointed at:

- mremap_test: save errno before fclose() in get_mmap_min_addr() so
  strerror() reports the actual failure, and split the ksft_*() messages
  embedding "\n\t" so continuation lines get the "# " prefix.

- hugetlb-soft-offline: restore enable_soft_offline from an atexit()
  handler so it also runs on early exits, and use read_num()/write_num()
  from vm_util instead of the hand-rolled helpers.

v1: https://lore.kernel.org/all/20260812120821.523860-1-husong@kylinos.cn/

-- 
2.43.0



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

* [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap
  2026-08-15  8:07 [PATCH v2 0/3] selftests/mm: TAP output and global-state fixes Song Hu
@ 2026-08-15  8:07 ` Song Hu
  2026-08-17 15:37   ` Usama Anjum
  2026-08-17 16:40   ` Lorenzo Stoakes (ARM)
  2026-08-15  8:07 ` [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
  2026-08-15  8:07 ` [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
  2 siblings, 2 replies; 9+ messages in thread
From: Song Hu @ 2026-08-15  8:07 UTC (permalink / raw)
  To: akpm, rppt, sarthak.sharma
  Cc: linux-mm, shuah, david, ljs, liam, vbabka, surenb, mhocko, peterx,
	linux-kselftest, linux-kernel, Song Hu

uffd-wp-mremap calls ksft_set_plan() without ksft_print_header(), so its
output is not valid KTAP.  Add the header, like the sibling uffd tests
(uffd-stress, uffd-unit-tests).

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
Signed-off-by: Song Hu <husong@kylinos.cn>
---
 tools/testing/selftests/mm/uffd-wp-mremap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c
index c973d6722720..572c2516e874 100644
--- a/tools/testing/selftests/mm/uffd-wp-mremap.c
+++ b/tools/testing/selftests/mm/uffd-wp-mremap.c
@@ -347,6 +347,8 @@ int main(int argc, char **argv)
 	struct thp_settings settings;
 	int i, j, plan = 0;
 
+	ksft_print_header();
+
 	hugepage_save_settings(true, true);
 
 	check_uffd_wp_feature_supported();
-- 
2.43.0



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

* [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
  2026-08-15  8:07 [PATCH v2 0/3] selftests/mm: TAP output and global-state fixes Song Hu
  2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
@ 2026-08-15  8:07 ` Song Hu
  2026-08-17 15:44   ` Usama Anjum
  2026-08-17 16:44   ` Lorenzo Stoakes (ARM)
  2026-08-15  8:07 ` [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
  2 siblings, 2 replies; 9+ messages in thread
From: Song Hu @ 2026-08-15  8:07 UTC (permalink / raw)
  To: akpm, rppt, sarthak.sharma
  Cc: linux-mm, shuah, david, ljs, liam, vbabka, surenb, mhocko, peterx,
	linux-kselftest, linux-kernel, Song Hu

mremap_test calls ksft_set_plan() without ksft_print_header(), and its
get_mmap_min_addr() skip path uses a bare exit(KSFT_SKIP) that prints no
TAP line, so its output is not valid KTAP.  Add the header and switch
the skip to ksft_exit_skip().

Also fix two more KTAP compliance issues spotted in review:

- get_mmap_min_addr() calls strerror(errno) after fclose(), which may
  clobber errno; save errno before fclose() instead.

- Some ksft_*() messages embed "\n\t", so the text after each embedded
  newline is printed without the "# " prefix.  Split those into separate
  messages.

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
Signed-off-by: Song Hu <husong@kylinos.cn>
---
 tools/testing/selftests/mm/mremap_test.c | 41 +++++++++++++-----------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index 131d9d6db867..28f151daabe4 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -111,18 +111,17 @@ static unsigned long long get_mmap_min_addr(void)
 		return addr;
 
 	fp = fopen("/proc/sys/vm/mmap_min_addr", "r");
-	if (fp == NULL) {
-		ksft_print_msg("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
-			strerror(errno));
-		exit(KSFT_SKIP);
-	}
+	if (!fp)
+		ksft_exit_skip("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
+			       strerror(errno));
 
 	n_matched = fscanf(fp, "%llu", &addr);
 	if (n_matched != 1) {
-		ksft_print_msg("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
-			strerror(errno));
+		int err = errno;
+
 		fclose(fp);
-		exit(KSFT_SKIP);
+		ksft_exit_skip("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
+			       strerror(err));
 	}
 
 	fclose(fp);
@@ -1164,10 +1163,11 @@ static void run_mremap_test_case(struct test test_case, int *failures,
 					    rand_addr);
 
 	if (remap_time < 0) {
-		if (test_case.expect_failure)
-			ksft_test_result_xfail("%s\n\tExpected mremap failure\n",
-					      test_case.name);
-		else {
+		if (test_case.expect_failure) {
+			ksft_print_msg("%s: expected mremap failure\n",
+				       test_case.name);
+			ksft_test_result_xfail("%s\n", test_case.name);
+		} else {
 			ksft_test_result_fail("%s\n", test_case.name);
 			*failures += 1;
 		}
@@ -1177,11 +1177,13 @@ static void run_mremap_test_case(struct test test_case, int *failures,
 		 * was faulted in.
 		 */
 		if (threshold_mb == VALIDATION_NO_THRESHOLD ||
-		    test_case.config.region_size <= threshold_mb * _1MB)
-			ksft_test_result_pass("%s\n\tmremap time: %12lldns\n",
-					      test_case.name, remap_time);
-		else
+		    test_case.config.region_size <= threshold_mb * _1MB) {
+			ksft_print_msg("%s: mremap time: %12lldns\n",
+				       test_case.name, remap_time);
 			ksft_test_result_pass("%s\n", test_case.name);
+		} else {
+			ksft_test_result_pass("%s\n", test_case.name);
+		}
 	}
 }
 
@@ -1250,13 +1252,16 @@ int main(int argc, char **argv)
 	time_t t;
 	FILE *maps_fp;
 
+	ksft_print_header();
+
 	pattern_seed = (unsigned int) time(&t);
 
 	if (parse_args(argc, argv, &threshold_mb, &pattern_seed) < 0)
 		exit(EXIT_FAILURE);
 
-	ksft_print_msg("Test configs:\n\tthreshold_mb=%u\n\tpattern_seed=%u\n\n",
-		       threshold_mb, pattern_seed);
+	ksft_print_msg("Test configs:\n");
+	ksft_print_msg("threshold_mb=%u\n", threshold_mb);
+	ksft_print_msg("pattern_seed=%u\n", pattern_seed);
 
 	/*
 	 * set preallocated random array according to test configs; see the
-- 
2.43.0



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

* [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline
  2026-08-15  8:07 [PATCH v2 0/3] selftests/mm: TAP output and global-state fixes Song Hu
  2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
  2026-08-15  8:07 ` [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
@ 2026-08-15  8:07 ` Song Hu
  2026-08-17 15:41   ` Usama Anjum
  2 siblings, 1 reply; 9+ messages in thread
From: Song Hu @ 2026-08-15  8:07 UTC (permalink / raw)
  To: akpm, rppt, sarthak.sharma
  Cc: linux-mm, shuah, david, ljs, liam, vbabka, surenb, mhocko, peterx,
	linux-kselftest, linux-kernel, Song Hu

hugetlb-soft-offline toggles /proc/sys/vm/enable_soft_offline between 1
and 0 (test_soft_offline_common(1) then (0)) and leaves it at 0 when it
finishes, silently disabling soft offlining for the whole system after
the run.

Save the original value before the test and restore it from an atexit()
handler, so the sysctl is also restored when the test exits early via
ksft_exit_fail_msg(), as hugepage_restore_settings_atexit() in
hugepage_settings.c already does.  Use read_num()/write_num() from
vm_util instead of the hand-rolled popen()/fopen() helpers.

Signed-off-by: Song Hu <husong@kylinos.cn>
---
 .../selftests/mm/hugetlb-soft-offline.c       | 35 +++++++------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
index bc202e4ed2bd..86259921d54c 100644
--- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
+++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 
 #include "kselftest.h"
+#include "vm_util.h"
 #include "hugepage_settings.h"
 
 #ifndef MADV_SOFT_OFFLINE
@@ -31,6 +32,8 @@
 
 #define EPREFIX " !!! "
 
+#define ENABLE_SOFT_OFFLINE_PATH "/proc/sys/vm/enable_soft_offline"
+
 static int do_soft_offline(int fd, size_t len, int expect_errno)
 {
 	char *filemap = NULL;
@@ -77,26 +80,12 @@ static int do_soft_offline(int fd, size_t len, int expect_errno)
 	return ret;
 }
 
-static int set_enable_soft_offline(int value)
-{
-	char cmd[256] = {0};
-	FILE *cmdfile = NULL;
-
-	if (value != 0 && value != 1)
-		return -EINVAL;
-
-	sprintf(cmd, "echo %d > /proc/sys/vm/enable_soft_offline", value);
-	cmdfile = popen(cmd, "r");
-
-	if (cmdfile)
-		ksft_print_msg("enable_soft_offline => %d\n", value);
-	else {
-		ksft_perror(EPREFIX "failed to set enable_soft_offline");
-		return errno;
-	}
+static unsigned long orig_enable_soft_offline = -1UL;
 
-	pclose(cmdfile);
-	return 0;
+static void restore_enable_soft_offline(void)
+{
+	if (orig_enable_soft_offline != -1UL)
+		write_num(ENABLE_SOFT_OFFLINE_PATH, orig_enable_soft_offline);
 }
 
 static int create_hugetlbfs_file(struct statfs *file_stat)
@@ -145,10 +134,7 @@ static void test_soft_offline_common(int enable_soft_offline)
 	hugepagesize_kb = file_stat.f_bsize / 1024;
 	ksft_print_msg("Hugepagesize is %ldkB\n", hugepagesize_kb);
 
-	if (set_enable_soft_offline(enable_soft_offline) != 0) {
-		close(fd);
-		ksft_exit_fail_msg("Failed to set enable_soft_offline\n");
-	}
+	write_num(ENABLE_SOFT_OFFLINE_PATH, enable_soft_offline);
 
 	nr_hugepages_before = hugetlb_nr_default_pages();
 
@@ -192,6 +178,9 @@ int main(int argc, char **argv)
 
 	ksft_set_plan(2);
 
+	orig_enable_soft_offline = read_num(ENABLE_SOFT_OFFLINE_PATH);
+	atexit(restore_enable_soft_offline);
+
 	test_soft_offline_common(1);
 	test_soft_offline_common(0);
 
-- 
2.43.0



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

* Re: [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap
  2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
@ 2026-08-17 15:37   ` Usama Anjum
  2026-08-17 16:40   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 9+ messages in thread
From: Usama Anjum @ 2026-08-17 15:37 UTC (permalink / raw)
  To: Song Hu, akpm, rppt, sarthak.sharma
  Cc: usama.anjum, linux-mm, shuah, david, ljs, liam, vbabka, surenb,
	mhocko, peterx, linux-kselftest, linux-kernel

On 15/08/2026 9:07 am, Song Hu wrote:
> uffd-wp-mremap calls ksft_set_plan() without ksft_print_header(), so its
> output is not valid KTAP.  Add the header, like the sibling uffd tests
> (uffd-stress, uffd-unit-tests).
> 
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
>  tools/testing/selftests/mm/uffd-wp-mremap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c
> index c973d6722720..572c2516e874 100644
> --- a/tools/testing/selftests/mm/uffd-wp-mremap.c
> +++ b/tools/testing/selftests/mm/uffd-wp-mremap.c
> @@ -347,6 +347,8 @@ int main(int argc, char **argv)
>  	struct thp_settings settings;
>  	int i, j, plan = 0;
>  
> +	ksft_print_header();
> +

Reviewed-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com>

>  	hugepage_save_settings(true, true);
>  
>  	check_uffd_wp_feature_supported();



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

* Re: [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline
  2026-08-15  8:07 ` [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
@ 2026-08-17 15:41   ` Usama Anjum
  0 siblings, 0 replies; 9+ messages in thread
From: Usama Anjum @ 2026-08-17 15:41 UTC (permalink / raw)
  To: Song Hu, akpm, rppt, sarthak.sharma
  Cc: usama.anjum, linux-mm, shuah, david, ljs, liam, vbabka, surenb,
	mhocko, peterx, linux-kselftest, linux-kernel

On 15/08/2026 9:07 am, Song Hu wrote:
> hugetlb-soft-offline toggles /proc/sys/vm/enable_soft_offline between 1
> and 0 (test_soft_offline_common(1) then (0)) and leaves it at 0 when it
> finishes, silently disabling soft offlining for the whole system after
> the run.
> 
> Save the original value before the test and restore it from an atexit()
> handler, so the sysctl is also restored when the test exits early via
> ksft_exit_fail_msg(), as hugepage_restore_settings_atexit() in
> hugepage_settings.c already does.  Use read_num()/write_num() from
> vm_util instead of the hand-rolled popen()/fopen() helpers.
> 
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
>  .../selftests/mm/hugetlb-soft-offline.c       | 35 +++++++------------
>  1 file changed, 12 insertions(+), 23 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> index bc202e4ed2bd..86259921d54c 100644
> --- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
> +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> @@ -23,6 +23,7 @@
>  #include <sys/types.h>
>  
>  #include "kselftest.h"
> +#include "vm_util.h"
>  #include "hugepage_settings.h"
>  
>  #ifndef MADV_SOFT_OFFLINE
> @@ -31,6 +32,8 @@
>  
>  #define EPREFIX " !!! "
>  
> +#define ENABLE_SOFT_OFFLINE_PATH "/proc/sys/vm/enable_soft_offline"
> +
>  static int do_soft_offline(int fd, size_t len, int expect_errno)
>  {
>  	char *filemap = NULL;
> @@ -77,26 +80,12 @@ static int do_soft_offline(int fd, size_t len, int expect_errno)
>  	return ret;
>  }
>  
> -static int set_enable_soft_offline(int value)
> -{
> -	char cmd[256] = {0};
> -	FILE *cmdfile = NULL;
> -
> -	if (value != 0 && value != 1)
> -		return -EINVAL;
> -
> -	sprintf(cmd, "echo %d > /proc/sys/vm/enable_soft_offline", value);
> -	cmdfile = popen(cmd, "r");
> -
> -	if (cmdfile)
> -		ksft_print_msg("enable_soft_offline => %d\n", value);
> -	else {
> -		ksft_perror(EPREFIX "failed to set enable_soft_offline");
> -		return errno;
> -	}
> +static unsigned long orig_enable_soft_offline = -1UL;
>  
> -	pclose(cmdfile);
> -	return 0;
> +static void restore_enable_soft_offline(void)
> +{
> +	if (orig_enable_soft_offline != -1UL)
> +		write_num(ENABLE_SOFT_OFFLINE_PATH, orig_enable_soft_offline);
>  }
>  
>  static int create_hugetlbfs_file(struct statfs *file_stat)
> @@ -145,10 +134,7 @@ static void test_soft_offline_common(int enable_soft_offline)
>  	hugepagesize_kb = file_stat.f_bsize / 1024;
>  	ksft_print_msg("Hugepagesize is %ldkB\n", hugepagesize_kb);
>  
> -	if (set_enable_soft_offline(enable_soft_offline) != 0) {
> -		close(fd);
> -		ksft_exit_fail_msg("Failed to set enable_soft_offline\n");
> -	}
> +	write_num(ENABLE_SOFT_OFFLINE_PATH, enable_soft_offline);
>  
>  	nr_hugepages_before = hugetlb_nr_default_pages();
>  
> @@ -192,6 +178,9 @@ int main(int argc, char **argv)
>  
>  	ksft_set_plan(2);
>  
> +	orig_enable_soft_offline = read_num(ENABLE_SOFT_OFFLINE_PATH);
> +	atexit(restore_enable_soft_offline);
> +

Seems good. Thanks for fixing.

Reviewed-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Tested-by: Muhammad Usama Anjum <usama.anjum@arm.com>

Thanks,
Usama


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

* Re: [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
  2026-08-15  8:07 ` [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
@ 2026-08-17 15:44   ` Usama Anjum
  2026-08-17 16:44   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 9+ messages in thread
From: Usama Anjum @ 2026-08-17 15:44 UTC (permalink / raw)
  To: Song Hu, akpm, rppt, sarthak.sharma
  Cc: usama.anjum, linux-mm, shuah, david, ljs, liam, vbabka, surenb,
	mhocko, peterx, linux-kselftest, linux-kernel

On 15/08/2026 9:07 am, Song Hu wrote:
> mremap_test calls ksft_set_plan() without ksft_print_header(), and its
> get_mmap_min_addr() skip path uses a bare exit(KSFT_SKIP) that prints no
> TAP line, so its output is not valid KTAP.  Add the header and switch
> the skip to ksft_exit_skip().
> 
> Also fix two more KTAP compliance issues spotted in review:
> 
> - get_mmap_min_addr() calls strerror(errno) after fclose(), which may
>   clobber errno; save errno before fclose() instead.
> 
> - Some ksft_*() messages embed "\n\t", so the text after each embedded
>   newline is printed without the "# " prefix.  Split those into separate
>   messages.
> 
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
>  tools/testing/selftests/mm/mremap_test.c | 41 +++++++++++++-----------
>  1 file changed, 23 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
> index 131d9d6db867..28f151daabe4 100644
> --- a/tools/testing/selftests/mm/mremap_test.c
> +++ b/tools/testing/selftests/mm/mremap_test.c
> @@ -111,18 +111,17 @@ static unsigned long long get_mmap_min_addr(void)
>  		return addr;
>  
>  	fp = fopen("/proc/sys/vm/mmap_min_addr", "r");
> -	if (fp == NULL) {
> -		ksft_print_msg("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> -			strerror(errno));
> -		exit(KSFT_SKIP);
> -	}
> +	if (!fp)
> +		ksft_exit_skip("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> +			       strerror(errno));

The skip conditions are usually at the start of the test before we set
the total number planned tests. If skip like this happens later, it
still counts as failure. I found the following corresponding output
with this patch:

TAP version 13
# Test configs:
# threshold_mb=4
# pattern_seed=1786980558
1..26
ok 1 # SKIP Failed to read /proc/sys/vm/mmap_min_addr: Success
# 1 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
# Planned tests != run tests (26 != 1)
# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0
MREMAP_FORCED_SKIP_RC=4
### MREMAP FORCED READ-SKIP END

>  
>  	n_matched = fscanf(fp, "%llu", &addr);
>  	if (n_matched != 1) {
> -		ksft_print_msg("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> -			strerror(errno));
> +		int err = errno;
> +
>  		fclose(fp);
> -		exit(KSFT_SKIP);
> +		ksft_exit_skip("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> +			       strerror(err));
>  	}
>  
>  	fclose(fp);
> @@ -1164,10 +1163,11 @@ static void run_mremap_test_case(struct test test_case, int *failures,
>  					    rand_addr);
>  
>  	if (remap_time < 0) {
> -		if (test_case.expect_failure)
> -			ksft_test_result_xfail("%s\n\tExpected mremap failure\n",
> -					      test_case.name);
> -		else {
> +		if (test_case.expect_failure) {
> +			ksft_print_msg("%s: expected mremap failure\n",
> +				       test_case.name);
> +			ksft_test_result_xfail("%s\n", test_case.name);
> +		} else {
>  			ksft_test_result_fail("%s\n", test_case.name);
>  			*failures += 1;
>  		}
> @@ -1177,11 +1177,13 @@ static void run_mremap_test_case(struct test test_case, int *failures,
>  		 * was faulted in.
>  		 */
>  		if (threshold_mb == VALIDATION_NO_THRESHOLD ||
> -		    test_case.config.region_size <= threshold_mb * _1MB)
> -			ksft_test_result_pass("%s\n\tmremap time: %12lldns\n",
> -					      test_case.name, remap_time);
> -		else
> +		    test_case.config.region_size <= threshold_mb * _1MB) {
> +			ksft_print_msg("%s: mremap time: %12lldns\n",
> +				       test_case.name, remap_time);
>  			ksft_test_result_pass("%s\n", test_case.name);
> +		} else {
> +			ksft_test_result_pass("%s\n", test_case.name);
> +		}
>  	}
>  }
>  
> @@ -1250,13 +1252,16 @@ int main(int argc, char **argv)
>  	time_t t;
>  	FILE *maps_fp;
>  
> +	ksft_print_header();
> +
>  	pattern_seed = (unsigned int) time(&t);
>  
>  	if (parse_args(argc, argv, &threshold_mb, &pattern_seed) < 0)
>  		exit(EXIT_FAILURE);
>  
> -	ksft_print_msg("Test configs:\n\tthreshold_mb=%u\n\tpattern_seed=%u\n\n",
> -		       threshold_mb, pattern_seed);
> +	ksft_print_msg("Test configs:\n");
> +	ksft_print_msg("threshold_mb=%u\n", threshold_mb);
> +	ksft_print_msg("pattern_seed=%u\n", pattern_seed);
>  
>  	/*
>  	 * set preallocated random array according to test configs; see the

Thanks,
Usama



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

* Re: [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap
  2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
  2026-08-17 15:37   ` Usama Anjum
@ 2026-08-17 16:40   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-08-17 16:40 UTC (permalink / raw)
  To: Song Hu
  Cc: akpm, rppt, sarthak.sharma, linux-mm, shuah, david, liam, vbabka,
	surenb, mhocko, peterx, linux-kselftest, linux-kernel

On Sat, Aug 15, 2026 at 04:07:14PM +0800, Song Hu wrote:
> uffd-wp-mremap calls ksft_set_plan() without ksft_print_header(), so its
> output is not valid KTAP.  Add the header, like the sibling uffd tests
> (uffd-stress, uffd-unit-tests).
>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
> Signed-off-by: Song Hu <husong@kylinos.cn>

This all seems to be yet another way of saying 'somebody didn't use the
kselftest harness and so things went wrong' :)

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  tools/testing/selftests/mm/uffd-wp-mremap.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/mm/uffd-wp-mremap.c b/tools/testing/selftests/mm/uffd-wp-mremap.c
> index c973d6722720..572c2516e874 100644
> --- a/tools/testing/selftests/mm/uffd-wp-mremap.c
> +++ b/tools/testing/selftests/mm/uffd-wp-mremap.c
> @@ -347,6 +347,8 @@ int main(int argc, char **argv)
>  	struct thp_settings settings;
>  	int i, j, plan = 0;
>
> +	ksft_print_header();
> +
>  	hugepage_save_settings(true, true);
>
>  	check_uffd_wp_feature_supported();
> --
> 2.43.0
>

--
Cheers, Lorenzo


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

* Re: [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
  2026-08-15  8:07 ` [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
  2026-08-17 15:44   ` Usama Anjum
@ 2026-08-17 16:44   ` Lorenzo Stoakes (ARM)
  1 sibling, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-08-17 16:44 UTC (permalink / raw)
  To: Song Hu
  Cc: akpm, rppt, sarthak.sharma, linux-mm, shuah, david, liam, vbabka,
	surenb, mhocko, peterx, linux-kselftest, linux-kernel

On Sat, Aug 15, 2026 at 04:07:15PM +0800, Song Hu wrote:
> mremap_test calls ksft_set_plan() without ksft_print_header(), and its
> get_mmap_min_addr() skip path uses a bare exit(KSFT_SKIP) that prints no
> TAP line, so its output is not valid KTAP.  Add the header and switch
> the skip to ksft_exit_skip().
>
> Also fix two more KTAP compliance issues spotted in review:
>
> - get_mmap_min_addr() calls strerror(errno) after fclose(), which may
>   clobber errno; save errno before fclose() instead.
>
> - Some ksft_*() messages embed "\n\t", so the text after each embedded
>   newline is printed without the "# " prefix.  Split those into separate
>   messages.
>
> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>
> Signed-off-by: Song Hu <husong@kylinos.cn>

All LGTM so:

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  tools/testing/selftests/mm/mremap_test.c | 41 +++++++++++++-----------
>  1 file changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
> index 131d9d6db867..28f151daabe4 100644
> --- a/tools/testing/selftests/mm/mremap_test.c
> +++ b/tools/testing/selftests/mm/mremap_test.c
> @@ -111,18 +111,17 @@ static unsigned long long get_mmap_min_addr(void)
>  		return addr;
>
>  	fp = fopen("/proc/sys/vm/mmap_min_addr", "r");
> -	if (fp == NULL) {
> -		ksft_print_msg("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> -			strerror(errno));
> -		exit(KSFT_SKIP);
> -	}
> +	if (!fp)
> +		ksft_exit_skip("Failed to open /proc/sys/vm/mmap_min_addr: %s\n",
> +			       strerror(errno));
>
>  	n_matched = fscanf(fp, "%llu", &addr);
>  	if (n_matched != 1) {
> -		ksft_print_msg("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> -			strerror(errno));
> +		int err = errno;
> +
>  		fclose(fp);
> -		exit(KSFT_SKIP);
> +		ksft_exit_skip("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
> +			       strerror(err));
>  	}
>
>  	fclose(fp);
> @@ -1164,10 +1163,11 @@ static void run_mremap_test_case(struct test test_case, int *failures,
>  					    rand_addr);
>
>  	if (remap_time < 0) {
> -		if (test_case.expect_failure)
> -			ksft_test_result_xfail("%s\n\tExpected mremap failure\n",
> -					      test_case.name);
> -		else {
> +		if (test_case.expect_failure) {
> +			ksft_print_msg("%s: expected mremap failure\n",
> +				       test_case.name);
> +			ksft_test_result_xfail("%s\n", test_case.name);
> +		} else {
>  			ksft_test_result_fail("%s\n", test_case.name);
>  			*failures += 1;
>  		}
> @@ -1177,11 +1177,13 @@ static void run_mremap_test_case(struct test test_case, int *failures,
>  		 * was faulted in.
>  		 */
>  		if (threshold_mb == VALIDATION_NO_THRESHOLD ||
> -		    test_case.config.region_size <= threshold_mb * _1MB)
> -			ksft_test_result_pass("%s\n\tmremap time: %12lldns\n",
> -					      test_case.name, remap_time);
> -		else
> +		    test_case.config.region_size <= threshold_mb * _1MB) {
> +			ksft_print_msg("%s: mremap time: %12lldns\n",
> +				       test_case.name, remap_time);
>  			ksft_test_result_pass("%s\n", test_case.name);
> +		} else {
> +			ksft_test_result_pass("%s\n", test_case.name);
> +		}
>  	}
>  }
>
> @@ -1250,13 +1252,16 @@ int main(int argc, char **argv)
>  	time_t t;
>  	FILE *maps_fp;
>
> +	ksft_print_header();
> +
>  	pattern_seed = (unsigned int) time(&t);
>
>  	if (parse_args(argc, argv, &threshold_mb, &pattern_seed) < 0)
>  		exit(EXIT_FAILURE);
>
> -	ksft_print_msg("Test configs:\n\tthreshold_mb=%u\n\tpattern_seed=%u\n\n",
> -		       threshold_mb, pattern_seed);
> +	ksft_print_msg("Test configs:\n");
> +	ksft_print_msg("threshold_mb=%u\n", threshold_mb);
> +	ksft_print_msg("pattern_seed=%u\n", pattern_seed);
>
>  	/*
>  	 * set preallocated random array according to test configs; see the
> --
> 2.43.0
>

--
Cheers, Lorenzo


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

end of thread, other threads:[~2026-08-17 16:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15  8:07 [PATCH v2 0/3] selftests/mm: TAP output and global-state fixes Song Hu
2026-08-15  8:07 ` [PATCH v2 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
2026-08-17 15:37   ` Usama Anjum
2026-08-17 16:40   ` Lorenzo Stoakes (ARM)
2026-08-15  8:07 ` [PATCH v2 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
2026-08-17 15:44   ` Usama Anjum
2026-08-17 16:44   ` Lorenzo Stoakes (ARM)
2026-08-15  8:07 ` [PATCH v2 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
2026-08-17 15:41   ` Usama Anjum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox