[PATCH v6 0/6] selftests/mm: skip several tests when thp is not available

Chunyu Hu posted 6 patches 1 week, 5 days ago
There is a newer version of this series
tools/testing/selftests/mm/guard-regions.c    |  4 +++
tools/testing/selftests/mm/soft-dirty.c       |  4 ++-
.../selftests/mm/split_huge_page_test.c       | 19 +++-------
tools/testing/selftests/mm/thp_settings.c     | 35 ++-----------------
tools/testing/selftests/mm/thp_settings.h     |  1 -
tools/testing/selftests/mm/transhuge-stress.c |  4 +++
tools/testing/selftests/mm/vm_util.c          | 23 ++++++++++++
tools/testing/selftests/mm/vm_util.h          |  2 ++
8 files changed, 43 insertions(+), 49 deletions(-)
[PATCH v6 0/6] selftests/mm: skip several tests when thp is not available
Posted by Chunyu Hu 1 week, 5 days ago
There are several tests requires transprarent hugepages, when run on thp
disabled kernel such as realtime kernel, there will be false negative.
Mark those tests as skip when thp is not available.

Chagnes in v6:
  - patch 3 add reviewed-by from Lorenzo
  - patch 4 handle the errno before and after close(), suggested by AI

Changes in v5:
  - patch 1, patch 3 updated reviwed-by and acked-by
  - patch 4 adds new patch for robust write_file()

Changes in v4:
  - patch 1 update to use thp_available instead of thp_is_enabled,
    suggested by ai review
  - removed reviewed-by and acked-by

Changes in v3:
  - patch 1 update commit message to show the log snippet with where the
    fail happens, change the 'false positive' to 'false negative'.
    Update reviwed by
  - patch 2 update reviewed-by
  - patch 3 make write_file to void return
  - patch 4 and patch 5 updated reviewed-by/acked-by

Changes in v2:
  - replace 'false postive' with 'false negative' in cover letter
  - patch 1 and patch 2 add reviewed-by/acked-by
  - new patch 3 to add write_file() in vm_util as a common helper
  - patch 4 removed the {} in if block, removed the write_file helper
    rename chunk in v1. Add reviewed-by
  - patch 5 move the exit chunk to the front of ksft_print_headers() as
    suggested by David.  Add review by.

Chunyu Hu (6):
  selftests/mm/guard-regions: skip collapse test when thp not enabled
  selftests/mm: soft-dirty: skip two tests when thp is not available
  selftests/mm: move write_file helper to vm_util
  selftests/mm/vm_util: robust write_file()
  selftests/mm: split_huge_page_test: skip the test when thp is not
    available
  selftests/mm: transhuge_stress: skip the test when thp not available

 tools/testing/selftests/mm/guard-regions.c    |  4 +++
 tools/testing/selftests/mm/soft-dirty.c       |  4 ++-
 .../selftests/mm/split_huge_page_test.c       | 19 +++-------
 tools/testing/selftests/mm/thp_settings.c     | 35 ++-----------------
 tools/testing/selftests/mm/thp_settings.h     |  1 -
 tools/testing/selftests/mm/transhuge-stress.c |  4 +++
 tools/testing/selftests/mm/vm_util.c          | 23 ++++++++++++
 tools/testing/selftests/mm/vm_util.h          |  2 ++
 8 files changed, 43 insertions(+), 49 deletions(-)


base-commit: c369299895a591d96745d6492d4888259b004a9e
-- 
2.53.0
Re: [PATCH v6 0/6] selftests/mm: skip several tests when thp is not available
Posted by Andrew Morton 1 week, 5 days ago
On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <chuhu@redhat.com> wrote:

> There are several tests requires transprarent hugepages, when run on thp
> disabled kernel such as realtime kernel, there will be false negative.
> Mark those tests as skip when thp is not available.

Thanks, I updated mm.git's mm-unstable branch to this version.

> Chagnes in v6:
>   - patch 3 add reviewed-by from Lorenzo
>   - patch 4 handle the errno before and after close(), suggested by AI

Here's how v6 altered mm.git:


 tools/testing/selftests/mm/vm_util.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/tools/testing/selftests/mm/vm_util.c~b
