[PATCH v2 1/5] selftests/mm/guard-regions: skip collapse test when thp not enabled

Chunyu Hu posted 5 patches 3 weeks ago
There is a newer version of this series
[PATCH v2 1/5] selftests/mm/guard-regions: skip collapse test when thp not enabled
Posted by Chunyu Hu 3 weeks ago
When thp is not available, just skip the collape tests to avoid the false
positive.

Without the change, run with a thp disabled kernel:
  ./run_vmtests.sh -t madv_guard
  <snip/>
  # #  RUN           guard_regions.file.multi_vma ...
  # #            OK  guard_regions.file.multi_vma
  # ok 89 guard_regions.file.multi_vma
  # #  RUN           guard_regions.file.basic ...
  # #            OK  guard_regions.file.basic
  # ok 90 guard_regions.file.basic
  # # FAILED: 87 / 90 tests passed.
  # # 17 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
  # # Totals: pass:70 fail:3 xfail:0 xpass:0 skip:17 error:0
  # [FAIL]
  not ok 1 guard-regions # exit=1
  hwpoison_inject
  # SUMMARY: PASS=0 SKIP=0 FAIL=1

With this change, run with thp disabled kernel:
  ./run_vmtests.sh -t madv_guard
  <snip/>
  # ok 90 guard_regions.file.basic
  # # PASSED: 90 / 90 tests passed.
  # # 20 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
  # # Totals: pass:70 fail:0 xfail:0 xpass:0 skip:20 error:0
  # [PASS]
  ok 1 guard-regions
  hwpoison_inject
  # SUMMARY: PASS=1 SKIP=0 FAIL=0
  1..1

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
CC: Li Wang <liwang@redhat.com>
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
Changes in v2:
  - add reviewed by from Zi and Lorenzo
  - add acked-by from David
---
 tools/testing/selftests/mm/guard-regions.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/mm/guard-regions.c b/tools/testing/selftests/mm/guard-regions.c
index dbd21d66d383..897af9c512f9 100644
--- a/tools/testing/selftests/mm/guard-regions.c
+++ b/tools/testing/selftests/mm/guard-regions.c
@@ -21,6 +21,7 @@
 #include <sys/uio.h>
 #include <unistd.h>
 #include "vm_util.h"
+#include "thp_settings.h"
 
 #include "../pidfd/pidfd.h"
 
@@ -2195,6 +2196,9 @@ TEST_F(guard_regions, collapse)
 	char *ptr;
 	int i;
 
+	if (!thp_is_enabled())
+		SKIP(return, "Transparent Hugepages not available\n");
+
 	/* Need file to be correct size for tests for non-anon. */
 	if (variant->backing != ANON_BACKED)
 		ASSERT_EQ(ftruncate(self->fd, size), 0);

base-commit: f338e77383789c0cae23ca3d48adcc5e9e137e3c
-- 
2.53.0
Re: [PATCH v2 1/5] selftests/mm/guard-regions: skip collapse test when thp not enabled
Posted by Mike Rapoport 3 weeks ago
On Mon, Mar 16, 2026 at 12:43:31PM +0800, Chunyu Hu wrote:
> When thp is not available, just skip the collape tests to avoid the false
> positive.

... to avoid the false negative

> Without the change, run with a thp disabled kernel:
>   ./run_vmtests.sh -t madv_guard
>   <snip/>
>   # #  RUN           guard_regions.file.multi_vma ...
>   # #            OK  guard_regions.file.multi_vma
>   # ok 89 guard_regions.file.multi_vma
>   # #  RUN           guard_regions.file.basic ...
>   # #            OK  guard_regions.file.basic
>   # ok 90 guard_regions.file.basic

It would be useful to include output of two failing THP tests rather
then just the output of the last two test.
You can also add '-n' option to run_vmtest.sh to reduce amount of leading
#, but for that I don't feel strongly.

With that updated

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

-- 
Sincerely yours,
Mike.
Re: [PATCH v2 1/5] selftests/mm/guard-regions: skip collapse test when thp not enabled
Posted by Chunyu Hu 2 weeks, 6 days ago
On Mon, Mar 16, 2026 at 08:18:40AM +0200, Mike Rapoport wrote:
> On Mon, Mar 16, 2026 at 12:43:31PM +0800, Chunyu Hu wrote:
> > When thp is not available, just skip the collape tests to avoid the false
> > positive.
> 
> ... to avoid the false negative

Oops, I missed this one. Will update.

> 
> > Without the change, run with a thp disabled kernel:
> >   ./run_vmtests.sh -t madv_guard
> >   <snip/>
> >   # #  RUN           guard_regions.file.multi_vma ...
> >   # #            OK  guard_regions.file.multi_vma
> >   # ok 89 guard_regions.file.multi_vma
> >   # #  RUN           guard_regions.file.basic ...
> >   # #            OK  guard_regions.file.basic
> >   # ok 90 guard_regions.file.basic
> 
> It would be useful to include output of two failing THP tests rather
> then just the output of the last two test.

Will update in next version. 

> You can also add '-n' option to run_vmtest.sh to reduce amount of leading
> #, but for that I don't feel strongly.

Good to know. Thanks.

> 
> With that updated
> 
> Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> 
> -- 
> Sincerely yours,
> Mike.
>