Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	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,
	Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH bpf-next v3 1/3] arm64: perf: Don't report the caller twice in caller-regs callchains
Date: Thu, 3 Dec 2026 14:13:43 +0000	[thread overview]
Message-ID: <20261203141343.GA3019743@e132581.arm.com> (raw)
In-Reply-To: <20261201230247.73877-2-andrii@kernel.org>

On Tue, Dec 01, 2026 at 03:02:45PM -0800, Andrii Nakryiko wrote:
> perf_arch_fetch_caller_regs() sets regs->pc to the return address of
> the function it is used in (CALLER_ADDR0) and points regs->regs[29] at
> that function's own frame record, whose saved LR is that same return
> address.

> Mark these regs on arm64 by setting pstate to PSR_MODE_EL1t, which
> exceptions taken from the kernel never have (the kernel runs in EL1h,
> or EL2h with VHE). For regs with that mode, kunwind_stack_walk() steps
> to the frame record at x29 before reporting anything, so the unwind
> starts from the LR saved there and regs->pc is not reported.

I tested this patch and confirmed it fixes the issue.

...

> +/* PSR_MODE_EL1t marks these regs for kunwind_stack_walk() */
>  #define perf_arch_fetch_caller_regs(regs, __ip) { \
>  	(regs)->pc = (__ip);    \
>  	(regs)->regs[29] = (unsigned long) __builtin_frame_address(0); \
>  	(regs)->sp = current_stack_pointer; \
> -	(regs)->pstate = PSR_MODE_EL1h;	\
> +	(regs)->pstate = PSR_MODE_EL1t;	\
>  }

It seems to me that the issue comes from a mismatch between the IP and
the frame pointer. Could we update the interface to pass them as a pair?

  perf_arch_fetch_caller_regs(regs, caller_ip, caller_fp)

I've read Will's comment on v1, so I'll wait to hear which approach he
prefers. If go with this version, please feel free to add my test tag:

Tested-by: Leo Yan <leo.yan@arm.com>

Thanks,
Leo


  reply	other threads:[~2026-12-03 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:02 [PATCH bpf-next v3 0/3] Fix duplicate caller frame in arm64 stack traces Andrii Nakryiko
2026-12-01 23:02 ` [PATCH bpf-next v3 1/3] arm64: perf: Don't report the caller twice in caller-regs callchains Andrii Nakryiko
2026-12-03 14:13   ` Leo Yan [this message]
2026-12-01 23:02 ` [PATCH bpf-next v3 2/3] selftests/bpf: Add stacktrace_ips test for tracepoint Andrii Nakryiko
2026-12-01 23:02 ` [PATCH bpf-next v3 3/3] selftests/bpf: Run stacktrace_ips raw_tp, tp and fentry tests on arm64 Andrii Nakryiko

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=20261203141343.GA3019743@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=andrii@kernel.org \
    --cc=ast@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox