mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Adding benchmark test that attaches to (almost) all allowed tracing functions and display attach/detach times. # ./test_progs -t tracing_multi_bench_attach -v bpf_testmod.ko is already unloaded. Loading bpf_testmod.ko... Successfully loaded bpf_testmod.ko. serial_test_tracing_multi_bench_attach:PASS:btf__load_vmlinux_btf 0 nsec serial_test_tracing_multi_bench_attach:PASS:tracing_multi_bench__open_and_load 0 nsec serial_test_tracing_multi_bench_attach:PASS:get_syms 0 nsec serial_test_tracing_multi_bench_attach:PASS:bpf_program__attach_tracing_multi 0 nsec serial_test_tracing_multi_bench_attach: found 51186 functions serial_test_tracing_multi_bench_attach: attached in 1.295s serial_test_tracing_multi_bench_attach: detached in 0.243s #507 tracing_multi_bench_attach:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Successfully unloaded bpf_testmod.ko. Exporting skip_entry as is_unsafe_function and using it in the test. Also updating trace_blacklist with ___migrate_enable to be in sync with kernel functions deny list. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20260606123955.345967-29-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
68 lines
1.8 KiB
C
68 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __TRACE_HELPER_H
|
|
#define __TRACE_HELPER_H
|
|
|
|
#include <bpf/libbpf.h>
|
|
|
|
#ifdef __x86_64__
|
|
#define SYS_PREFIX "__x64_"
|
|
#elif defined(__s390x__)
|
|
#define SYS_PREFIX "__s390x_"
|
|
#elif defined(__aarch64__)
|
|
#define SYS_PREFIX "__arm64_"
|
|
#elif defined(__riscv)
|
|
#define SYS_PREFIX "__riscv_"
|
|
#else
|
|
#define SYS_PREFIX ""
|
|
#endif
|
|
|
|
#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
|
|
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1)
|
|
|
|
struct ksym {
|
|
long addr;
|
|
char *name;
|
|
};
|
|
|
|
struct ksyms {
|
|
struct ksym *syms;
|
|
size_t sym_cap;
|
|
size_t sym_cnt;
|
|
char **filtered_syms;
|
|
size_t filtered_cnt;
|
|
};
|
|
|
|
typedef int (*ksym_cmp_t)(const void *p1, const void *p2);
|
|
typedef int (*ksym_search_cmp_t)(const void *p1, const struct ksym *p2);
|
|
|
|
int load_kallsyms(void);
|
|
struct ksym *ksym_search(long key);
|
|
long ksym_get_addr(const char *name);
|
|
|
|
struct ksyms *load_kallsyms_local(void);
|
|
struct ksym *ksym_search_local(struct ksyms *ksyms, long key);
|
|
long ksym_get_addr_local(struct ksyms *ksyms, const char *name);
|
|
void free_kallsyms_local(struct ksyms *ksyms);
|
|
|
|
struct ksyms *load_kallsyms_custom_local(ksym_cmp_t cmp_cb);
|
|
struct ksym *search_kallsyms_custom_local(struct ksyms *ksyms, const void *p1,
|
|
ksym_search_cmp_t cmp_cb);
|
|
|
|
/* open kallsyms and find addresses on the fly, faster than load + search. */
|
|
int kallsyms_find(const char *sym, unsigned long long *addr);
|
|
|
|
void read_trace_pipe(void);
|
|
int read_trace_pipe_iter(void (*cb)(const char *str, void *data),
|
|
void *data, int iter);
|
|
|
|
ssize_t get_uprobe_offset(const void *addr);
|
|
ssize_t get_rel_offset(uintptr_t addr);
|
|
|
|
int read_build_id(const char *path, char *build_id, size_t size);
|
|
|
|
int bpf_get_ksyms(struct ksyms **ksymsp, bool kernel);
|
|
int bpf_get_addrs(unsigned long **addrsp, size_t *cntp, bool kernel);
|
|
|
|
bool is_unsafe_function(const char *name);
|
|
#endif
|