* [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure
@ 2025-06-13 1:49 Baolin Wang
2025-06-13 1:49 ` [PATCH v2 2/2] selftests: mm: add shmem collapse as a default test item Baolin Wang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Baolin Wang @ 2025-06-13 1:49 UTC (permalink / raw)
To: akpm, david
Cc: lorenzo.stoakes, Liam.Howlett, npache, ryan.roberts, dev.jain,
baohua, shuah, ziy, baolin.wang, linux-mm, linux-kselftest,
linux-kernel
When running the khugepaged selftest for shmem (./khugepaged all:shmem),
I encountered the following test failures:
"
Run test: collapse_full (khugepaged:shmem)
Collapse multiple fully populated PTE table.... Fail
...
Run test: collapse_single_pte_entry (khugepaged:shmem)
Collapse PTE table with single PTE entry present.... Fail
...
Run test: collapse_full_of_compound (khugepaged:shmem)
Allocate huge page... OK
Split huge page leaving single PTE page table full of compound pages... OK
Collapse PTE table full of compound pages.... Fail
"
The reason for the failure is that, it will set MADV_NOHUGEPAGE to prevent
khugepaged from continuing to scan shmem VMA after khugepaged finishes
scanning in the wait_for_scan() function. Moreover, shmem requires a refault
to establish PMD mappings.
However, after commit 2b0f922323cc ("mm: don't install PMD mappings when
THPs are disabled by the hw/process/vma"), PMD mappings are prevented if the
VMA is set with MADV_NOHUGEPAGE flag, so shmem cannot establish PMD mappings
during refault.
One way to fix this issue is to move the MADV_NOHUGEPAGE setting after the
shmem refault. After shmem refault and check huge, the test case will unmap
the shmem immediately. So it seems unnecessary to set the MADV_NOHUGEPAGE.
Then we can simply drop the MADV_NOHUGEPAGE setting, and all khugepaged test
cases passed.
Fixes: 2b0f922323cc ("mm: don't install PMD mappings when THPs are disabled by the hw/process/vma")
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
Changes from v1:
- Add reviewed tag from Zi. Thanks.
- Drop the MADV_NOHUGEPAGE setting, per David.
---
tools/testing/selftests/mm/khugepaged.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/testing/selftests/mm/khugepaged.c b/tools/testing/selftests/mm/khugepaged.c
index 8a4d34cce36b..4341ce6b3b38 100644
--- a/tools/testing/selftests/mm/khugepaged.c
+++ b/tools/testing/selftests/mm/khugepaged.c
@@ -561,8 +561,6 @@ static bool wait_for_scan(const char *msg, char *p, int nr_hpages,
usleep(TICK);
}
- madvise(p, nr_hpages * hpage_pmd_size, MADV_NOHUGEPAGE);
-
return timeout == -1;
}
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] selftests: mm: add shmem collapse as a default test item
2025-06-13 1:49 [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Baolin Wang
@ 2025-06-13 1:49 ` Baolin Wang
2025-06-13 3:33 ` [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Dev Jain
2025-06-13 7:34 ` David Hildenbrand
2 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2025-06-13 1:49 UTC (permalink / raw)
To: akpm, david
Cc: lorenzo.stoakes, Liam.Howlett, npache, ryan.roberts, dev.jain,
baohua, shuah, ziy, baolin.wang, linux-mm, linux-kselftest,
linux-kernel
Currently, we only test anonymous memory collapse by default. We should also
add shmem collapse as a default test item to catch issues that could break
the test cases.
Reviewed-by: Dev Jain <dev.jain@arm.com>
Tested-by: Dev Jain <dev.jain@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
Changes from v1:
- Collect reviewed and acked tags. Thanks.
---
tools/testing/selftests/mm/run_vmtests.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index 33fc7fafa8f9..a38c984103ce 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -485,6 +485,10 @@ CATEGORY="thp" run_test ./khugepaged
CATEGORY="thp" run_test ./khugepaged -s 2
+CATEGORY="thp" run_test ./khugepaged all:shmem
+
+CATEGORY="thp" run_test ./khugepaged -s 4 all:shmem
+
CATEGORY="thp" run_test ./transhuge-stress -d 20
# Try to create XFS if not provided
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure
2025-06-13 1:49 [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Baolin Wang
2025-06-13 1:49 ` [PATCH v2 2/2] selftests: mm: add shmem collapse as a default test item Baolin Wang
@ 2025-06-13 3:33 ` Dev Jain
2025-06-13 7:34 ` David Hildenbrand
2 siblings, 0 replies; 4+ messages in thread
From: Dev Jain @ 2025-06-13 3:33 UTC (permalink / raw)
To: Baolin Wang, akpm, david
Cc: lorenzo.stoakes, Liam.Howlett, npache, ryan.roberts, baohua,
shuah, ziy, linux-mm, linux-kselftest, linux-kernel
On 13/06/25 7:19 am, Baolin Wang wrote:
> When running the khugepaged selftest for shmem (./khugepaged all:shmem),
> I encountered the following test failures:
> "
> Run test: collapse_full (khugepaged:shmem)
> Collapse multiple fully populated PTE table.... Fail
> ...
> Run test: collapse_single_pte_entry (khugepaged:shmem)
> Collapse PTE table with single PTE entry present.... Fail
> ...
> Run test: collapse_full_of_compound (khugepaged:shmem)
> Allocate huge page... OK
> Split huge page leaving single PTE page table full of compound pages... OK
> Collapse PTE table full of compound pages.... Fail
> "
>
> The reason for the failure is that, it will set MADV_NOHUGEPAGE to prevent
> khugepaged from continuing to scan shmem VMA after khugepaged finishes
> scanning in the wait_for_scan() function. Moreover, shmem requires a refault
> to establish PMD mappings.
>
> However, after commit 2b0f922323cc ("mm: don't install PMD mappings when
> THPs are disabled by the hw/process/vma"), PMD mappings are prevented if the
> VMA is set with MADV_NOHUGEPAGE flag, so shmem cannot establish PMD mappings
> during refault.
>
> One way to fix this issue is to move the MADV_NOHUGEPAGE setting after the
> shmem refault. After shmem refault and check huge, the test case will unmap
> the shmem immediately. So it seems unnecessary to set the MADV_NOHUGEPAGE.
>
> Then we can simply drop the MADV_NOHUGEPAGE setting, and all khugepaged test
> cases passed.
>
> Fixes: 2b0f922323cc ("mm: don't install PMD mappings when THPs are disabled by the hw/process/vma")
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
The test converts from fail to pass for me, for the aforementioned failures.
Reviewed-by: Dev Jain <dev.jain@arm.com>
Tested-by: Dev Jain <dev.jain@arm.com>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure
2025-06-13 1:49 [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Baolin Wang
2025-06-13 1:49 ` [PATCH v2 2/2] selftests: mm: add shmem collapse as a default test item Baolin Wang
2025-06-13 3:33 ` [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Dev Jain
@ 2025-06-13 7:34 ` David Hildenbrand
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2025-06-13 7:34 UTC (permalink / raw)
To: Baolin Wang, akpm
Cc: lorenzo.stoakes, Liam.Howlett, npache, ryan.roberts, dev.jain,
baohua, shuah, ziy, linux-mm, linux-kselftest, linux-kernel
On 13.06.25 03:49, Baolin Wang wrote:
> When running the khugepaged selftest for shmem (./khugepaged all:shmem),
> I encountered the following test failures:
> "
> Run test: collapse_full (khugepaged:shmem)
> Collapse multiple fully populated PTE table.... Fail
> ...
> Run test: collapse_single_pte_entry (khugepaged:shmem)
> Collapse PTE table with single PTE entry present.... Fail
> ...
> Run test: collapse_full_of_compound (khugepaged:shmem)
> Allocate huge page... OK
> Split huge page leaving single PTE page table full of compound pages... OK
> Collapse PTE table full of compound pages.... Fail
> "
>
> The reason for the failure is that, it will set MADV_NOHUGEPAGE to prevent
> khugepaged from continuing to scan shmem VMA after khugepaged finishes
> scanning in the wait_for_scan() function. Moreover, shmem requires a refault
> to establish PMD mappings.
>
> However, after commit 2b0f922323cc ("mm: don't install PMD mappings when
> THPs are disabled by the hw/process/vma"), PMD mappings are prevented if the
> VMA is set with MADV_NOHUGEPAGE flag, so shmem cannot establish PMD mappings
> during refault.
>
> One way to fix this issue is to move the MADV_NOHUGEPAGE setting after the
> shmem refault. After shmem refault and check huge, the test case will unmap
> the shmem immediately. So it seems unnecessary to set the MADV_NOHUGEPAGE.
>
> Then we can simply drop the MADV_NOHUGEPAGE setting, and all khugepaged test
> cases passed.
>
> Fixes: 2b0f922323cc ("mm: don't install PMD mappings when THPs are disabled by the hw/process/vma")
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-13 7:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 1:49 [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Baolin Wang
2025-06-13 1:49 ` [PATCH v2 2/2] selftests: mm: add shmem collapse as a default test item Baolin Wang
2025-06-13 3:33 ` [PATCH v2 1/2] selftests: khugepaged: fix the shmem collapse failure Dev Jain
2025-06-13 7:34 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).