From: Andrii Nakryiko <andrii@kernel.org>
To: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com,
linux-perf-users@vger.kernel.org, peterz@infradead.org,
jolsa@kernel.org, rostedt@goodmis.org,
Andrii Nakryiko <andrii@kernel.org>
Subject: [PATCH bpf-next v2 3/3] selftests/bpf: Run stacktrace_ips raw_tp, tp and fentry tests on arm64
Date: Wed, 18 Nov 2026 16:01:12 -0800 [thread overview]
Message-ID: <20261119000112.2377949-4-andrii@kernel.org> (raw)
In-Reply-To: <20261119000112.2377949-1-andrii@kernel.org>
The raw_tp, tp and fentry subtests check stacks unwound from
perf_fetch_caller_regs() regs. Now that arm64 perf_callchain_kernel()
skips regs->pc of such regs and no longer reports the caller twice,
run these subtests on arm64 as well, where kernel stacks are always
unwound through frame records.
Leave the kprobe, kretprobe, kprobe_multi, kretprobe_multi and fexit
subtests x86-only: on arm64, kprobes at function entry miss the probed
function's caller, and fexit stacks have an extra entry for the traced
function. The kretprobe subtests pass on arm64, but don't use
perf_fetch_caller_regs() regs.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
.../selftests/bpf/prog_tests/stacktrace_ips.c | 15 +++++++++++----
.../testing/selftests/bpf/progs/stacktrace_ips.c | 5 +++--
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c
index a03d4c10c469..aee46543f390 100644
--- a/tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c
+++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_ips.c
@@ -2,7 +2,7 @@
#include <test_progs.h>
#include "stacktrace_ips.skel.h"
-#ifdef __x86_64__
+#if defined(__x86_64__) || defined(__aarch64__)
static int check_stacktrace_ips(int fd, __u32 key, int cnt, ...)
{
__u64 ips[PERF_MAX_STACK_DEPTH];
@@ -47,6 +47,12 @@ static int check_stacktrace_ips(int fd, __u32 key, int cnt, ...)
return err;
}
+/* arm64 always unwinds kernel stacks through frame records */
+static bool unwinder_ok(struct stacktrace_ips *skel)
+{
+ return skel->kconfig->CONFIG_UNWINDER_ORC || skel->kconfig->CONFIG_ARM64;
+}
+
static void test_stacktrace_ips_kprobe_multi(bool retprobe)
{
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts,
@@ -106,7 +112,7 @@ static void test_stacktrace_ips_raw_tp(void)
if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load"))
return;
- if (!skel->kconfig->CONFIG_UNWINDER_ORC) {
+ if (!unwinder_ok(skel)) {
test__skip();
goto cleanup;
}
@@ -149,7 +155,7 @@ static void test_stacktrace_ips_tp(void)
if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load"))
return;
- if (!skel->kconfig->CONFIG_UNWINDER_ORC) {
+ if (!unwinder_ok(skel)) {
test__skip();
goto cleanup;
}
@@ -244,7 +250,8 @@ static void test_stacktrace_ips_trampoline(bool retprobe)
if (!ASSERT_OK_PTR(skel, "stacktrace_ips__open_and_load"))
return;
- if (!skel->kconfig->CONFIG_UNWINDER_ORC) {
+ /* on arm64, fexit stacks also have a frame for the traced function */
+ if ((retprobe && !skel->kconfig->CONFIG_UNWINDER_ORC) || !unwinder_ok(skel)) {
test__skip();
goto cleanup;
}
diff --git a/tools/testing/selftests/bpf/progs/stacktrace_ips.c b/tools/testing/selftests/bpf/progs/stacktrace_ips.c
index df10ef3cb14d..11dfebd4ddb2 100644
--- a/tools/testing/selftests/bpf/progs/stacktrace_ips.c
+++ b/tools/testing/selftests/bpf/progs/stacktrace_ips.c
@@ -19,14 +19,15 @@ struct {
} stackmap SEC(".maps");
extern bool CONFIG_UNWINDER_ORC __kconfig __weak;
+extern bool CONFIG_ARM64 __kconfig __weak;
/*
- * This function is here to have CONFIG_UNWINDER_ORC
+ * This function is here to have CONFIG_UNWINDER_ORC and CONFIG_ARM64
* used and added to object BTF.
*/
int unused(void)
{
- return CONFIG_UNWINDER_ORC ? 0 : 1;
+ return CONFIG_UNWINDER_ORC || CONFIG_ARM64 ? 0 : 1;
}
__u32 stack_key;
--
2.53.1-Meta
next prev parent reply other threads:[~2026-11-19 0:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 0:01 [PATCH bpf-next v2 0/3] Fix duplicate caller frame in arm64 stack traces Andrii Nakryiko
2026-11-19 0:01 ` [PATCH bpf-next v2 1/3] arm64: perf: Don't report the caller twice in caller-regs callchains Andrii Nakryiko
2026-11-19 0:22 ` sashiko-bot
2026-11-19 1:38 ` Alexei Starovoitov
2026-11-19 4:45 ` Andrii Nakryiko
2026-11-19 0:01 ` [PATCH bpf-next v2 2/3] selftests/bpf: Add stacktrace_ips test for tracepoint Andrii Nakryiko
2026-11-19 0:07 ` sashiko-bot
2026-11-19 0:01 ` Andrii Nakryiko [this message]
2026-11-19 0:05 ` [PATCH bpf-next v2 3/3] selftests/bpf: Run stacktrace_ips raw_tp, tp and fentry tests on arm64 sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119000112.2377949-4-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.