Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: fix khugepaged_race build with older glibc
@ 2026-10-27 12:20 Zenghui Yu
  2026-10-27 12:22 ` Lorenzo Stoakes (ARM)
  2026-10-27 12:38 ` Kiryl Shutsemau
  0 siblings, 2 replies; 3+ messages in thread
From: Zenghui Yu @ 2026-10-27 12:20 UTC (permalink / raw)
  To: linux-mm, linux-kselftest, linux-kernel
  Cc: akpm, david, ljs, liam, vbabka, rppt, surenb, mhocko, kas,
	Zenghui Yu (Huawei)

From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>

glibc versions before 2.37 do not define MADV_COLLAPSE in <sys/mman.h>, so
khugepaged_race fails to build against them (e.g. glibc 2.34):

[root@localhost mm]# make
  CC       khugepaged_race
khugepaged_race.c: In function 'main':
khugepaged_race.c:506:23: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?
  506 |       hpage_pmd_size, MADV_COLLAPSE);
      |                       ^~~~~~~~~~~~~
      |                       MADV_COLD
khugepaged_race.c:506:23: note: each undeclared identifier is reported only once for each function it appears in
make: *** [../lib.mk:225: /data/code/mm/tools/testing/selftests/mm/khugepaged_race] Error 1

Include <linux/mman.h> to get the UAPI definition of MADV_COLLAPSE.

Fixes: 66c374464438 ("selftests/mm: add khugepaged race harness")
Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>
---
 tools/testing/selftests/mm/khugepaged_race.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/mm/khugepaged_race.c b/tools/testing/selftests/mm/khugepaged_race.c
index abb0678522cd..1a27cb39745b 100644
--- a/tools/testing/selftests/mm/khugepaged_race.c
+++ b/tools/testing/selftests/mm/khugepaged_race.c
@@ -8,6 +8,7 @@
 #define _GNU_SOURCE
 #include <errno.h>
 #include <fcntl.h>
+#include <linux/mman.h>
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
-- 
2.56.0



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

* Re: [PATCH] selftests/mm: fix khugepaged_race build with older glibc
  2026-10-27 12:20 [PATCH] selftests/mm: fix khugepaged_race build with older glibc Zenghui Yu
@ 2026-10-27 12:22 ` Lorenzo Stoakes (ARM)
  2026-10-27 12:38 ` Kiryl Shutsemau
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-10-27 12:22 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: linux-mm, linux-kselftest, linux-kernel, akpm, david, liam,
	vbabka, rppt, surenb, mhocko, kas

On Tue, Oct 27, 2026 at 08:20:13PM +0800, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
>
> glibc versions before 2.37 do not define MADV_COLLAPSE in <sys/mman.h>, so
> khugepaged_race fails to build against them (e.g. glibc 2.34):
>
> [root@localhost mm]# make
>   CC       khugepaged_race
> khugepaged_race.c: In function 'main':
> khugepaged_race.c:506:23: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?
>   506 |       hpage_pmd_size, MADV_COLLAPSE);
>       |                       ^~~~~~~~~~~~~
>       |                       MADV_COLD
> khugepaged_race.c:506:23: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [../lib.mk:225: /data/code/mm/tools/testing/selftests/mm/khugepaged_race] Error 1
>
> Include <linux/mman.h> to get the UAPI definition of MADV_COLLAPSE.
>
> Fixes: 66c374464438 ("selftests/mm: add khugepaged race harness")
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>

Seems sensible enough so:

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

> ---
>  tools/testing/selftests/mm/khugepaged_race.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/mm/khugepaged_race.c b/tools/testing/selftests/mm/khugepaged_race.c
> index abb0678522cd..1a27cb39745b 100644
> --- a/tools/testing/selftests/mm/khugepaged_race.c
> +++ b/tools/testing/selftests/mm/khugepaged_race.c
> @@ -8,6 +8,7 @@
>  #define _GNU_SOURCE
>  #include <errno.h>
>  #include <fcntl.h>
> +#include <linux/mman.h>
>  #include <pthread.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> --
> 2.56.0
>

--
Cheers, Lorenzo


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

* Re: [PATCH] selftests/mm: fix khugepaged_race build with older glibc
  2026-10-27 12:20 [PATCH] selftests/mm: fix khugepaged_race build with older glibc Zenghui Yu
  2026-10-27 12:22 ` Lorenzo Stoakes (ARM)
@ 2026-10-27 12:38 ` Kiryl Shutsemau
  1 sibling, 0 replies; 3+ messages in thread
From: Kiryl Shutsemau @ 2026-10-27 12:38 UTC (permalink / raw)
  To: Zenghui Yu
  Cc: linux-mm, linux-kselftest, linux-kernel, akpm, david, ljs, liam,
	vbabka, rppt, surenb, mhocko

On Tue, Oct 27, 2026 at 08:20:13PM +0800, Zenghui Yu wrote:
> From: "Zenghui Yu (Huawei)" <zenghui.yu@linux.dev>
> 
> glibc versions before 2.37 do not define MADV_COLLAPSE in <sys/mman.h>, so
> khugepaged_race fails to build against them (e.g. glibc 2.34):
> 
> [root@localhost mm]# make
>   CC       khugepaged_race
> khugepaged_race.c: In function 'main':
> khugepaged_race.c:506:23: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?
>   506 |       hpage_pmd_size, MADV_COLLAPSE);
>       |                       ^~~~~~~~~~~~~
>       |                       MADV_COLD
> khugepaged_race.c:506:23: note: each undeclared identifier is reported only once for each function it appears in
> make: *** [../lib.mk:225: /data/code/mm/tools/testing/selftests/mm/khugepaged_race] Error 1
> 
> Include <linux/mman.h> to get the UAPI definition of MADV_COLLAPSE.
> 
> Fixes: 66c374464438 ("selftests/mm: add khugepaged race harness")
> Signed-off-by: Zenghui Yu (Huawei) <zenghui.yu@linux.dev>

Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>


-- 
  Kiryl Shutsemau / Kirill A. Shutemov


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

end of thread, other threads:[~2026-10-27 12:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 12:20 [PATCH] selftests/mm: fix khugepaged_race build with older glibc Zenghui Yu
2026-10-27 12:22 ` Lorenzo Stoakes (ARM)
2026-10-27 12:38 ` Kiryl Shutsemau

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