Skip to contentSkip to conversation

selftests/mm: uffd-wp-mremap: keep the THP sizes in unsigned long

PATCH In review Sasha Levin 4 participants 4 messages Nov 3

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/mm: uffd-wp-mremap: keep the THP sizes in unsigned long

Commit 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size") changed the sizes of the test cases to unsigned long, but left thpsizes and detect_thp_sizes() with size_t. On 32-bit architectures size_t is unsigned int, and gcc 14 rejects the test cases that point at thpsizes:

uffd-wp-mremap.c:299:26: error: initialization of 'long unsigned int *' from incompatible pointer type 'size_t *' {aka 'unsigned int *'} [-Wincompatible-pointer-types]

Use unsigned long for the THP sizes as well.

Fixes 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size")

---
KernelCI's 32-bit arm kselftest builds hit this. Built the mm selftests with gcc 14 and gcc 16 -m32 (four errors in this file before, none after) and natively with gcc and clang (no change). An i386 build with clang runs and detects the THP sizes as before, up to the point where the test needs root.

 tools/testing/selftests/mm/uffd-wp-mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/uffd-wp-mremap.c +2 -2
index c48eaab8e75cf..fb5582ec5b201 100644
@@ -15,7 +15,7 @@ static int pagemap_fd;
 static int nr_pagesizes = 1;
 static unsigned long pagesize;
 static int nr_thpsizes;
-static size_t thpsizes[20];
+static unsigned long thpsizes[20];
 static int nr_hugetlbsizes;
 static unsigned long hugetlbsizes[10];
 
@@ -30,7 +30,7 @@ static void check_uffd_wp_feature_supported(void)
 		ksft_exit_skip("uffd-wp feature not supported\n");
 }
 
-static int detect_thp_sizes(size_t sizes[], int max)
+static int detect_thp_sizes(unsigned long sizes[], int max)
 {
 	int count = 0;
 	unsigned long orders;
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Sasha Levin

Commit 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size") changed the sizes of the test cases to unsigned long, but left thpsizes and detect_thp_sizes() with size_t. On 32-bit architectures size_t is unsigned int, and gcc 14 rejects the test cases that point at thpsizes:

uffd-wp-mremap.c:299:26: error: initialization of 'long unsigned int *' from incompatible pointer type 'size_t *' {aka 'unsigned int *'} [-Wincompatible-pointer-types]

Use unsigned long for the THP sizes as well.

Fixes 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size")

---
KernelCI's 32-bit arm kselftest builds hit this. Built the mm selftests with gcc 14 and gcc 16 -m32 (four errors in this file before, none after) and natively with gcc and clang (no change). An i386 build with clang runs and detects the THP sizes as before, up to the point where the test needs root.

 tools/testing/selftests/mm/uffd-wp-mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/uffd-wp-mremap.c +1 -1
index c48eaab8e75cf..fb5582ec5b201 100644
@@ -15,7 +15,7 @@ static int pagemap_fd;
 static int nr_pagesizes = 1;
 static unsigned long pagesize;
 static int nr_thpsizes;
-static size_t thpsizes[20];
+static unsigned long thpsizes[20];
 static int nr_hugetlbsizes;
 static unsigned long hugetlbsizes[10];
 

tools/testing/selftests/mm/uffd-wp-mremap.c static void check_uffd_wp_feature_supported(void) · line 36

Quoted 8 lines
tools/testing/selftests/mm/uffd-wp-mremap.c +1 -1
@@ -30,7 +30,7 @@ static void check_uffd_wp_feature_supported(void)
 		ksft_exit_skip("uffd-wp feature not supported\n");
 }
 
-static int detect_thp_sizes(size_t sizes[], int max)
+static int detect_thp_sizes(unsigned long sizes[], int max)
 {
 	int count = 0;
 	unsigned long orders;
Signature · 3 lines
Cheers,

David
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Sasha Levin
Quoted 6 lines · Sasha Levin

Commit 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size") changed the sizes of the test cases to unsigned long, but left thpsizes and detect_thp_sizes() with size_t. On 32-bit architectures size_t is unsigned int, and gcc 14 rejects the test cases that point at thpsizes:

Quoted 6 lines

uffd-wp-mremap.c:299:26: error: initialization of 'long unsigned int *' from incompatible pointer type 'size_t *' {aka 'unsigned int *'} [-Wincompatible-pointer-types]

Use unsigned long for the THP sizes as well.

Fixes 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size")

LGTM so:

Quoted 33 lines

---
KernelCI's 32-bit arm kselftest builds hit this. Built the mm selftests with gcc 14 and gcc 16 -m32 (four errors in this file before, none after) and natively with gcc and clang (no change). An i386 build with clang runs and detects the THP sizes as before, up to the point where the test needs root.

 tools/testing/selftests/mm/uffd-wp-mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/uffd-wp-mremap.c +2 -3
index c48eaab8e75cf..fb5582ec5b201 100644
@@ -15,7 +15,7 @@ static int pagemap_fd;
 static int nr_pagesizes = 1;
 static unsigned long pagesize;
 static int nr_thpsizes;
-static size_t thpsizes[20];
+static unsigned long thpsizes[20];
 static int nr_hugetlbsizes;
 static unsigned long hugetlbsizes[10];
 
@@ -30,7 +30,7 @@ static void check_uffd_wp_feature_supported(void)
 		ksft_exit_skip("uffd-wp feature not supported\n");
 }
 
-static int detect_thp_sizes(size_t sizes[], int max)
+static int detect_thp_sizes(unsigned long sizes[], int max)
 {
 	int count = 0;
 	unsigned long orders;
--
Quoted 2 lines

2.53.0

--
Cheers, Lorenzo

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Sasha Levin
Quoted 6 lines · Sasha Levin

Commit 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size") changed the sizes of the test cases to unsigned long, but left thpsizes and detect_thp_sizes() with size_t. On 32-bit architectures size_t is unsigned int, and gcc 14 rejects the test cases that point at thpsizes:

Quoted 6 lines

uffd-wp-mremap.c:299:26: error: initialization of 'long unsigned int *' from incompatible pointer type 'size_t *' {aka 'unsigned int *'} [-Wincompatible-pointer-types]

Use unsigned long for the THP sizes as well.

Fixes 0020a1f5ca36 ("selftests/mm: hugepage_settings: use unsigned long in detect_hugetlb_page_size")
Quoted 35 lines

---
KernelCI's 32-bit arm kselftest builds hit this. Built the mm selftests with gcc 14 and gcc 16 -m32 (four errors in this file before, none after) and natively with gcc and clang (no change). An i386 build with clang runs and detects the THP sizes as before, up to the point where the test needs root.

 tools/testing/selftests/mm/uffd-wp-mremap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/uffd-wp-mremap.c +2 -2
index c48eaab8e75cf..fb5582ec5b201 100644
@@ -15,7 +15,7 @@ static int pagemap_fd;
 static int nr_pagesizes = 1;
 static unsigned long pagesize;
 static int nr_thpsizes;
-static size_t thpsizes[20];
+static unsigned long thpsizes[20];
 static int nr_hugetlbsizes;
 static unsigned long hugetlbsizes[10];
 
@@ -30,7 +30,7 @@ static void check_uffd_wp_feature_supported(void)
 		ksft_exit_skip("uffd-wp feature not supported\n");
 }
 
-static int detect_thp_sizes(size_t sizes[], int max)
+static int detect_thp_sizes(unsigned long sizes[], int max)
 {
 	int count = 0;
 	unsigned long orders;
Signature · 1 line
2.53.0
Signature · 2 lines
Sincerely yours,
Mike.