]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests/bpf: Remove hard coded PAGE_SIZE macro.
authorAlexei Starovoitov <ast@kernel.org>
Fri, 15 Mar 2024 02:18:33 +0000 (19:18 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 15 Mar 2024 21:24:03 +0000 (14:24 -0700)
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
tools/testing/selftests/bpf/prog_tests/arena_htab.c
tools/testing/selftests/bpf/prog_tests/arena_list.c

index 0766702de84657460995af4b791374c941d5e285..d69fd2465f5367fc2471694f5938a7ab2cf03c47 100644 (file)
@@ -3,12 +3,14 @@
 #include <test_progs.h>
 #include <sys/mman.h>
 #include <network_helpers.h>
-
+#include <sys/user.h>
+#ifndef PAGE_SIZE /* on some archs it comes in sys/user.h */
+#include <unistd.h>
+#define PAGE_SIZE getpagesize()
+#endif
 #include "arena_htab_asm.skel.h"
 #include "arena_htab.skel.h"
 
-#define PAGE_SIZE 4096
-
 #include "bpf_arena_htab.h"
 
 static void test_arena_htab_common(struct htab *htab)
index e61886debab12727a594a0c3f54163bba35e3bea..d15867cddde06ab5c49bfdca8df1c1f69d0931d9 100644 (file)
@@ -3,8 +3,11 @@
 #include <test_progs.h>
 #include <sys/mman.h>
 #include <network_helpers.h>
-
-#define PAGE_SIZE 4096
+#include <sys/user.h>
+#ifndef PAGE_SIZE /* on some archs it comes in sys/user.h */
+#include <unistd.h>
+#define PAGE_SIZE getpagesize()
+#endif
 
 #include "bpf_arena_list.h"
 #include "arena_list.skel.h"