mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: hugetlb-read-hwpoison: add setup of HugeTLB pages
@ 2026-10-04 20:54 Jaeyeon Lee
  2026-10-05  6:06 ` Sarthak Sharma
  0 siblings, 1 reply; 2+ messages in thread
From: Jaeyeon Lee @ 2026-10-04 20:54 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand, Shuah Khan
  Cc: Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm,
	linux-kselftest, linux-kernel, Jaeyeon Lee

Every test is expected to reserve the HugeTLB pages it needs.
hugetlb-read-hwpoison was not converted, so on a system without
pre-reserved huge pages the MAP_POPULATE mmap() fails with ENOMEM and
every test case is skipped.

Reserve the pages with hugetlb_setup_default(). Each chunk size runs two
HWPOISON tests and a poisoned huge page can't be reused, so reserve two
pages per chunk size. The pool size is restored on exit. The poisoned
pages remain allocated until reboot.

With the patch, all 12 cases pass on a system with no huge pages
reserved (tested on Fedora, x86_64, CONFIG_MEMORY_FAILURE=y).

Assisted-by: LLM
Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
---
 tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
index 70b24e3660c4..31748a24448f 100644
--- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
+++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
@@ -13,6 +13,7 @@
 #include <signal.h>
 
 #include "kselftest.h"
+#include "vm_util.h"
 
 #define MAX_WRITE_READ_CHUNK_SIZE (getpagesize() * 16)
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
@@ -281,6 +282,13 @@ int main(void)
 	size_t i;
 
 	ksft_print_header();
+
+	if (!hugetlb_available())
+		ksft_exit_skip("HugeTLB is not available\n");
+
+	if (!hugetlb_setup_default(ARRAY_SIZE(wr_chunk_sizes) * 2))
+		ksft_exit_skip("Not enough free huge pages\n");
+
 	ksft_set_plan(ARRAY_SIZE(wr_chunk_sizes) * 3);
 
 	signal(SIGBUS, sigbus_handler);
-- 
2.43.0


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

* Re: [PATCH] selftests/mm: hugetlb-read-hwpoison: add setup of HugeTLB pages
  2026-10-04 20:54 [PATCH] selftests/mm: hugetlb-read-hwpoison: add setup of HugeTLB pages Jaeyeon Lee
@ 2026-10-05  6:06 ` Sarthak Sharma
  0 siblings, 0 replies; 2+ messages in thread
From: Sarthak Sharma @ 2026-10-05  6:06 UTC (permalink / raw)
  To: Jaeyeon Lee, Andrew Morton, David Hildenbrand, Shuah Khan
  Cc: Lorenzo Stoakes, Liam R . Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, linux-mm,
	linux-kselftest, linux-kernel



On 10/5/26 2:24 AM, Jaeyeon Lee wrote:
> Every test is expected to reserve the HugeTLB pages it needs.
> hugetlb-read-hwpoison was not converted, so on a system without
> pre-reserved huge pages the MAP_POPULATE mmap() fails with ENOMEM and
> every test case is skipped.
> 
> Reserve the pages with hugetlb_setup_default(). Each chunk size runs two
> HWPOISON tests and a poisoned huge page can't be reused, so reserve two
> pages per chunk size. The pool size is restored on exit. The poisoned
> pages remain allocated until reboot.
> 
> With the patch, all 12 cases pass on a system with no huge pages
> reserved (tested on Fedora, x86_64, CONFIG_MEMORY_FAILURE=y).
> 
> Assisted-by: LLM
> Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
> ---

Looks good to me. Before the patch, all 12 test cases were skipping with
ENOMEM. After the patch, all test cases passed.

Tested-by: Sarthak Sharma <sarthak.sharma@arm.com>
Reviewed-by: Sarthak Sharma <sarthak.sharma@arm.com>

>  tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> index 70b24e3660c4..31748a24448f 100644
> --- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> +++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
> @@ -13,6 +13,7 @@
>  #include <signal.h>
>  
>  #include "kselftest.h"
> +#include "vm_util.h"
>  
>  #define MAX_WRITE_READ_CHUNK_SIZE (getpagesize() * 16)
>  #define MAX(a, b) (((a) > (b)) ? (a) : (b))
> @@ -281,6 +282,13 @@ int main(void)
>  	size_t i;
>  
>  	ksft_print_header();
> +
> +	if (!hugetlb_available())
> +		ksft_exit_skip("HugeTLB is not available\n");
> +
> +	if (!hugetlb_setup_default(ARRAY_SIZE(wr_chunk_sizes) * 2))
> +		ksft_exit_skip("Not enough free huge pages\n");
> +
>  	ksft_set_plan(ARRAY_SIZE(wr_chunk_sizes) * 3);
>  
>  	signal(SIGBUS, sigbus_handler);


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

end of thread, other threads:[~2026-10-05  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-04 20:54 [PATCH] selftests/mm: hugetlb-read-hwpoison: add setup of HugeTLB pages Jaeyeon Lee
2026-10-05  6:06 ` Sarthak Sharma

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

all inboxes | Powered by JetHome®