selftests/bpf: Add stacktrace ips test for raw_tp

Adding test that verifies we get expected initial 2 entries from
stacktrace for rawtp probe via ORC unwind.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20251104215405.168643-5-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Jiri Olsa 2025-11-04 22:54:05 +01:00 committed by Alexei Starovoitov
parent c9e208fa93
commit 3490d29964
2 changed files with 54 additions and 0 deletions

View File

@ -84,12 +84,58 @@ static void test_stacktrace_ips_kprobe_multi(bool retprobe)
stacktrace_ips__destroy(skel);
}
static void test_stacktrace_ips_raw_tp(void)
{
__u32 info_len = sizeof(struct bpf_prog_info);
LIBBPF_OPTS(bpf_test_run_opts, topts);
struct bpf_prog_info info = {};
struct stacktrace_ips *skel;
__u64 bpf_prog_ksym = 0;
int err;
skel = stacktrace_ips__open_and_load();
if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load"))
return;
if (!skel->kconfig->CONFIG_UNWINDER_ORC) {
test__skip();
goto cleanup;
}
skel->links.rawtp_test = bpf_program__attach_raw_tracepoint(
skel->progs.rawtp_test,
"bpf_testmod_test_read");
if (!ASSERT_OK_PTR(skel->links.rawtp_test, "bpf_program__attach_raw_tracepoint"))
goto cleanup;
/* get bpf program address */
info.jited_ksyms = ptr_to_u64(&bpf_prog_ksym);
info.nr_jited_ksyms = 1;
err = bpf_prog_get_info_by_fd(bpf_program__fd(skel->progs.rawtp_test),
&info, &info_len);
if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd"))
goto cleanup;
trigger_module_test_read(1);
load_kallsyms();
check_stacktrace_ips(bpf_map__fd(skel->maps.stackmap), skel->bss->stack_key, 2,
bpf_prog_ksym,
ksym_get_addr("bpf_trace_run2"));
cleanup:
stacktrace_ips__destroy(skel);
}
static void __test_stacktrace_ips(void)
{
if (test__start_subtest("kprobe_multi"))
test_stacktrace_ips_kprobe_multi(false);
if (test__start_subtest("kretprobe_multi"))
test_stacktrace_ips_kprobe_multi(true);
if (test__start_subtest("raw_tp"))
test_stacktrace_ips_raw_tp();
}
#else
static void __test_stacktrace_ips(void)

View File

@ -38,4 +38,12 @@ int kprobe_multi_test(struct pt_regs *ctx)
return 0;
}
SEC("raw_tp/bpf_testmod_test_read")
int rawtp_test(void *ctx)
{
/* Skip ebpf program entry in the stack. */
stack_key = bpf_get_stackid(ctx, &stackmap, 0);
return 0;
}
char _license[] SEC("license") = "GPL";