Skip to contentSkip to conversation

selftests/mm: hmm-tests: include linux/mman.h to access MADV_COLLAPSE

PATCH Applied Zenghui Yu 3 participants 3 messages Jun 28 – Jun 30

Subsystems (4)
lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH 1/1 selftests/mm: hmm-tests: include linux/mman.h to access MADV_COLLAPSE

The following compilation error occurs with an old version of glibc due to a recent commit adding MADV_COLLAPSE testing:

[root@localhost mm]# getconf GNU_LIBC_VERSION
glibc 2.34
[root@localhost mm]# make
CC hmm-tests
hmm-tests.c: In function 'hmm_migrate_anon_huge_fault':
hmm-tests.c:2355:27: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?

  2355 |  ret = madvise(map, size, MADV_COLLAPSE);
       |                           ^~~~~~~~~~~~~
       |                           MADV_COLD

hmm-tests.c:2355:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [../lib.mk:225: /root/code/linux/tools/testing/selftests/mm/hmm-tests] Error 1

Include linux/mman.h (which provides the definition of MADV_COLLAPSE) to fix the build error.

Fixes e3d8707358ea ("selftests/mm/hmm-tests: test pagemap reads of PMD device-private entries")
---
 tools/testing/selftests/mm/hmm-tests.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/hmm-tests.c +1 -0
index e4c49699f3f7..2f2b9879d100 100644
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <pthread.h>
 #include <limits.h>
+#include <linux/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Zenghui Yu

The following compilation error occurs with an old version of glibc due to a recent commit adding MADV_COLLAPSE testing:

[root@localhost mm]# getconf GNU_LIBC_VERSION
glibc 2.34
[root@localhost mm]# make
CC hmm-tests
hmm-tests.c: In function 'hmm_migrate_anon_huge_fault':
hmm-tests.c:2355:27: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?

  2355 |  ret = madvise(map, size, MADV_COLLAPSE);
       |                           ^~~~~~~~~~~~~
       |                           MADV_COLD
Quoted 8 lines

hmm-tests.c:2355:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [../lib.mk:225: /root/code/linux/tools/testing/selftests/mm/hmm-tests] Error 1

Include linux/mman.h (which provides the definition of MADV_COLLAPSE) to fix the build error.

Fixes e3d8707358ea ("selftests/mm/hmm-tests: test pagemap reads of PMD device-private entries")

LGTM, so:

Quoted 17 lines
---
 tools/testing/selftests/mm/hmm-tests.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/hmm-tests.c +1 -1
index e4c49699f3f7..2f2b9879d100 100644
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <pthread.h>
 #include <limits.h>
+#include <linux/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
--
Quoted 2 lines

2.53.0

Cheers, Lorenzo

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

The following compilation error occurs with an old version of glibc due to a recent commit adding MADV_COLLAPSE testing:

[root@localhost mm]# getconf GNU_LIBC_VERSION
glibc 2.34
[root@localhost mm]# make
CC hmm-tests
hmm-tests.c: In function 'hmm_migrate_anon_huge_fault':
hmm-tests.c:2355:27: error: 'MADV_COLLAPSE' undeclared (first use in this function); did you mean 'MADV_COLD'?

  2355 |  ret = madvise(map, size, MADV_COLLAPSE);
       |                           ^~~~~~~~~~~~~
       |                           MADV_COLD

hmm-tests.c:2355:27: note: each undeclared identifier is reported only once for each function it appears in
make: *** [../lib.mk:225: /root/code/linux/tools/testing/selftests/mm/hmm-tests] Error 1

Quoted 6 lines

Include linux/mman.h (which provides the definition of MADV_COLLAPSE) to fix the build error.

Fixes e3d8707358ea ("selftests/mm/hmm-tests: test pagemap reads of PMD device-private entries")

---

Quoted 15 lines
 tools/testing/selftests/mm/hmm-tests.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/mm/hmm-tests.c +1 -0
index e4c49699f3f7..2f2b9879d100 100644
@@ -23,6 +23,7 @@
 #include <time.h>
 #include <pthread.h>
 #include <limits.h>
+#include <linux/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>