public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] Failed to obtain stack trace via bpf_get_stackid on ARM64 architecture
@ 2025-09-19  7:19 Feng Yang
  2025-09-20  2:56 ` Alexei Starovoitov
  0 siblings, 1 reply; 13+ messages in thread
From: Feng Yang @ 2025-09-19  7:19 UTC (permalink / raw)
  To: ast, daniel, john.fastabend, andrii, martin.lau, eddyz87, song,
	yonghong.song, kpsingh, sdf, haoluo, jolsa
  Cc: bpf, linux-kernel, linux-trace-kernel, mhiramat

When I use bpf_program__attach_kprobe_multi_opts to hook a BPF program that contains the bpf_get_stackid function on the arm64 architecture,
I find that the stack trace cannot be obtained. The trace->nr in __bpf_get_stackid is 0, and the function returns -EFAULT.

For example:
diff --git a/tools/testing/selftests/bpf/progs/kprobe_multi.c b/tools/testing/selftests/bpf/progs/kprobe_multi.c
index 9e1ca8e34913..844fa88cdc4c 100644
--- a/tools/testing/selftests/bpf/progs/kprobe_multi.c
+++ b/tools/testing/selftests/bpf/progs/kprobe_multi.c
@@ -36,6 +36,15 @@ __u64 kretprobe_test6_result = 0;
 __u64 kretprobe_test7_result = 0;
 __u64 kretprobe_test8_result = 0;
 
+typedef __u64 stack_trace_t[2];
+
+struct {
+       __uint(type, BPF_MAP_TYPE_STACK_TRACE);
+       __uint(max_entries, 1024);
+       __type(key, __u32);
+       __type(value, stack_trace_t);
+} stacks SEC(".maps");
+
 static void kprobe_multi_check(void *ctx, bool is_return)
 {
        if (bpf_get_current_pid_tgid() >> 32 != pid)
@@ -100,7 +109,9 @@ int test_kretprobe(struct pt_regs *ctx)
 SEC("kprobe.multi")
 int test_kprobe_manual(struct pt_regs *ctx)
 {
+       int id = bpf_get_stackid(ctx, &stacks, 0);
        kprobe_multi_check(ctx, false);
+       bpf_printk("stackid: %d\n", id);
        return 0;
 }

./test_progs -t kprobe_multi_test/attach_api_pattern
#155/4   kprobe_multi_test/attach_api_pattern:OK
#155     kprobe_multi_test:OK
#156     kprobe_multi_testmod_test:OK
Summary: 2/1 PASSED, 0 SKIPPED, 0 FAILED

cat /sys/kernel/debug/tracing/trace
test_progs-68315   [004] ...1. 13377.097527: bpf_trace_printk: stackid: -14
......

Test Version:
6ff4a0fa3e1 ("bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()")
Linux localhost.localdomain 6.17.0-rc5+ #2 SMP PREEMPT_DYNAMIC Fri Sep 19 10:29:07 CST 2025 aarch64 aarch64 aarch64 GNU/Linux
clang version 17.0.6 ( 17.0.6-30.p03.ky11)
gcc (GCC) 12.3.1 (kylin 12.3.1-62.p02.ky11)
GNU Make 4.4.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-09-24 22:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-19  7:19 [BUG] Failed to obtain stack trace via bpf_get_stackid on ARM64 architecture Feng Yang
2025-09-20  2:56 ` Alexei Starovoitov
2025-09-20 22:17   ` Jiri Olsa
2025-09-21 13:30   ` Masami Hiramatsu
2025-09-22  2:15     ` Feng Yang
2025-09-23 15:32       ` Masami Hiramatsu
2025-09-24  6:25         ` Feng Yang
2025-09-24  7:31           ` Masami Hiramatsu
2025-09-24  8:04           ` Masami Hiramatsu
2025-09-24 10:53             ` Feng Yang
2025-09-24 22:00               ` Masami Hiramatsu
2025-09-24 15:42           ` Jiri Olsa
2025-09-24 21:56             ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox