selftests/mm: Fix false positives and skip unsupported tests
Subsystems (5)
v4 cover selftests/mm: Fix false positives and skip unsupported tests
Hi all,
This patch series addresses false positives in the generic mm selftests and skips tests that cannot run correctly due to missing features or system limitations.
v3: https://lore.kernel.org/all/[email protected]/
Changes in v4:
- Rebased onto the latest mm-new branch, top commit of the base is commit 916e1f041670 ("drivers/base: move memory_block_add_nid() into the caller"). Dropped the v3 patches that had already been merged and re-applied them to the mm-new branch.
- Only Patch 4 is updated to address review comments, all other patches remain unchanged from v3.
---
v2: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- Rebased onto the latest mm-new branch, top commit of the base is commit 0709ddf8951f ("mm: add zblock allocator").
- Minor refactor based on the review comments.
- Included the tags from the previous version.
---
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Rebased onto the mm-new branch, top commit of the base is commit 3b4a8ad89f7e ("mm: add zblock allocator").
- Split some patches for clarity.
- Updated virtual_address_range test to support testing 4PB VA on PPC64.
- Added proper Fixes: tags.
- Included a patch to skip a failing userfaultfd test when unsupported,
instead of reporting a failure.
---
Please let us know if you have any further comments.
Thanks,
Aboorva
Aboorva Devarajan (3):
selftests/mm: fix child process exit codes in ksm_functional_tests selftests/mm: skip thuge-gen test if system is not setup properly selftests/mm: skip hugepage-mremap test if userfaultfd unavailable
Donet Tom (4):
mm/selftests: Fix incorrect pointer being passed to mark_range() selftests/mm: Add support to test 4PB VA on PPC64 selftest/mm: Fix ksm_funtional_test failures mm/selftests: Fix split_huge_page_test failure on systems with 64KB
page size
tools/testing/selftests/mm/cow.c | 5 ---- tools/testing/selftests/mm/hugepage-mremap.c | 16 +++++++++-- .../selftests/mm/ksm_functional_tests.c | 28 +++++++++++++------ .../selftests/mm/split_huge_page_test.c | 22 +++++++++------ tools/testing/selftests/mm/thuge-gen.c | 11 +++++--- tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ---- .../selftests/mm/virtual_address_range.c | 13 ++++++++- tools/testing/selftests/mm/vm_util.h | 5 ++++ 8 files changed, 71 insertions(+), 34 deletions(-)
Signature · 1 line
2.47.1
PATCH v4 1/7 mm/selftests: Fix incorrect pointer being passed to mark_range()
From: Donet Tom <[email protected]>
In main(), the high address is stored in hptr, but for mark_range(), the address passed is ptr, not hptr. Fixed this by changing ptr[i] to hptr[i] in mark_range() function call.
--- tools/testing/selftests/mm/virtual_address_range.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/virtual_address_range.c +1 -1
@@ -227,7 +227,7 @@ int main(void)if (hptr[i] ==MAP_FAILED )break ; -mark_range (ptr[i],MAP_CHUNK_SIZE ); +mark_range (hptr[i],MAP_CHUNK_SIZE );validate_addr (hptr[i],1 ); } hchunks = i;
Signature · 1 line
2.47.1
Re: [PATCH v4 1/7] mm/selftests: Fix incorrect pointer being passed to mark_range()
Quoted 6 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
In
main(), the high address is stored in hptr, but formark_range(), the address passed is ptr, not hptr. Fixed this by changing ptr[i] to hptr[i] inmark_range()function call.
Quoted 7 lines
Fixes b2a79f62133a ("selftests/mm: virtual_address_range: unmap chunks after validation")Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me
PATCH v4 2/7 selftests/mm: Add support to test 4PB VA on PPC64
In reply to Aboorva DevarajanFrom: Donet Tom <[email protected]>
PowerPC64 supports a 4PB virtual address space, but this test was previously limited to 512TB. This patch extends the coverage up to the full 4PB VA range on PowerPC64.
Memory from 0 to 128TB is allocated without an address hint, while allocations from 128TB to 4PB use a hint address.
--- tools/testing/selftests/mm/virtual_address_range.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/mm/virtual_address_range.c +11 -0
@@ -44,12 +44,18 @@* On Arm64 the address space is 256TB and support for * high mappings up to 4PB virtual address space has * been added. +* +* On PowerPC64, the address space up to 128TB can be +* mapped without a hint. Addresses beyond 128TB, up to +* 4PB, can be mapped with a hint. +* */ #define NR_CHUNKS_128TB ((128 * SZ_1TB) / MAP_CHUNK_SIZE)/* Number of chunks for 128TB */ #define NR_CHUNKS_256TB (NR_CHUNKS_128TB * 2UL)#define NR_CHUNKS_384TB (NR_CHUNKS_128TB * 3UL)#define NR_CHUNKS_3840TB (NR_CHUNKS_128TB * 30UL) +#define NR_CHUNKS_3968TB (NR_CHUNKS_128TB * 31UL)#define ADDR_MARK_128TB (1UL << 47)/* First address beyond 128TB */ #define ADDR_MARK_256TB (1UL << 48)/* First address beyond 256TB */
@@ -59,6 +65,11 @@#define HIGH_ADDR_SHIFT 49#define NR_CHUNKS_LOW NR_CHUNKS_256TB#define NR_CHUNKS_HIGH NR_CHUNKS_3840TB +#elif defined(__PPC64__) +#define HIGH_ADDR_MARK ADDR_MARK_128TB +#define HIGH_ADDR_SHIFT 48 +#define NR_CHUNKS_LOW NR_CHUNKS_128TB +#define NR_CHUNKS_HIGH NR_CHUNKS_3968TB#else #define HIGH_ADDR_MARK ADDR_MARK_128TB#define HIGH_ADDR_SHIFT 48
Signature · 1 line
2.47.1
Re: [PATCH v4 2/7] selftests/mm: Add support to test 4PB VA on PPC64
Quoted 9 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
PowerPC64 supports a 4PB virtual address space, but this test was previously limited to 512TB. This patch extends the coverage up to the full 4PB VA range on PowerPC64.
Memory from 0 to 128TB is allocated without an address hint, while allocations from 128TB to 4PB use a hint address.
Quoted 6 lines
Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me
PATCH v4 3/7 selftest/mm: Fix ksm_funtional_test failures
In reply to Aboorva DevarajanFrom: Donet Tom <[email protected]>
This patch fixed 2 issues.
1) After fork() in test_prctl_fork, the child process uses the file descriptors from the parent process to read ksm_stat and ksm_merging_pages. This results in incorrect values being read (parent process ksm_stat and ksm_merging_pages will be read in child), causing the test to fail.
This patch calls init_global_file_handles() in the child process to ensure that the current process's file descriptors are used to read ksm_stat and ksm_merging_pages.
2) All tests currently call ksm_merge to trigger page merging. To ensure the system remains in a consistent state for subsequent tests, it is better to call ksm_unmerge during the test cleanup phase
In the test_prctl_fork test, after a fork(), reading ksm_merging_pages in the child process returns a non-zero value because a previous test performed a merge, and the child's memory state is inherited from the parent.
Although the child process calls ksm_unmerge, the ksm_merging_pages counter in the parent is reset to zero, while the child's counter remains unchanged. This discrepancy causes the test to fail.
To avoid this issue, each test should call ksm_unmerge during cleanup to ensure the counter is reset and the system is in a clean state for subsequent tests.
execv argument is an array of pointers to null-terminated strings. In this patch we also added NULL in the execv argument.
--- tools/testing/selftests/mm/ksm_functional_tests.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/ksm_functional_tests.c +11 -1
@@ -46,6 +46,8 @@ static int ksm_use_zero_pages_fd;static int pagemap_fd;static size_t pagesize; +static void init_global_file_handles (void ); +static bool range_maps_duplicates (char *addr,unsigned long size) {unsigned long offs_a, offs_b, pfn_a, pfn_b;
@@ -274,6 +276,7 @@ static void test_unmerge(void)ksft_test_result (!range_maps_duplicates (map, size),"Pages were unmerged\n" ); unmap: +ksm_unmerge ();munmap (map, size); }
@@ -338,6 +341,7 @@ static void test_unmerge_zero_pages(void)ksft_test_result (!range_maps_duplicates (map, size),"KSM zero pages were unmerged\n" ); unmap: +ksm_unmerge ();munmap (map, size); }
@@ -366,6 +370,7 @@ static void test_unmerge_discarded(void)ksft_test_result (!range_maps_duplicates (map, size),"Pages were unmerged\n" ); unmap: +ksm_unmerge ();munmap (map, size); }
@@ -452,6 +457,7 @@ static void test_unmerge_uffd_wp(void) close_uffd:close (uffd); unmap: +ksm_unmerge (); munmap(map, size); }#endif
@@ -515,6 +521,7 @@ static int test_child_ksm(void)else if (map ==MAP_MERGE_SKIP )return -3 ; +ksm_unmerge ();munmap (map, size);return 0 ; }
@@ -548,6 +555,7 @@ static void test_prctl_fork(void) child_pid =fork ();if (!child_pid) { +init_global_file_handles ();exit (test_child_ksm ()); }else if (child_pid <0 ) {ksft_test_result_fail ("fork() failed\n" );
@@ -595,7 +603,7 @@ static void test_prctl_fork_exec(void)return ; }else if (child_pid ==0 ) {char *prg_name ="./ksm_functional_tests" ; -char *argv_for_program[] = { prg_name,FORK_EXEC_CHILD_PRG_NAME }; +char *argv_for_program[] = { prg_name,FORK_EXEC_CHILD_PRG_NAME ,NULL };execv (prg_name, argv_for_program);return ;
@@ -644,6 +652,7 @@ static void test_prctl_unmerge(void)ksft_test_result (!range_maps_duplicates (map, size),"Pages were unmerged\n" ); unmap: +ksm_unmerge ();munmap (map, size); }
@@ -677,6 +686,7 @@ static void test_prot_none(void)ksft_test_result (!range_maps_duplicates (map, size),"Pages were unmerged\n" ); unmap: +ksm_unmerge ();munmap (map, size); }
Signature · 1 line
2.47.1
Re: [PATCH v4 3/7] selftest/mm: Fix ksm_funtional_test failures
Quoted 31 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
This patch fixed 2 issues.
1) After
fork()intest_prctl_fork, the child process uses the file descriptors from the parent process to readksm_statandksm_merging_pages. This results in incorrect values being read (parent processksm_statandksm_merging_pageswill be read in child), causing the test to fail.This patch calls
init_global_file_handles()in the child process to ensure that the current process's file descriptors are used to readksm_statandksm_merging_pages.2) All tests currently call
ksm_mergeto trigger page merging. To ensure the system remains in a consistent state for subsequent tests, it is better to callksm_unmergeduring the test cleanup phaseIn the
test_prctl_forktest, after afork(), readingksm_merging_pagesin the child process returns a non-zero value because a previous test performed a merge, and the child's memory state is inherited from the parent.Although the child process calls
ksm_unmerge, theksm_merging_pagescounter in the parent is reset to zero, while the child's counter remains unchanged. This discrepancy causes the test to fail.To avoid this issue, each test should call
ksm_unmergeduring cleanup to ensure the counter is reset and the system is in a clean state for subsequent tests.
Quoted 7 lines
execv argument is an array of pointers to null-terminated strings. In this patch we also added NULL in the execv argument.
Fixes 6c47de3be3a0 ("selftest/mm: ksm_functional_tests: extend test case for ksm fork/exec")Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Signed-off-by Donet Tom <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me
PATCH v4 4/7 mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
In reply to Aboorva DevarajanFrom: Donet Tom <[email protected]>
The split_huge_page_test fails on systems with a 64KB base page size. This is because the order of a 2MB huge page is different:
On 64KB systems, the order is 5.
On 4KB systems, it's 9.
The test currently assumes a maximum huge page order of 9, which is only valid for 4KB base page systems. On systems with 64KB pages, attempting to split huge pages beyond their actual order (5) causes the test to fail.
In this patch, we calculate the huge page order based on the system's base page size. With this change, the tests now run successfully on both 64KB and 4KB page size systems.
--- tools/testing/selftests/mm/cow.c | 5 ----- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++------- tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ----- tools/testing/selftests/mm/vm_util.h | 5 +++++ 4 files changed, 19 insertions(+), 18 deletions(-)
tools/testing/selftests/mm/cow.c +0 -5
@@ -41,11 +41,6 @@ static size_t hugetlbsizes[10];static int gup_fd;static bool has_huge_zeropage; -static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;
tools/testing/selftests/mm/split_huge_page_test.c +14 -8
@@ -523,6 +523,9 @@ int main(int argc, char **argv)const char *fs_loc;bool created_tmp;int offset; +unsigned int max_order; +unsigned int nr_pages; +unsigned int tests;ksft_print_header ();
@@ -534,35 +537,38 @@ int main(int argc, char **argv)if (argc >1 ) optional_xfs_path = argv[1 ]; -ksft_set_plan (1 +8 +1 +9 +9 +8 *4 +2 ); - pagesize =getpagesize (); pageshift =ffs (pagesize) -1 ; pmd_pagesize =read_pmd_pagesize ();if (!pmd_pagesize)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" ); + nr_pages = pmd_pagesize / pagesize; + max_order =sz2ord (pmd_pagesize); + tests =2 + (max_order -1 ) + (2 * max_order) + (max_order -1 ) *4 +2 ; +ksft_set_plan (tests); + fd_size =2 * pmd_pagesize;split_pmd_zero_pages (); -for (i =0 ; i <9 ; i++) +for (i =0 ; i < max_order; i++)if (i !=1 )split_pmd_thp_to_order (i);split_pte_mapped_thp (); -for (i =0 ; i <9 ; i++) +for (i =0 ; i < max_order; i++)split_file_backed_thp (i); created_tmp =prepare_thp_fs (optional_xfs_path, fs_loc_template, &fs_loc); -for (i =8 ; i >=0 ; i--) +for (i = max_order -1 ; i >=0 ; i--)split_thp_in_pagecache_to_order_at (fd_size, fs_loc, i,-1 ); -for (i =0 ; i <9 ; i++) +for (i =0 ; i < max_order; i++)for (offset =0 ; - offset < pmd_pagesize / pagesize; - offset +=MAX (pmd_pagesize / pagesize /4 ,1 << i)) + offset < nr_pages; + offset +=MAX (nr_pages /4 ,1 << i))split_thp_in_pagecache_to_order_at (fd_size, fs_loc, i, offset);cleanup_thp_fs (fs_loc, created_tmp);
tools/testing/selftests/mm/uffd-wp-mremap.c +0 -5
@@ -19,11 +19,6 @@ static size_t thpsizes[20];static int nr_hugetlbsizes;static size_t hugetlbsizes[10 ]; -static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;
tools/testing/selftests/mm/vm_util.h +5 -0
@@ -127,6 +127,11 @@ static inline void log_test_result(int result)ksft_test_result_report (result,"%s\n" , test_name); } +static inline int sz2ord (size_t size) +{ +return __builtin_ctzll (size /getpagesize ()); +} +void *sys_mremap (void *old_address,unsigned long old_size,unsigned long new_size,int flags,void *new_address);
Signature · 1 line
2.47.1
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
Quoted 17 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
The
split_huge_page_testfails on systems with a 64KB base page size. This is because the order of a 2MB huge page is different:On 64KB systems, the order is 5.
On 4KB systems, it's 9.
The test currently assumes a maximum huge page order of 9, which is only valid for 4KB base page systems. On systems with 64KB pages, attempting to split huge pages beyond their actual order (5) causes the test to fail.
In this patch, we calculate the huge page order based on the system's base page size. With this change, the tests now run successfully on both 64KB and 4KB page size systems.
Quoted 6 lines
Fixes fa6c02315f745 ("mm: huge_memory: a new debugfs interface for splitting THP tests")Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>
Nit below:
Quoted 41 lines
---
tools/testing/selftests/mm/cow.c | 5 ----- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++------- tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ----- tools/testing/selftests/mm/vm_util.h | 5 +++++ 4 files changed, 19 insertions(+), 18 deletions(-)tools/testing/selftests/mm/cow.c +0
-5@@ -41,11 +41,6 @@ static size_t hugetlbsizes[10];static int gup_fd;static bool has_huge_zeropage; -static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;tools/testing/selftests/mm/split_huge_page_test.c +3
-0@@ -523,6 +523,9 @@ int main(int argc, char **argv)const char *fs_loc;bool created_tmp;int offset; +unsigned int max_order; +unsigned int nr_pages; +unsigned int tests;ksft_print_header ();@@ -534,35 +537,38 @@ int main(int argc, char **argv)if (argc >1 ) optional_xfs_path = argv[1 ];
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 547
Quoted 10 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-2-ksft_set_plan (1 +8 +1 +9 +9 +8 *4 +2 ); - pagesize =getpagesize (); pageshift =ffs (pagesize) -1 ; pmd_pagesize =read_pmd_pagesize ();if (!pmd_pagesize)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" ); + nr_pages = pmd_pagesize / pagesize; + max_order =sz2ord (pmd_pagesize);
^
extra space here
Quoted 7 lines
tools/testing/selftests/mm/split_huge_page_test.c +3
-0+ tests =2 + (max_order -1 ) + (2 * max_order) + (max_order -1 ) *4 +2 ; +ksft_set_plan (tests); + fd_size =2 * pmd_pagesize;split_pmd_zero_pages ();
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
Quoted 81 lines · Wei Yang
Quoted 13 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
The
split_huge_page_testfails on systems with a 64KB base page size. This is because the order of a 2MB huge page is different:On 64KB systems, the order is 5.
On 4KB systems, it's 9.
The test currently assumes a maximum huge page order of 9, which is only valid for 4KB base page systems. On systems with 64KB pages, attempting to split huge pages beyond their actual order (5) causes the test to fail.
Quoted 5 lines
In this patch, we calculate the huge page order based on the system's base page size. With this change, the tests now run successfully on both 64KB and 4KB page size systems.
Fixes fa6c02315f745 ("mm: huge_memory: a new debugfs interface forsplitting THP tests")
Quoted 5 lines
Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>Reviewed-by Wei Yang <[email protected]>Nit below:
Review
Quoted 8 lines
---
tools/testing/selftests/mm/cow.c | 5 ----- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++------- tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ----- tools/testing/selftests/mm/vm_util.h | 5 +++++ 4 files changed, 19 insertions(+), 18 deletions(-)(quoted diff) +0
-0
b/tools/testing/selftests/mm/cow.cReview
Quoted 16 lines
index
90ee5779662f..e742d9313798100644tools/testing/selftests/mm/cow.c +0
-5@@ -41,11 +41,6 @@ static size_t hugetlbsizes[10];static int gup_fd;static bool has_huge_zeropage; -static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;(quoted diff) +0
-0
b/tools/testing/selftests/mm/split_huge_page_test.cQuoted 25 lines
index
eadbeb820d71..7cbeaebc9d71100644tools/testing/selftests/mm/split_huge_page_test.c +3
-2@@ -523,6 +523,9 @@ int main(int argc, char **argv)const char *fs_loc;bool created_tmp;int offset; +unsigned int max_order; +unsigned int nr_pages; +unsigned int tests;ksft_print_header ();@@ -534,35 +537,38 @@ int main(int argc, char **argv)if (argc >1 ) optional_xfs_path = argv[1 ]; -ksft_set_plan (1 +8 +1 +9 +9 +8 *4 +2 ); - pagesize =getpagesize (); pageshift =ffs (pagesize) -1 ; pmd_pagesize =read_pmd_pagesize ();if (!pmd_pagesize)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" );
Quoted 8 lines
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 547
Quoted 2 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-0+ nr_pages = pmd_pagesize / pagesize; + max_order =sz2ord (pmd_pagesize);^
extra space heretools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 548
Quoted 1 line
tools/testing/selftests/mm/split_huge_page_test.c +1
-0+ tests = 2 + (max_order - 1) + (2 * max_order) + (max_order - 1) *4 + 2;
Is it possible to have some defines instead number for readability?
Thanks
Quoted 12 lines
+
ksft_set_plan(tests);tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 554
Quoted 5 lines
tools/testing/selftests/mm/split_huge_page_test.c +1
-0+ fd_size =2 * pmd_pagesize;split_pmd_zero_pages ();--
Wei Yang
Help you, Help me
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
In reply to Wei YangQuoted 14 lines · Wei Yang
Quoted 13 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
The
split_huge_page_testfails on systems with a 64KB base page size. This is because the order of a 2MB huge page is different:On 64KB systems, the order is 5.
On 4KB systems, it's 9.
The test currently assumes a maximum huge page order of 9, which is only valid for 4KB base page systems. On systems with 64KB pages, attempting to split huge pages beyond their actual order (5) causes the test to fail.
Quoted 5 lines
Quoted 5 lines
In this patch, we calculate the huge page order based on the system's base page size. With this change, the tests now run successfully on both 64KB and 4KB page size systems.
Fixes fa6c02315f745 ("mm: huge_memory: a new debugfs interface for
splitting THP tests")
Quoted 10 lines
Quoted 5 lines
Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>Reviewed-by Wei Yang <[email protected]>Nit below:
Quoted 8 lines
Review
Quoted 8 lines
---
tools/testing/selftests/mm/cow.c | 5 ----- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++------- tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ----- tools/testing/selftests/mm/vm_util.h | 5 +++++ 4 files changed, 19 insertions(+), 18 deletions(-)(quoted diff) +0
-0
b/tools/testing/selftests/mm/cow.c
Quoted 7 lines
Quoted 7 lines
index
90ee5779662f..e742d9313798100644tools/testing/selftests/mm/cow.c +0
-0@@ -41,11 +41,6 @@ static size_t hugetlbsizes[10];static int gup_fd;static bool has_huge_zeropage;
Quoted 9 lines
Review
Quoted 9 lines
tools/testing/selftests/mm/cow.c +0
-5-static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;(quoted diff) +0
-0
b/tools/testing/selftests/mm/split_huge_page_test.c
Quoted 25 lines
Quoted 25 lines
index
eadbeb820d71..7cbeaebc9d71100644tools/testing/selftests/mm/split_huge_page_test.c +3
-2@@ -523,6 +523,9 @@ int main(int argc, char **argv)const char *fs_loc;bool created_tmp;int offset; +unsigned int max_order; +unsigned int nr_pages; +unsigned int tests;ksft_print_header ();@@ -534,35 +537,38 @@ int main(int argc, char **argv)if (argc >1 ) optional_xfs_path = argv[1 ]; -ksft_set_plan (1 +8 +1 +9 +9 +8 *4 +2 ); - pagesize =getpagesize (); pageshift =ffs (pagesize) -1 ; pmd_pagesize =read_pmd_pagesize ();if (!pmd_pagesize)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" );
Quoted 6 lines
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 547
Quoted 2 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-0+ nr_pages = pmd_pagesize / pagesize; + max_order =sz2ord (pmd_pagesize);^
extra space hereQuoted 1 line
tools/testing/selftests/mm/split_huge_page_test.c +1
-0+ tests = 2 + (max_order - 1) + (2 * max_order) + (max_order - 1) *
4 + 2;
Is it possible to have some defines here instead plain numbers? Thanks
Quoted 12 lines
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 554
Quoted 6 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-0+ksft_set_plan (tests); + fd_size =2 * pmd_pagesize;split_pmd_zero_pages ();--
Wei Yang
Help you, Help me
Signature · 10 lines
__________________________________________________ Linux 30 birthday! https://www.linuxfoundation.org/en/linux30th/ Choosing Firefox isn't just choosing a browser. It's a vote for personal freedom online. Here's how you can help <https://www.mozilla.org/en-US/etc/firefox/retention/thank-you-a/?utm_source=desktop-snippet&utm_medium=snippet&utm_campaign=FirefoxBirthday&utm_term=9594&utm_content=REL_ESR&sample_rate=0.001&snippet_name=9594> . Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html Happy 30th Birthday, GNU project <https://gnu.org/gnu30/>
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
Quoted 33 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) renamed from tools/testing/selftests/mm/split_huge_page_test.c +0
-0
tools/testing/selftests/mm/split_huge_page_test.cQuoted 30 lines
Quoted 17 lines
index
eadbeb820d71..7cbeaebc9d71100644tools/testing/selftests/mm/split_huge_page_test.c +3
-0@@ -523,6 +523,9 @@ int main(int argc, char **argv) const char *fs_loc; bool created_tmp; int offset; + unsigned int max_order; + unsigned int nr_pages; + unsigned int tests; ksft_print_header();@@ -534,35 +537,38 @@ int main(int argc, char **argv) if (argc > 1) optional_xfs_path = argv[1];tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 547
Quoted 10 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-2- ksft_set_plan(1+8+1+9+9+8*4+2); - pagesize = getpagesize(); pageshift = ffs(pagesize) - 1; pmd_pagesize = read_pmd_pagesize(); if (!pmd_pagesize) ksft_exit_fail_msg("Reading PMD pagesize failed\n"); + nr_pages = pmd_pagesize / pagesize; + max_order = sz2ord(pmd_pagesize);^
extra space here
Quoted 5 lines
Quoted 1 line
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 548
Quoted 1 line
tools/testing/selftests/mm/split_huge_page_test.c +1
-0+ tests = 2 + (max_order - 1) + (2 * max_order) + (max_order -1) * 4 + 2;
Is it possible to have some defines here instead plain numbers? Thanks
I assume we should look into using kselftest_harness as a separate effort, so we can avoid this manual test calculation completely. I'm afraid even using defines will not make this significntly more readable.
Signature · 3 lines
Cheers David / dhildenb
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
On Sun, Aug 17, 2025 at 10:07:01AM +0200, David Hildenbrand wrote:
[...]
Quoted 8 lines
Quoted 3 lines
Is it possible to have some defines here instead plain numbers? Thanks
I assume we should look into using
kselftest_harnessas a separate effort, so we can avoid this manual test calculation completely. I'm afraid even using defines will not make this significntly more readable.
Agree
Quoted 4 lines
Signature · 3 lines
Cheers David / dhildenb
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 4/7] mm/selftests: Fix split_huge_page_test failure on systems with 64KB page size
In reply to Wei YangQuoted 89 lines · Wei Yang
Quoted 23 lines · Aboorva Devarajan
From: Donet Tom <[email protected]>
The
split_huge_page_testfails on systems with a 64KB base page size.
This is because the order of a 2MB huge page is different:On 64KB systems, the order is 5.
On 4KB systems, it's 9.
The test currently assumes a maximum huge page order of 9, which is only
valid for 4KB base page systems. On systems with 64KB pages, attempting
to split huge pages beyond their actual order (5) causes the test to fail.In this patch, we calculate the huge page order based on the system's base
page size. With this change, the tests now run successfully on both 64KB
and 4KB page size systems.Quoted 7 lines
Fixes fa6c02315f745 ("mm: huge_memory: a new debugfs interface forsplitting THP tests")
Co-developed-by Aboorva Devarajan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Donet Tom <[email protected]>Reviewed-by Wei Yang <[email protected]>Nit below:
Quoted 53 lines
---
tools/testing/selftests/mm/cow.c | 5 ----- .../selftests/mm/split_huge_page_test.c | 22 ++++++++++++----
---
tools/testing/selftests/mm/uffd-wp-mremap.c | 5 ----- tools/testing/selftests/mm/vm_util.h | 5 +++++4 files changed, 19 insertions(+), 18 deletions(-)tools/testing/selftests/mm/cow.c +0
-5@@ -41,11 +41,6 @@ static size_t hugetlbsizes[10];static int gup_fd;static bool has_huge_zeropage; -static int sz2ord (size_t size) -{ -return __builtin_ctzll (size / pagesize); -} -static int detect_thp_sizes (size_t sizes[],int max) {int count =0 ;tools/testing/selftests/mm/split_huge_page_test.c +3
-2@@ -523,6 +523,9 @@ int main(int argc, char **argv)const char *fs_loc;bool created_tmp;int offset; +unsigned int max_order; +unsigned int nr_pages; +unsigned int tests;ksft_print_header ();@@ -534,35 +537,38 @@ int main(int argc, char **argv)if (argc >1 ) optional_xfs_path = argv[1 ]; -ksft_set_plan (1 +8 +1 +9 +9 +8 *4 +2 ); - pagesize =getpagesize (); pageshift =ffs (pagesize) -1 ; pmd_pagesize =read_pmd_pagesize ();if (!pmd_pagesize)ksft_exit_fail_msg ("Reading PMD pagesize failed\n");
Quoted 4 lines
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 547
Quoted 2 lines
tools/testing/selftests/mm/split_huge_page_test.c +2
-0+ nr_pages = pmd_pagesize / pagesize; + max_order = sz2ord(pmd_pagesize);^
extra space here
Hi Wei,
Thanks for the review. I’ve sent a fixup patch for this:
https://lore.kernel.org/all/[email protected]/
Andrew,
Could you please apply the above fixup patch?
Regards,
Aboorva
Quoted 9 lines
Quoted 9 lines
tools/testing/selftests/mm/split_huge_page_test.c +3
-1+ tests = 2 + (max_order - 1) + (2 * max_order) + (max_order - 1) * 4 + 2; + ksft_set_plan(tests); + fd_size = 2 * pmd_pagesize;split_pmd_zero_pages ();
PATCH 1/1 mm/selftests: Fix formattig in split_huge_page_test
In reply to Aboorva DevarajanRemoved an extra space in split_huge_page_test that was introduced by commit 4b76e221794b ("mm/selftests: fix split_huge_page_test failure on systems with 64KB page size").
--- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -544,7 +544,7 @@ int main(int argc, char **argv)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" ); nr_pages = pmd_pagesize / pagesize; - max_order =sz2ord (pmd_pagesize, pagesize); + max_order =sz2ord (pmd_pagesize, pagesize); tests =2 + (max_order -1 ) + (2 * max_order) + (max_order -1 ) *4 +2 ;ksft_set_plan (tests);
Signature · 1 line
2.47.1
Re: [Fixup PATCH] mm/selftests: Fix formattig in split_huge_page_test
Quoted 14 lines · Aboorva Devarajan
Removed an extra space in
split_huge_page_testthat was introduced by commit4b76e221794b("mm/selftests: fixsplit_huge_page_testfailure on systems with 64KB page size").Signed-off-by Aboorva Devarajan <[email protected]>--- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/mm/split_huge_page_test.c +0
-0
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 550
Quoted 8 lines
tools/testing/selftests/mm/split_huge_page_test.c +1
-1@@ -544,7 +544,7 @@ int main(int argc, char **argv)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" ); nr_pages = pmd_pagesize / pagesize; - max_order =sz2ord (pmd_pagesize, pagesize); + max_order =sz2ord (pmd_pagesize, pagesize); tests =2 + (max_order -1 ) + (2 * max_order) + (max_order -1 ) *4 +2 ;ksft_set_plan (tests);
Please just comment next time one the respective patch as review comment.
Signature · 3 lines
Cheers David / dhildenb
Re: [Fixup PATCH] mm/selftests: Fix formattig in split_huge_page_test
Quoted 17 lines · David Hildenbrand
Quoted 16 lines · Aboorva Devarajan
Removed an extra space in
split_huge_page_testthat was introduced by commit4b76e221794b("mm/selftests: fixsplit_huge_page_testfailure on systems with 64KB page size").Signed-off-by Aboorva Devarajan <[email protected]>--- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/mm/split_huge_page_test.c +0
-0@@ -544,7 +544,7 @@ int main(int argc, char **argv)ksft_exit_fail_msg ("Reading PMD pagesize failed\n" );
Quoted 9 lines
tools/testing/selftests/mm/split_huge_page_test.c int main(int argc, char **argv) · line 550
Quoted 6 lines
tools/testing/selftests/mm/split_huge_page_test.c +1
-1nr_pages = pmd_pagesize / pagesize; - max_order =sz2ord (pmd_pagesize, pagesize); + max_order =sz2ord (pmd_pagesize, pagesize); tests =2 + (max_order -1 ) + (2 * max_order) + (max_order -1 ) *4 +2 ;ksft_set_plan (tests);Please just comment next time one the respective patch as review comment.
To clarify what I mean is something like this:
https://lkml.kernel.org/r/[email protected]
Gives more context when the subject directly highlights to which patch you are replying.
Signature · 3 lines
Cheers David / dhildenb
Re: [Fixup PATCH] mm/selftests: Fix formattig in split_huge_page_test
Quoted 28 lines · David Hildenbrand
Quoted 10 lines · David Hildenbrand
Quoted 9 lines · Aboorva Devarajan
Removed an extra space in
split_huge_page_testthat was introduced by commit4b76e221794b("mm/selftests: fixsplit_huge_page_testfailure on systems with 64KB page size").Signed-off-by Aboorva Devarajan <[email protected]>---
tools/testing/selftests/mm/split_huge_page_test.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
Quoted 10 lines
tools/testing/selftests/mm/split_huge_page_test.c +0
-0@@ -544,7 +544,7 @@ int main(int argc, char **argv) ksft_exit_fail_msg("Reading PMD pagesize failed\n");
nr_pages=pmd_pagesize/ pagesize;tools/testing/selftests/mm/split_huge_page_test.c +1
-1- max_order = sz2ord(pmd_pagesize, pagesize); + max_order =sz2ord (pmd_pagesize, pagesize);Quoted 3 lines
tests = 2 + (
max_order- 1) + (2 *max_order) + (max_order- 1) * 4 + 2;ksft_set_plan(tests);Please just comment next time one the respective patch as review comment.
Quoted 6 lines
To clarify what I mean is something like this:
https://lkml.kernel.org/r/[email protected]
Gives more context when the subject directly highlights to which patch you are replying.
Hi David,
Thanks for pointing this out. I’ll make sure to follow this.
Regards,
Aboorva
PATCH v4 5/7 selftests/mm: fix child process exit codes in ksm_functional_tests
In reply to Aboorva DevarajanIn ksm_functional_tests, test_child_ksm() returned negative values to indicate errors. However, when passed to exit(), these were interpreted as large unsigned values (e.g, -2 became 254), leading to incorrect handling in the parent process. As a result, some tests appeared to be skipped or silently failed.
This patch changes test_child_ksm() to return positive error codes (1, 2,
3) and updates test_child_ksm_err() to interpret them correctly. Additionally, test_prctl_fork_exec() now uses exit(4) after a failed execv() to clearly signal exec failures. This ensures the parent accurately detects and reports child process failures.
--------------
Before patch:
--------------
- [RUN] test_unmerge
ok 1 Pages were unmerged
...
- [RUN] test_prctl_fork
- No pages got merged
- [RUN] test_prctl_fork_exec
ok 7 PR_SET_MEMORY_MERGE value is inherited
...
Bail out! 1 out of 8 tests failed
- Planned tests != run tests (9 != 8)
- Totals: pass:7 fail:1 xfail:0 xpass:0 skip:0 error:0
--------------
After patch:
--------------
- [RUN] test_unmerge
ok 1 Pages were unmerged
...
- [RUN] test_prctl_fork
- No pages got merged
not ok 7 Merge in child failed
- [RUN] test_prctl_fork_exec
ok 8 PR_SET_MEMORY_MERGE value is inherited
...
Bail out! 2 out of 9 tests failed
- Totals: pass:7 fail:2 xfail:0 xpass:0 skip:0 error:0
--- .../testing/selftests/mm/ksm_functional_tests.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
tools/testing/selftests/mm/ksm_functional_tests.c +9 -7
@@ -512,14 +512,14 @@ static int test_child_ksm(void)/* Test if KSM is enabled for the process. */ if (prctl (PR_GET_MEMORY_MERGE ,0 ,0 ,0 ,0 ) !=1 ) -return -1 ; +return 1 ;/* Test if merge could really happen. */ map =__mmap_and_merge_range (0xcf , size,PROT_READ |PROT_WRITE ,KSM_MERGE_NONE );if (map ==MAP_MERGE_FAIL ) -return -2 ; +return 2 ;else if (map ==MAP_MERGE_SKIP ) -return -3 ; +return 3 ;ksm_unmerge ();munmap (map, size);
@@ -528,12 +528,14 @@ static int test_child_ksm(void)static void test_child_ksm_err (int status) { -if (status ==-1 ) +if (status ==1 )ksft_test_result_fail ("unexpected PR_GET_MEMORY_MERGE result in child\n" ); -else if (status ==-2 ) +else if (status ==2 )ksft_test_result_fail ("Merge in child failed\n" ); -else if (status ==-3 ) +else if (status ==3 )ksft_test_result_skip ("Merge in child skipped\n" ); +else if (status ==4 ) +ksft_test_result_fail ("Binary not found\n" ); }/* Verify that prctl ksm flag is inherited. */
@@ -606,7 +608,7 @@ static void test_prctl_fork_exec(void)char *argv_for_program[] = { prg_name,FORK_EXEC_CHILD_PRG_NAME ,NULL };execv (prg_name, argv_for_program); -return ; +exit (4 ); }if (waitpid (child_pid, &status,0 ) >0 ) {
Signature · 1 line
2.47.1
Re: [PATCH v4 5/7] selftests/mm: fix child process exit codes in ksm_functional_tests
Quoted 5 lines · Aboorva Devarajan
In
ksm_functional_tests,test_child_ksm()returned negative values to indicate errors. However, when passed toexit(), these were interpreted as large unsigned values (e.g, -2 became 254), leading to incorrect handling in the parent process. As a result, some tests appeared to be skipped or silently failed.
This is because "the least significant 8 bits" is returned to parent, right?
Quoted 37 lines
This patch changes
test_child_ksm()to return positive error codes (1, 2,
3) and updatestest_child_ksm_err()to interpret them correctly. Additionally,test_prctl_fork_exec()now uses exit(4) after a failedexecv()to clearly signal exec failures. This ensures the parent accurately detects and reports child process failures.--------------
Before patch:
--------------
- [RUN]test_unmerge
ok 1 Pages were unmerged
...
- [RUN]test_prctl_fork
- No pages got merged
- [RUN]test_prctl_fork_exec
ok 7PR_SET_MEMORY_MERGEvalue is inherited
...
Bail out! 1 out of 8 tests failed
- Planned tests != run tests (9 != 8)
- Totals: pass:7 fail:1 xfail:0 xpass:0 skip:0 error:0--------------
After patch:
--------------
- [RUN]test_unmerge
ok 1 Pages were unmerged
...
- [RUN]test_prctl_fork
- No pages got merged
not ok 7 Merge in child failed
- [RUN]test_prctl_fork_exec
ok 8PR_SET_MEMORY_MERGEvalue is inherited
...
Bail out! 2 out of 9 tests failed
- Totals: pass:7 fail:2 xfail:0 xpass:0 skip:0 error:0
Quoted 5 lines
Fixes 6c47de3be3a0 ("selftest/mm: ksm_functional_tests: extend test case for ksm fork/exec")Co-developed-by Donet Tom <[email protected]>Signed-off-by Donet Tom <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>
If so:
Thanks, I am afraid to make the same mistake if you don't point out.
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH v4 5/7] selftests/mm: fix child process exit codes in ksm_functional_tests
On Sat, 2025-08-16 at 14:43 +0000, Wei Yang wrote:
Hi Wei,
Quoted 10 lines · Aboorva Devarajan
Quoted 5 lines
In
ksm_functional_tests,test_child_ksm()returned negative values to indicate errors. However, when passed toexit(), these were interpreted as large unsigned values (e.g, -2 became 254), leading to incorrect handling in the parent process. As a result, some tests appeared to be skipped or silently failed.This is because "the least significant 8 bits" is returned to parent, right?
Yes, that's right. As per the WEXITSTATUS(wstatus) manual:
WEXITSTATUS: returns the exit status of the child. This consists of the least significant 8 bits of the status argument that the child specified in a call to exit(3) or _exit(2) or as the argument for a return statement in main(). This macro should only be employed if WIFEXITED returned true.
Since only the least significant 8 bits are preserved, negative return values can appear as large unsigned codes, so using small positive exit codes ensures the parent interprets the error code correctly.
Quoted 42 lines
Quoted 36 lines
This patch changes
test_child_ksm()to return positive error codes (1, 2,
3) and updatestest_child_ksm_err()to interpret them correctly. Additionally,test_prctl_fork_exec()now uses exit(4) after a failedexecv()to clearly signal exec failures. This ensures the parent accurately detects and reports child process failures.--------------
Before patch:
--------------
- [RUN]test_unmerge
ok 1 Pages were unmerged
...
- [RUN]test_prctl_fork
- No pages got merged
- [RUN]test_prctl_fork_exec
ok 7PR_SET_MEMORY_MERGEvalue is inherited
...
Bail out! 1 out of 8 tests failed
- Planned tests != run tests (9 != 8)
- Totals: pass:7 fail:1 xfail:0 xpass:0 skip:0 error:0--------------
After patch:
--------------
- [RUN]test_unmerge
ok 1 Pages were unmerged
...
- [RUN]test_prctl_fork
- No pages got merged
not ok 7 Merge in child failed
- [RUN]test_prctl_fork_exec
ok 8PR_SET_MEMORY_MERGEvalue is inherited
...
Bail out! 2 out of 9 tests failed
- Totals: pass:7 fail:2 xfail:0 xpass:0 skip:0 error:0Quoted 5 lines
Fixes 6c47de3be3a0 ("selftest/mm: ksm_functional_tests: extend test case for ksm fork/exec")Co-developed-by Donet Tom <[email protected]>Signed-off-by Donet Tom <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>
Quoted 5 lines
If so:
Reviewed-by Wei Yang <[email protected]>Thanks, I am afraid to make the same mistake if you don't point out.
Thanks,
Aboorva
PATCH v4 6/7 selftests/mm: skip thuge-gen test if system is not setup properly
In reply to Aboorva DevarajanMake thuge-gen skip instead of fail when it can't run due to system settings. If shmmax is too small or no 1G huge pages are available, the test now prints a warning and is marked as skipped.
-------------------
Before Patch:
-------------------
~ running ./thuge-gen
~ Bail out! Please do echo 262144 > /proc/sys/kernel/shmmax ~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 ~ [FAIL]
not ok 28 thuge-gen ~ exit=1
-------------------
After Patch:
-------------------
~ running ./thuge-gen
~ ~ WARNING: shmmax is too small to run this test. ~ ~ Please run the following command to increase shmmax:
~ ~ echo 262144 > /proc/sys/kernel/shmmax
~ 1..0 ~ SKIP Test skipped due to insufficient shmmax value. ~ [SKIP]
ok 29 thuge-gen ~ SKIP
--- tools/testing/selftests/mm/thuge-gen.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/testing/selftests/mm/thuge-gen.c +7 -4
@@ -177,13 +177,16 @@ void find_pagesizes(void)globfree (&g);read_sysfs ("/proc/sys/kernel/shmmax" , &shmmax_val); -if (shmmax_val <NUM_PAGES * largest) -ksft_exit_fail_msg ("Please do echo %lu > /proc/sys/kernel/shmmax" , - largest *NUM_PAGES ); +if (shmmax_val <NUM_PAGES * largest) { +ksft_print_msg ("WARNING: shmmax is too small to run this test.\n" ); +ksft_print_msg ("Please run the following command to increase shmmax:\n" ); +ksft_print_msg ("echo %lu > /proc/sys/kernel/shmmax\n" , largest *NUM_PAGES ); +ksft_exit_skip ("Test skipped due to insufficient shmmax value.\n" ); + }#if defined(__x86_64__)if (largest !=1U <<30 ) { -ksft_exit_fail_msg ("No GB pages available on x86-64\n" +ksft_exit_skip ("No GB pages available on x86-64\n" "Please boot with hugepagesz=1G hugepages=%d\n" ,NUM_PAGES ); }#endif
Signature · 1 line
2.47.1
Re: [PATCH v4 6/7] selftests/mm: skip thuge-gen test if system is not setup properly
Quoted 24 lines · Aboorva Devarajan
Make thuge-gen skip instead of fail when it can't run due to system settings. If shmmax is too small or no 1G huge pages are available, the test now prints a warning and is marked as skipped.
-------------------
Before Patch:
-------------------
~ running ./thuge-gen
~ Bail out! Please do echo 262144 >/proc/sys/kernel/shmmax~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 ~ [FAIL]
not ok 28 thuge-gen ~ exit=1-------------------
After Patch:
-------------------
~ running ./thuge-gen
~ ~ WARNING: shmmax is too small to run this test. ~ ~ Please run the following command to increase shmmax:
~ ~ echo 262144 >/proc/sys/kernel/shmmax
~ 1..0 ~ SKIP Test skipped due to insufficient shmmax value. ~ [SKIP]
ok 29 thuge-gen ~ SKIP
Quoted 6 lines
Co-developed-by Donet Tom <[email protected]>Signed-off-by Donet Tom <[email protected]>Reviewed-by Dev Jain <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me
PATCH v4 7/7 selftests/mm: skip hugepage-mremap test if userfaultfd unavailable
In reply to Aboorva DevarajanGracefully skip test if userfaultfd is not supported (ENOSYS) or not permitted (EPERM), instead of failing. This avoids misleading failures with clear skip messages.
--------------
Before Patch
--------------
~ running ./hugepage-mremap
...
~ Bail out! userfaultfd: Function not implemented ~ Planned tests != run tests (1 != 0)
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 ~ [FAIL]
not ok 4 hugepage-mremap # exit=1
--------------
After Patch
--------------
~ running ./hugepage-mremap
...
~ ok 2 # SKIP userfaultfd is not supported/not enabled. ~ 1 skipped test(s) detected.
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0 ~ [SKIP]
ok 4 hugepage-mremap # SKIP
--- tools/testing/selftests/mm/hugepage-mremap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/hugepage-mremap.c +13 -3
@@ -65,10 +65,20 @@ static void register_region_with_uffd(char *addr, size_t len)struct uffdio_api uffdio_api;/* Create and enable userfaultfd object. */ - uffd =syscall (__NR_userfaultfd,O_CLOEXEC |O_NONBLOCK ); -if (uffd ==-1 ) -ksft_exit_fail_msg ("userfaultfd: %s\n" ,strerror (errno)); +if (uffd ==-1 ) { +switch (errno) { +case EPERM : +ksft_exit_skip ("Insufficient permissions, try running as root.\n" ); +break ; +case ENOSYS : +ksft_exit_skip ("userfaultfd is not supported/not enabled.\n" ); +break ; +default : +ksft_exit_fail_msg ("userfaultfd failed with %s\n" ,strerror (errno)); +break ; + } + } uffdio_api.api =UFFD_API ; uffdio_api.features =0 ;
Signature · 1 line
2.47.1
Re: [PATCH v4 7/7] selftests/mm: skip hugepage-mremap test if userfaultfd unavailable
Quoted 26 lines · Aboorva Devarajan
Gracefully skip test if userfaultfd is not supported (ENOSYS) or not permitted (EPERM), instead of failing. This avoids misleading failures with clear skip messages.
--------------
Before Patch
--------------
~ running ./hugepage-mremap
...
~ Bail out! userfaultfd: Function not implemented ~ Planned tests != run tests (1 != 0)
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 ~ [FAIL]
not ok 4 hugepage-mremap # exit=1--------------
After Patch
--------------
~ running ./hugepage-mremap
...
~ ok 2 # SKIP userfaultfd is not supported/not enabled. ~ 1 skipped test(s) detected.
~ Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0 ~ [SKIP]
ok 4 hugepage-mremap # SKIP
Quoted 5 lines
Co-developed-by Donet Tom <[email protected]>Signed-off-by Donet Tom <[email protected]>Reviewed-by Zi Yan <[email protected]>Signed-off-by Aboorva Devarajan <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me