On Tue, Jan 24, 2023 at 03:36:22PM +0100, Jiri Olsa wrote: > Move all kfunc exports into separate header file and include it > in tests that need it. > > We will move all test kfuncs into bpf_testmod in following change, > so it's convenient to have declarations in single place. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > --- > .../bpf/bpf_testmod/bpf_testmod_kfunc.h | 89 +++++++++++++++++++ > tools/testing/selftests/bpf/progs/cb_refs.c | 1 + > .../selftests/bpf/progs/jit_probe_mem.c | 3 +- > .../bpf/progs/kfunc_call_destructive.c | 3 +- > .../selftests/bpf/progs/kfunc_call_fail.c | 9 +- > .../selftests/bpf/progs/kfunc_call_race.c | 3 +- > .../selftests/bpf/progs/kfunc_call_test.c | 15 +--- > .../bpf/progs/kfunc_call_test_subprog.c | 17 +++- > tools/testing/selftests/bpf/progs/map_kptr.c | 1 + > .../selftests/bpf/progs/map_kptr_fail.c | 1 + > 10 files changed, 111 insertions(+), 31 deletions(-) > create mode 100644 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h > > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h > new file mode 100644 > index 000000000000..41d4f8543a25 > --- /dev/null > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h > @@ -0,0 +1,89 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef _BPF_TESTMOD_KFUNC_H > +#define _BPF_TESTMOD_KFUNC_H > + > +#ifndef __ksym > +#define __ksym __attribute__((section(".ksyms"))) > +#endif ... > +extern void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb) __ksym; > +extern void bpf_kfunc_call_test_pass1(struct prog_test_pass1 *p) __ksym; > +extern void bpf_kfunc_call_test_pass2(struct prog_test_pass2 *p) __ksym; > +extern void bpf_kfunc_call_test_mem_len_fail2(__u64 *mem, int len) __ksym; > + > +extern void bpf_kfunc_call_test_destructive(void) __ksym; > + > +#endif /* _BPF_TESTMOD_KFUNC_H */ This is missing bpf_kfunc_call_test_kptr_get() prototype, the function is moved with the rest in the 5th patch. > diff --git a/tools/testing/selftests/bpf/progs/cb_refs.c b/tools/testing/selftests/bpf/progs/cb_refs.c > index 7653df1bc787..b905833dc9d3 100644 > --- a/tools/testing/selftests/bpf/progs/cb_refs.c > +++ b/tools/testing/selftests/bpf/progs/cb_refs.c > @@ -2,6 +2,7 @@ > #include <vmlinux.h> > #include <bpf/bpf_tracing.h> > #include <bpf/bpf_helpers.h> > +#include "bpf_testmod/bpf_testmod_kfunc.h" > > struct map_value { > struct prog_test_ref_kfunc __kptr_ref *ptr; > diff --git a/tools/testing/selftests/bpf/progs/map_kptr.c b/tools/testing/selftests/bpf/progs/map_kptr.c > index eb8217803493..753305c22c2f 100644 > --- a/tools/testing/selftests/bpf/progs/map_kptr.c > +++ b/tools/testing/selftests/bpf/progs/map_kptr.c > @@ -2,6 +2,7 @@ > #include <vmlinux.h> > #include <bpf/bpf_tracing.h> > #include <bpf/bpf_helpers.h> > +#include "bpf_testmod/bpf_testmod_kfunc.h" > > struct map_value { > struct prog_test_ref_kfunc __kptr *unref_ptr; > diff --git a/tools/testing/selftests/bpf/progs/map_kptr_fail.c b/tools/testing/selftests/bpf/progs/map_kptr_fail.c > index 760e41e1a632..3b5076d951df 100644 > --- a/tools/testing/selftests/bpf/progs/map_kptr_fail.c > +++ b/tools/testing/selftests/bpf/progs/map_kptr_fail.c > @@ -4,6 +4,7 @@ > #include <bpf/bpf_helpers.h> > #include <bpf/bpf_core_read.h> > #include "bpf_misc.h" > +#include "bpf_testmod/bpf_testmod_kfunc.h" > > struct map_value { > char buf[8]; These three are missing old prototype removal. -- Artem