selftests/mm: fix khugepaged_race build with older glibc
Subsystems (3)
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_racekhugepaged_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_COLDkhugepaged_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.
--- tools/testing/selftests/mm/khugepaged_race.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/khugepaged_race.c +1 -0
@@ -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
Quoted 12 lines · Zenghui Yu
From: "Zenghui Yu (Huawei)" <[email protected]>
glibc versions before 2.37 do not define
MADV_COLLAPSEin <sys/mman.h>, sokhugepaged_racefails to build against them (e.g. glibc 2.34):[root@localhost mm]# make
CCkhugepaged_racekhugepaged_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 1Include <
linux/mman.h> to get the UAPI definition ofMADV_COLLAPSE.Fixes 66c374464438 ("selftests/mm: add khugepaged race harness")Signed-off-by Zenghui Yu (Huawei) <[email protected]>
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@@ -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
Quoted 12 lines · Zenghui Yu
From: "Zenghui Yu (Huawei)" <[email protected]>
glibc versions before 2.37 do not define
MADV_COLLAPSEin <sys/mman.h>, sokhugepaged_racefails to build against them (e.g. glibc 2.34):[root@localhost mm]# make
CCkhugepaged_racekhugepaged_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 1Include <
linux/mman.h> to get the UAPI definition ofMADV_COLLAPSE.Fixes 66c374464438 ("selftests/mm: add khugepaged race harness")Signed-off-by Zenghui Yu (Huawei) <[email protected]>
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov