hi, I noticed several times in discussions that we should move test kfuncs into kernel module, now perhaps even more pressing with all the kfunc effort. This patchset moves all the test kfuncs into bpf_testmod. I added bpf_testmod/bpf_testmod_kfunc.h header that is shared between bpf_testmod kernel module and BPF programs, which brings some difficulties with __ksym define. But I'm not sure having separate headers for BPF programs and for kernel module would be better. This patchset also needs: 74bc3a5acc82 bpf: Add missing btf_put to register_btf_id_dtor_kfuncs which is only in bpf/master now. v3 changes: - added acks [David] - added bpf_testmod.ko make dependency for bpf test progs [David] - better handling of __ksym and refcount_t in bpf_testmod_kfunc.h [David] - removed 'extern' from kfuncs declarations [David] - typo in header guard macro [David] - use only stdout in un/load_bpf_testmod v2 changes: - add 74bc3a5acc82 into bpf-next/master CI, so the test would pass https://github.com/kernel-patches/vmtest/pull/192 - remove extra externs [Artem] - using un/load_bpf_testmod in other tests - rebased thanks, jirka --- Jiri Olsa (9): selftests/bpf: Move kfunc exports to bpf_testmod/bpf_testmod_kfunc.h selftests/bpf: Move test_progs helpers to testing_helpers object selftests/bpf: Use only stdout in un/load_bpf_testmod functions selftests/bpf: Do not unload bpf_testmod in load_bpf_testmod selftests/bpf: Use un/load_bpf_testmod functions in tests selftests/bpf: Load bpf_testmod for verifier test selftests/bpf: Allow to use kfunc from testmod.ko in test_verifier selftests/bpf: Remove extern from kfuncs declarations bpf: Move kernel test kfuncs to bpf_testmod net/bpf/test_run.c | 271 +------------------------------------------------------------------------------------------ tools/testing/selftests/bpf/Makefile | 1 + tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h | 102 ++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c | 34 ++---------- tools/testing/selftests/bpf/prog_tests/module_attach.c | 12 ++-- tools/testing/selftests/bpf/progs/cb_refs.c | 4 +- tools/testing/selftests/bpf/progs/jit_probe_mem.c | 4 +- tools/testing/selftests/bpf/progs/kfunc_call_destructive.c | 3 +- tools/testing/selftests/bpf/progs/kfunc_call_fail.c | 9 +-- tools/testing/selftests/bpf/progs/kfunc_call_race.c | 3 +- tools/testing/selftests/bpf/progs/kfunc_call_test.c | 17 +----- tools/testing/selftests/bpf/progs/kfunc_call_test_subprog.c | 9 +-- tools/testing/selftests/bpf/progs/map_kptr.c | 6 +- tools/testing/selftests/bpf/progs/map_kptr_fail.c | 5 +- tools/testing/selftests/bpf/test_progs.c | 76 +++----------------------- tools/testing/selftests/bpf/test_progs.h | 1 - tools/testing/selftests/bpf/test_verifier.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++-------- tools/testing/selftests/bpf/testing_helpers.c | 61 +++++++++++++++++++++ tools/testing/selftests/bpf/testing_helpers.h | 10 ++++ 20 files changed, 556 insertions(+), 448 deletions(-) create mode 100644 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod_kfunc.h