Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/vm: make MADV_POPULATE_(READ|WRITE) use in-tree headers

The madv_populate selftest currently builds with a warning when the
local installed headers (via the distribution) don't include
MADV_POPULATE_READ and MADV_POPULATE_WRITE. The warning is correct,
because the test cannot locate the necessary header.

The reason is that the in-tree installed headers (usr/include) have a
"linux" instead of a "sys" subdirectory.

Including "linux/mman.h" instead of "sys/mman.h" doesn't work (e.g.,
mmap() and madvise() are not defined that way). The only thing that
seems to work is including "linux/mman.h" in addition to "sys/mman.h".

We can get rid of our availability check and simplify.

Link: https://lkml.kernel.org/r/20211015165758.41374-1-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reported-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Hildenbrand and committed by
Linus Torvalds
39b2e5ca a9970586

+1 -14
+1 -14
tools/testing/selftests/vm/madv_populate.c
··· 14 14 #include <unistd.h> 15 15 #include <errno.h> 16 16 #include <fcntl.h> 17 + #include <linux/mman.h> 17 18 #include <sys/mman.h> 18 19 19 20 #include "../kselftest.h" 20 - 21 - #if defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) 22 21 23 22 /* 24 23 * For now, we're using 2 MiB of private anonymous memory for all tests. ··· 327 328 err, ksft_test_num()); 328 329 return ksft_exit_pass(); 329 330 } 330 - 331 - #else /* defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) */ 332 - 333 - #warning "missing MADV_POPULATE_READ or MADV_POPULATE_WRITE definition" 334 - 335 - int main(int argc, char **argv) 336 - { 337 - ksft_print_header(); 338 - ksft_exit_skip("MADV_POPULATE_READ or MADV_POPULATE_WRITE not defined\n"); 339 - } 340 - 341 - #endif /* defined(MADV_POPULATE_READ) && defined(MADV_POPULATE_WRITE) */