All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] selftests/mm: TAP output and global-state fixes
@ 2026-08-12 12:08 Song Hu
  2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Song Hu @ 2026-08-12 12:08 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: shuah, david, ljs, liam, vbabka, rppt, 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       | 24 +++++++++++++++++++
 tools/testing/selftests/mm/mremap_test.c      | 15 ++++++------
 tools/testing/selftests/mm/uffd-wp-mremap.c   |  2 ++
 3 files changed, 33 insertions(+), 8 deletions(-)

-- 
2.43.0


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

* [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap
  2026-08-12 12:08 [PATCH 0/3] selftests/mm: TAP output and global-state fixes Song Hu
@ 2026-08-12 12:08 ` Song Hu
  2026-08-12 13:42   ` Mike Rapoport
  2026-08-12 12:08 ` [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
  2026-08-12 12:08 ` [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
  2 siblings, 1 reply; 7+ messages in thread
From: Song Hu @ 2026-08-12 12:08 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: shuah, david, ljs, liam, vbabka, rppt, surenb, mhocko, peterx,
	linux-kselftest, linux-kernel, Song Hu

uffd-wp-mremap calls ksft_set_plan() with no preceding ksft_print_header(),
so the "TAP version 13" line is never emitted and the output is not valid
KTAP.  The sibling uffd tests (uffd-stress, uffd-unit-tests) print the
header first; do the same.

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

* [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
  2026-08-12 12:08 [PATCH 0/3] selftests/mm: TAP output and global-state fixes Song Hu
  2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
@ 2026-08-12 12:08 ` Song Hu
  2026-08-12 13:42   ` Mike Rapoport
  2026-08-12 12:08 ` [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
  2 siblings, 1 reply; 7+ messages in thread
From: Song Hu @ 2026-08-12 12:08 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: shuah, david, ljs, liam, vbabka, rppt, 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().

Signed-off-by: Song Hu <husong@kylinos.cn>
---
 tools/testing/selftests/mm/mremap_test.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c
index 131d9d6db867..d055a4b3b024 100644
--- a/tools/testing/selftests/mm/mremap_test.c
+++ b/tools/testing/selftests/mm/mremap_test.c
@@ -111,18 +111,15 @@ 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));
 		fclose(fp);
-		exit(KSFT_SKIP);
+		ksft_exit_skip("Failed to read /proc/sys/vm/mmap_min_addr: %s\n",
+			       strerror(errno));
 	}
 
 	fclose(fp);
@@ -1250,6 +1247,8 @@ 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)
-- 
2.43.0


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

* [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline
  2026-08-12 12:08 [PATCH 0/3] selftests/mm: TAP output and global-state fixes Song Hu
  2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
  2026-08-12 12:08 ` [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
@ 2026-08-12 12:08 ` Song Hu
  2026-08-12 13:42   ` Mike Rapoport
  2 siblings, 1 reply; 7+ messages in thread
From: Song Hu @ 2026-08-12 12:08 UTC (permalink / raw)
  To: linux-mm, akpm
  Cc: shuah, david, ljs, liam, vbabka, rppt, 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.  Read the original value before the test and restore it before
ksft_finished().

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

diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
index bc202e4ed2bd..35dcf661b091 100644
--- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
+++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
@@ -99,6 +99,23 @@ static int set_enable_soft_offline(int value)
 	return 0;
 }
 
+static int get_enable_soft_offline(void)
+{
+	FILE *fp = fopen("/proc/sys/vm/enable_soft_offline", "r");
+	int value = -1;
+
+	if (!fp) {
+		ksft_perror(EPREFIX "failed to read enable_soft_offline");
+		return -1;
+	}
+	if (fscanf(fp, "%d", &value) != 1) {
+		ksft_perror(EPREFIX "failed to parse enable_soft_offline");
+		value = -1;
+	}
+	fclose(fp);
+	return value;
+}
+
 static int create_hugetlbfs_file(struct statfs *file_stat)
 {
 	int fd;
@@ -185,6 +202,8 @@ static void test_soft_offline_common(int enable_soft_offline)
 
 int main(int argc, char **argv)
 {
+	int orig;
+
 	ksft_print_header();
 
 	if (!hugetlb_setup_default(8))
@@ -192,8 +211,13 @@ int main(int argc, char **argv)
 
 	ksft_set_plan(2);
 
+	orig = get_enable_soft_offline();
+
 	test_soft_offline_common(1);
 	test_soft_offline_common(0);
 
+	if (orig >= 0)
+		set_enable_soft_offline(orig);
+
 	ksft_finished();
 }
-- 
2.43.0


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

* Re: [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline
  2026-08-12 12:08 ` [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
@ 2026-08-12 13:42   ` Mike Rapoport
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2026-08-12 13:42 UTC (permalink / raw)
  To: Song Hu
  Cc: linux-mm, akpm, shuah, david, ljs, liam, vbabka, surenb, mhocko,
	peterx, linux-kselftest, linux-kernel

Hi,

On Wed, Aug 12, 2026 at 08:08:21PM +0800, 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.  Read the original value before the test and restore it before
> ksft_finished().
> 
> Signed-off-by: Song Hu <husong@kylinos.cn>
> ---
>  .../selftests/mm/hugetlb-soft-offline.c       | 24 +++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> index bc202e4ed2bd..35dcf661b091 100644
> --- a/tools/testing/selftests/mm/hugetlb-soft-offline.c
> +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c
> @@ -99,6 +99,23 @@ static int set_enable_soft_offline(int value)
>  	return 0;
>  }
>  
> +static int get_enable_soft_offline(void)
> +{
> +	FILE *fp = fopen("/proc/sys/vm/enable_soft_offline", "r");
> +	int value = -1;
> +
> +	if (!fp) {
> +		ksft_perror(EPREFIX "failed to read enable_soft_offline");
> +		return -1;
> +	}
> +	if (fscanf(fp, "%d", &value) != 1) {
> +		ksft_perror(EPREFIX "failed to parse enable_soft_offline");
> +		value = -1;
> +	}
> +	fclose(fp);
> +	return value;
> +}

We have read_num() in vm_util and write_num() that can replace
set_enable_soft_offline().

> +
>  static int create_hugetlbfs_file(struct statfs *file_stat)
>  {
>  	int fd;
> @@ -185,6 +202,8 @@ static void test_soft_offline_common(int enable_soft_offline)
>  
>  int main(int argc, char **argv)
>  {
> +	int orig;

Please spell out what orig is this.

> +
>  	ksft_print_header();
>  
>  	if (!hugetlb_setup_default(8))
> @@ -192,8 +211,13 @@ int main(int argc, char **argv)
>  
>  	ksft_set_plan(2);
>  
> +	orig = get_enable_soft_offline();
> +
>  	test_soft_offline_common(1);
>  	test_soft_offline_common(0);
>  
> +	if (orig >= 0)
> +		set_enable_soft_offline(orig);
> +
>  	ksft_finished();
>  }
> -- 
> 2.43.0
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap
  2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
@ 2026-08-12 13:42   ` Mike Rapoport
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2026-08-12 13:42 UTC (permalink / raw)
  To: Song Hu
  Cc: linux-mm, akpm, shuah, david, ljs, liam, vbabka, surenb, mhocko,
	peterx, linux-kselftest, linux-kernel

On Wed, Aug 12, 2026 at 08:08:19PM +0800, Song Hu wrote:
> uffd-wp-mremap calls ksft_set_plan() with no preceding ksft_print_header(),
> so the "TAP version 13" line is never emitted and the output is not valid
> KTAP.  The sibling uffd tests (uffd-stress, uffd-unit-tests) print the
> header first; do the same.
> 
> Signed-off-by: Song Hu <husong@kylinos.cn>

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  tools/testing/selftests/mm/uffd-wp-mremap.c | 2 ++
>  1 file changed, 2 insertions(+)

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test
  2026-08-12 12:08 ` [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
@ 2026-08-12 13:42   ` Mike Rapoport
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2026-08-12 13:42 UTC (permalink / raw)
  To: Song Hu
  Cc: linux-mm, akpm, shuah, david, ljs, liam, vbabka, surenb, mhocko,
	peterx, linux-kselftest, linux-kernel

On Wed, Aug 12, 2026 at 08:08:20PM +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().
> 
> Signed-off-by: Song Hu <husong@kylinos.cn>

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

> ---
>  tools/testing/selftests/mm/mremap_test.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)

-- 
Sincerely yours,
Mike.

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

end of thread, other threads:[~2026-08-12 13:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 12:08 [PATCH 0/3] selftests/mm: TAP output and global-state fixes Song Hu
2026-08-12 12:08 ` [PATCH 1/3] selftests/mm: emit TAP header in uffd-wp-mremap Song Hu
2026-08-12 13:42   ` Mike Rapoport
2026-08-12 12:08 ` [PATCH 2/3] selftests/mm: emit TAP header and use TAP skip in mremap_test Song Hu
2026-08-12 13:42   ` Mike Rapoport
2026-08-12 12:08 ` [PATCH 3/3] selftests/mm: restore enable_soft_offline in hugetlb-soft-offline Song Hu
2026-08-12 13:42   ` Mike Rapoport

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.