+++ a/tools/testing/selftests/mm/vm_util.c
@@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)
 
 void write_file(const char *path, const char *buf, size_t buflen)
 {
-	int fd;
+	int fd, saved_errno;
 	ssize_t numwritten;
+	if (buflen < 1)
+		ksft_exit_fail_msg("Incorrect buffer len: %zu\n", buflen);
 
 	fd = open(path, O_WRONLY);
 	if (fd == -1)
 		ksft_exit_fail_msg("%s open failed: %s\n", path, strerror(errno));
 
 	numwritten = write(fd, buf, buflen - 1);
+	saved_errno = errno;
 	close(fd);
+	errno = saved_errno;
 	if (numwritten < 1)
-		ksft_exit_fail_msg("Write failed\n");
+		ksft_exit_fail_msg("%s write(%s) failed: %s\n", path, buf,
+				strerror(errno));
+	if (numwritten != buflen - 1)
+		ksft_exit_fail_msg("%s write(%s) is truncated, expected %zu bytes, got %zd bytes\n",
+				path, buf, buflen - 1, numwritten);
 }
_
Re: [PATCH v6 0/6] selftests/mm: skip several tests when thp is not available
Posted by David Hildenbrand (Arm) 1 week, 2 days ago
On 3/24/26 17:09, Andrew Morton wrote:
> On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <chuhu@redhat.com> wrote:
> 
>> There are several tests requires transprarent hugepages, when run on thp
>> disabled kernel such as realtime kernel, there will be false negative.
>> Mark those tests as skip when thp is not available.
> 
> Thanks, I updated mm.git's mm-unstable branch to this version.
> 
>> Chagnes in v6:
>>   - patch 3 add reviewed-by from Lorenzo
>>   - patch 4 handle the errno before and after close(), suggested by AI
> 
> Here's how v6 altered mm.git:
> 
> 
>  tools/testing/selftests/mm/vm_util.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> --- a/tools/testing/selftests/mm/vm_util.c~b
> +++ a/tools/testing/selftests/mm/vm_util.c
> @@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)
>  
>  void write_file(const char *path, const char *buf, size_t buflen)
>  {
> -	int fd;
> +	int fd, saved_errno;
>  	ssize_t numwritten;

Empty line? :)

> +	if (buflen < 1)
> +		ksft_exit_fail_msg("Incorrect buffer len: %zu\n", buflen);

-- 
Cheers,

David
Re: [PATCH v6 0/6] selftests/mm: skip several tests when thp is not available
Posted by Chunyu Hu 1 week ago
On Fri, Mar 27, 2026 at 02:24:58PM +0100, David Hildenbrand (Arm) wrote:
> On 3/24/26 17:09, Andrew Morton wrote:
> > On Tue, 24 Mar 2026 09:33:10 +0800 Chunyu Hu <chuhu@redhat.com> wrote:
> > 
> >> There are several tests requires transprarent hugepages, when run on thp
> >> disabled kernel such as realtime kernel, there will be false negative.
> >> Mark those tests as skip when thp is not available.
> > 
> > Thanks, I updated mm.git's mm-unstable branch to this version.
> > 
> >> Chagnes in v6:
> >>   - patch 3 add reviewed-by from Lorenzo
> >>   - patch 4 handle the errno before and after close(), suggested by AI
> > 
> > Here's how v6 altered mm.git:
> > 
> > 
> >  tools/testing/selftests/mm/vm_util.c |   12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > --- a/tools/testing/selftests/mm/vm_util.c~b
> > +++ a/tools/testing/selftests/mm/vm_util.c
> > @@ -785,15 +785,23 @@ int unpoison_memory(unsigned long pfn)
> >  
> >  void write_file(const char *path, const char *buf, size_t buflen)
> >  {
> > -	int fd;
> > +	int fd, saved_errno;
> >  	ssize_t numwritten;
> 
> Empty line? :)

Good catch. I will add one empty line in the next version. Thanks!

> 
> > +	if (buflen < 1)
> > +		ksft_exit_fail_msg("Incorrect buffer len: %zu\n", buflen);
> 
> -- 
> Cheers,
> 
> David
>