]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: trace_helpers.c: Optimize kallsyms cache
authorRong Tao <rongtao@cestc.cn>
Thu, 7 Sep 2023 01:59:13 +0000 (09:59 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 8 Sep 2023 23:22:41 +0000 (16:22 -0700)
commitc698eaebdf4759d297343f20e00172610207b754
tree43bb2e1d8df10efdbaa16eff016329f22aa222d6
parent9bc869253d4de75fed388caaeb7626b3ee8ec56c
selftests/bpf: trace_helpers.c: Optimize kallsyms cache

Static ksyms often have problems because the number of symbols exceeds the
MAX_SYMS limit. Like changing the MAX_SYMS from 300000 to 400000 in
commit e76a014334a6("selftests/bpf: Bump and validate MAX_SYMS") solves
the problem somewhat, but it's not the perfect way.

This commit uses dynamic memory allocation, which completely solves the
problem caused by the limitation of the number of kallsyms. At the same
time, add APIs:

    load_kallsyms_local()
    ksym_search_local()
    ksym_get_addr_local()
    free_kallsyms_local()

There are used to solve the problem of selftests/bpf updating kallsyms
after attach new symbols during testmod testing.

Signed-off-by: Rong Tao <rongtao@cestc.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/tencent_C9BDA68F9221F21BE4081566A55D66A9700A@qq.com
samples/bpf/Makefile
tools/testing/selftests/bpf/prog_tests/fill_link_info.c
tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c
tools/testing/selftests/bpf/trace_helpers.c
tools/testing/selftests/bpf/trace_helpers.h