aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/bpf_testmod
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2021-01-11 23:55:20 -0800
committerAlexei Starovoitov <ast@kernel.org>2021-01-12 17:24:30 -0800
commit430d97a8a7bf1500c081ce756ff2ead73d2303c5 (patch)
tree348ac2808f0006934b49aa2f472b7d069af710ba /tools/testing/selftests/bpf/bpf_testmod
parentlibbpf: Support kernel module ksym externs (diff)
downloadlinux-dev-430d97a8a7bf1500c081ce756ff2ead73d2303c5.tar.xz
linux-dev-430d97a8a7bf1500c081ce756ff2ead73d2303c5.zip
selftests/bpf: Test kernel module ksym externs
Add per-CPU variable to bpf_testmod.ko and use those from new selftest to validate it works end-to-end. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Acked-by: Hao Luo <haoluo@google.com> Link: https://lore.kernel.org/bpf/20210112075520.4103414-8-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_testmod')
-rw-r--r--tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index 2df19d73ca49..0b991e115d1f 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -3,6 +3,7 @@
#include <linux/error-injection.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/percpu-defs.h>
#include <linux/sysfs.h>
#include <linux/tracepoint.h>
#include "bpf_testmod.h"
@@ -10,6 +11,8 @@
#define CREATE_TRACE_POINTS
#include "bpf_testmod-events.h"
+DEFINE_PER_CPU(int, bpf_testmod_ksym_percpu) = 123;
+
noinline ssize_t
bpf_testmod_test_read(struct file *file, struct kobject *kobj,
struct bin_attribute *bin_attr,