Skip to contentSkip to conversation

selftests/mm: fix khugepaged_race build with older glibc

PATCH Applied Zenghui Yu 3 participants 3 messages Oct 27

Subsystems (3)
lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH 1/1 selftests/mm: fix khugepaged_race build with older glibc

From: "Zenghui Yu (Huawei)" <[email protected]>

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")
---
 tools/testing/selftests/mm/khugepaged_race.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/khugepaged_race.c +1 -0
index abb0678522cd..1a27cb39745b 100644
@@ -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>
Signature · 1 line
2.56.0
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Zenghui Yu

From: "Zenghui Yu (Huawei)" <[email protected]>

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
Quoted 7 lines

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")

Seems sensible enough so:

Quoted 17 lines
---
 tools/testing/selftests/mm/khugepaged_race.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/khugepaged_race.c +1 -1
index abb0678522cd..1a27cb39745b 100644
@@ -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>
--
Quoted 2 lines

2.56.0

--
Cheers, Lorenzo

Reviewed-by on v1 1/1
#2 lore raw
In reply to Zenghui Yu
Quoted 12 lines · Zenghui Yu

From: "Zenghui Yu (Huawei)" <[email protected]>

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
Quoted 7 lines

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")
Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov