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

selftests/bpf: Remove hard coded PAGE_SIZE macro.

Remove hard coded PAGE_SIZE.
Add #include <sys/user.h> instead (that works on x86-64 and s390)
and fallback to slow getpagesize() for aarch64.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20240315021834.62988-4-alexei.starovoitov@gmail.com

authored by

Alexei Starovoitov and committed by
Andrii Nakryiko
9a2d5a96 10ebe835

+10 -5
+5 -3
tools/testing/selftests/bpf/prog_tests/arena_htab.c
··· 3 3 #include <test_progs.h> 4 4 #include <sys/mman.h> 5 5 #include <network_helpers.h> 6 - 6 + #include <sys/user.h> 7 + #ifndef PAGE_SIZE /* on some archs it comes in sys/user.h */ 8 + #include <unistd.h> 9 + #define PAGE_SIZE getpagesize() 10 + #endif 7 11 #include "arena_htab_asm.skel.h" 8 12 #include "arena_htab.skel.h" 9 - 10 - #define PAGE_SIZE 4096 11 13 12 14 #include "bpf_arena_htab.h" 13 15
+5 -2
tools/testing/selftests/bpf/prog_tests/arena_list.c
··· 3 3 #include <test_progs.h> 4 4 #include <sys/mman.h> 5 5 #include <network_helpers.h> 6 - 7 - #define PAGE_SIZE 4096 6 + #include <sys/user.h> 7 + #ifndef PAGE_SIZE /* on some archs it comes in sys/user.h */ 8 + #include <unistd.h> 9 + #define PAGE_SIZE getpagesize() 10 + #endif 8 11 9 12 #include "bpf_arena_list.h" 10 13 #include "arena_list.skel.h"