Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev --- tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 192ea3725c5c..ed90deebef0d 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -100,6 +100,7 @@ $(OUTPUT)/madv_populate: vm_util.c $(OUTPUT)/soft-dirty: vm_util.c $(OUTPUT)/split_huge_page_test: vm_util.c $(OUTPUT)/userfaultfd: vm_util.c +$(OUTPUT)/map_hugetlb: vm_util.c
ifeq ($(MACHINE),x86_64) BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 297f250c1d95..4751b28eba18 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -1674,30 +1674,6 @@ static int userfaultfd_stress(void) || userfaultfd_events_test() || userfaultfd_minor_test(); }
-/* - * Copied from mlock2-tests.c - */ -unsigned long default_huge_page_size(void) -{ - unsigned long hps = 0; - char *line = NULL; - size_t linelen = 0; - FILE *f = fopen("/proc/meminfo", "r"); - - if (!f) - return 0; - while (getline(&line, &linelen, f) > 0) { - if (sscanf(line, "Hugepagesize: %lu kB", &hps) == 1) { - hps <<= 10; - break; - } - } - - free(line); - fclose(f); - return hps; -} - static void set_test_type(const char *type) { if (!strcmp(type, "anon")) { diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index fc5743bc1283..613cc61602c9 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -161,6 +161,27 @@ bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size) return __check_huge(addr, "ShmemPmdMapped:", nr_hpages, hpage_size); }
+unsigned long default_huge_page_size(void) +{ + unsigned long hps = 0; + char *line = NULL; + size_t linelen = 0; + FILE *f = fopen("/proc/meminfo", "r"); + + if (!f) + return 0; + while (getline(&line, &linelen, f) > 0) { + if (sscanf(line, "Hugepagesize: %lu kB", &hps) == 1) { + hps <<= 10; + break; + } + } + + free(line); + fclose(f); + return hps; +} + static bool check_vmflag(void *addr, const char *flag) { char buffer[MAX_LINE_LENGTH]; diff --git a/tools/testing/selftests/vm/vm_util.h b/tools/testing/selftests/vm/vm_util.h index 470f85fe9594..a4439db0d6f8 100644 --- a/tools/testing/selftests/vm/vm_util.h +++ b/tools/testing/selftests/vm/vm_util.h @@ -11,4 +11,5 @@ uint64_t read_pmd_pagesize(void); bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size); +unsigned long default_huge_page_size(void); bool softdirty_supported(void);
+Cc: Greg
On 2025/10/22 13:51, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 192ea3725c5c..ed90deebef0d 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -100,6 +100,7 @@ $(OUTPUT)/madv_populate: vm_util.c $(OUTPUT)/soft-dirty: vm_util.c $(OUTPUT)/split_huge_page_test: vm_util.c $(OUTPUT)/userfaultfd: vm_util.c +$(OUTPUT)/map_hugetlb: vm_util.c ifeq ($(MACHINE),x86_64) BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 297f250c1d95..4751b28eba18 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -1674,30 +1674,6 @@ static int userfaultfd_stress(void) || userfaultfd_events_test() || userfaultfd_minor_test(); } -/*
- Copied from mlock2-tests.c
- */
-unsigned long default_huge_page_size(void) -{
- unsigned long hps = 0;
- char *line = NULL;
- size_t linelen = 0;
- FILE *f = fopen("/proc/meminfo", "r");
- if (!f)
return 0;
- while (getline(&line, &linelen, f) > 0) {
if (sscanf(line, "Hugepagesize: %lu kB", &hps) == 1) {
hps <<= 10;
break;
}
- }
- free(line);
- fclose(f);
- return hps;
-}
- static void set_test_type(const char *type) { if (!strcmp(type, "anon")) {
diff --git a/tools/testing/selftests/vm/vm_util.c b/tools/testing/selftests/vm/vm_util.c index fc5743bc1283..613cc61602c9 100644 --- a/tools/testing/selftests/vm/vm_util.c +++ b/tools/testing/selftests/vm/vm_util.c @@ -161,6 +161,27 @@ bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size) return __check_huge(addr, "ShmemPmdMapped:", nr_hpages, hpage_size); } +unsigned long default_huge_page_size(void) +{
- unsigned long hps = 0;
- char *line = NULL;
- size_t linelen = 0;
- FILE *f = fopen("/proc/meminfo", "r");
- if (!f)
return 0;
- while (getline(&line, &linelen, f) > 0) {
if (sscanf(line, "Hugepagesize: %lu kB", &hps) == 1) {
hps <<= 10;
break;
}
- }
- free(line);
- fclose(f);
- return hps;
+}
- static bool check_vmflag(void *addr, const char *flag) { char buffer[MAX_LINE_LENGTH];
diff --git a/tools/testing/selftests/vm/vm_util.h b/tools/testing/selftests/vm/vm_util.h index 470f85fe9594..a4439db0d6f8 100644 --- a/tools/testing/selftests/vm/vm_util.h +++ b/tools/testing/selftests/vm/vm_util.h @@ -11,4 +11,5 @@ uint64_t read_pmd_pagesize(void); bool check_huge_anon(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_file(void *addr, int nr_hpages, uint64_t hpage_size); bool check_huge_shmem(void *addr, int nr_hpages, uint64_t hpage_size); +unsigned long default_huge_page_size(void); bool softdirty_supported(void);
On 22/10/25 14:07, Greg KH wrote:
On Wed, Oct 22, 2025 at 02:01:26PM +0800, Lance Yang wrote:
+Cc: Greg
I have no context here at all :(
Hi Greg,
This patch fixes a build error in the 6.1.y tree.
The mm selftests failed to build, likely because some patches were missed during backporting. I believe it's better to fix it directly here.
Thanks, Leon
On Wed, Oct 22, 2025 at 02:20:26PM +0800, Leon Hwang wrote:
On 22/10/25 14:07, Greg KH wrote:
On Wed, Oct 22, 2025 at 02:01:26PM +0800, Lance Yang wrote:
+Cc: Greg
I have no context here at all :(
Hi Greg,
This patch fixes a build error in the 6.1.y tree.
The mm selftests failed to build, likely because some patches were missed during backporting. I believe it's better to fix it directly here.
Why not take the original patches instead? That's almost always the proper thing to do.
thanks,
greg k-h
On Wed, Oct 22, 2025 at 01:51:38PM +0800, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
What commit id does this fix? And again, why not just take the original commits instead?
thanks,
greg k-h
On 22/10/25 15:40, Greg KH wrote:
On Wed, Oct 22, 2025 at 01:51:38PM +0800, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
What commit id does this fix? And again, why not just take the original
Let me check which commit introduced the fix.
commits instead?
I agree that taking the original commits would be preferable.
However, it might involve quite a few patches to backport, which could be a bit of work.
If the backport turns out to be too complex, I think it’s acceptable to leave the build error as-is for now.
Thanks, Leon
thanks,
greg k-h
On Wed, Oct 22, 2025 at 04:08:45PM +0800, Leon Hwang wrote:
On 22/10/25 15:40, Greg KH wrote:
On Wed, Oct 22, 2025 at 01:51:38PM +0800, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
What commit id does this fix? And again, why not just take the original
Let me check which commit introduced the fix.
commits instead?
I agree that taking the original commits would be preferable.
However, it might involve quite a few patches to backport, which could be a bit of work.
We can easily take lots of patches, don't worry about the quantity. But it would be good to figure out what caused this to break here, and not in other branches.
thanks,
greg k-h
On 2025/10/22 16:20, Greg KH wrote:
On Wed, Oct 22, 2025 at 04:08:45PM +0800, Leon Hwang wrote:
On 22/10/25 15:40, Greg KH wrote:
On Wed, Oct 22, 2025 at 01:51:38PM +0800, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
What commit id does this fix? And again, why not just take the original
Let me check which commit introduced the fix.
commits instead?
I agree that taking the original commits would be preferable.
However, it might involve quite a few patches to backport, which could be a bit of work.
We can easily take lots of patches, don't worry about the quantity. But it would be good to figure out what caused this to break here, and not in other branches.
Hi Greg,
After checking with 'git blame map_hugetlb.c', the issue was introduced by commit a584c7734a4d (“selftests: mm: fix map_hugetlb failure on 64K page size systems”), which corresponds to upstream commit 91b80cc5b39f. This change appears to have caused the build error in the 6.1.y tree.
Comparing several stable trees shows the following:
- 6.0.y: not backported* - 6.1.y: backported - 6.2.y: not backported* - 6.3.y: not backported* - 6.4.y: not backported* - 6.5.y: not backported* - 6.6.y: backported - 6.7.y: backported
Given this, it might be preferable to revert a584c7734a4d in 6.1.y for consistency with the other stable trees (6.0.y, 6.2–6.5.y).
WDYT?
Thanks, Leon
On Wed, Oct 22, 2025 at 09:34:52PM +0800, Leon Hwang wrote:
On 2025/10/22 16:20, Greg KH wrote:
On Wed, Oct 22, 2025 at 04:08:45PM +0800, Leon Hwang wrote:
On 22/10/25 15:40, Greg KH wrote:
On Wed, Oct 22, 2025 at 01:51:38PM +0800, Leon Hwang wrote:
Fix the build error:
map_hugetlb.c: In function 'main': map_hugetlb.c:79:25: warning: implicit declaration of function 'default_huge_page_size' [-Wimplicit-function-declaration] 79 | hugepage_size = default_huge_page_size(); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/bin/ld: /tmp/ccYOogvJ.o: in function 'main': map_hugetlb.c:(.text+0x114): undefined reference to 'default_huge_page_size'
According to the latest selftests, 'default_huge_page_size' has been moved to 'vm_util.c'. So fix the error by the same way.
Reviewed-by: Lance Yang lance.yang@linux.dev Signed-off-by: Leon Hwang leon.hwang@linux.dev
tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/userfaultfd.c | 24 ------------------------ tools/testing/selftests/vm/vm_util.c | 21 +++++++++++++++++++++ tools/testing/selftests/vm/vm_util.h | 1 + 4 files changed, 23 insertions(+), 24 deletions(-)
What commit id does this fix? And again, why not just take the original
Let me check which commit introduced the fix.
commits instead?
I agree that taking the original commits would be preferable.
However, it might involve quite a few patches to backport, which could be a bit of work.
We can easily take lots of patches, don't worry about the quantity. But it would be good to figure out what caused this to break here, and not in other branches.
Hi Greg,
After checking with 'git blame map_hugetlb.c', the issue was introduced by commit a584c7734a4d (“selftests: mm: fix map_hugetlb failure on 64K page size systems”), which corresponds to upstream commit 91b80cc5b39f. This change appears to have caused the build error in the 6.1.y tree.
Comparing several stable trees shows the following:
- 6.0.y: not backported*
- 6.1.y: backported
- 6.2.y: not backported*
- 6.3.y: not backported*
- 6.4.y: not backported*
- 6.5.y: not backported*
- 6.6.y: backported
- 6.7.y: backported
Given this, it might be preferable to revert a584c7734a4d in 6.1.y for consistency with the other stable trees (6.0.y, 6.2–6.5.y).
Ah, yeah, it looks like this commit was reverted from other stable releases, as it shows up in the following releases:
4.19.310 4.19.315 5.4.272 5.4.277 5.10.213 5.10.218 5.15.152 5.15.160 6.1.82 6.6.18 6.7.6
So a revert would be fine, want to submit it?
thanks,
greg k-h
On 2025/10/22 22:26, Greg KH wrote:
On Wed, Oct 22, 2025 at 09:34:52PM +0800, Leon Hwang wrote:
On 2025/10/22 16:20, Greg KH wrote:
[...]
Hi Greg,
After checking with 'git blame map_hugetlb.c', the issue was introduced by commit a584c7734a4d (“selftests: mm: fix map_hugetlb failure on 64K page size systems”), which corresponds to upstream commit 91b80cc5b39f. This change appears to have caused the build error in the 6.1.y tree.
Comparing several stable trees shows the following:
- 6.0.y: not backported*
- 6.1.y: backported
- 6.2.y: not backported*
- 6.3.y: not backported*
- 6.4.y: not backported*
- 6.5.y: not backported*
- 6.6.y: backported
- 6.7.y: backported
Given this, it might be preferable to revert a584c7734a4d in 6.1.y for consistency with the other stable trees (6.0.y, 6.2–6.5.y).
Ah, yeah, it looks like this commit was reverted from other stable releases, as it shows up in the following releases:
4.19.310 4.19.315 5.4.272 5.4.277 5.10.213 5.10.218 5.15.152 5.15.160 6.1.82 6.6.18 6.7.6
So a revert would be fine, want to submit it?
Got it. I'll send a patch to revert it later.
Thanks, Leon
linux-stable-mirror@lists.linaro.org