The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] perf evsel: Improve frame pointer unwinding warning for s390
@ 2026-08-07 10:49 Jens Remus
  2026-08-08  4:13 ` Ian Rogers
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Remus @ 2026-08-07 10:49 UTC (permalink / raw)
  To: Thomas Richter, Jan Polensky, Ian Rogers,
	Arnaldo Carvalho de Melo, Namhyung Kim
  Cc: Jens Remus, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Ilya Leoshkevich, linux-kernel, linux-perf-users, linux-s390

On s390 the kernel uses s390 back chain instead of frame pointers for
stack tracing of user space since v6.7 commit aa44433ac4ee ("s390: add
USER_STACKTRACE support").  This is because frame pointers on s390
cannot be used for stack tracing. [1]

This requires user space to maintain a s390 back chain.  For instance
user space to be built with compiler option '-mbackchain' (instead of
'-fno-omit-frame-pointer' used on other architectures, which should
better not be used on s390 [1]).

Only few distributions and users built user space with '-mbackchain'.
Therefore '--call-graph fp' may not produce the expected results.

Commit ca76fb67ebdd ("perf evlist: Improve default event for s390")
added a warning for s390 that wrongly claimed that "Framepointer
unwinding lacks kernel support".  Change the warning to hint at using
'--call-graph dwarf' if user space does not maintain a s390 back chain.

Note that '--call-graph fp' may also be useful for other applications,
such as OpenJDK maintaining a s390 back chain (does not require JVM
option '-XX:+PreserveFramePointer' on s390):

  $ perf record --call-graph fp ... -- \
    java -XX:+UnlockDiagnosticVMOptions -XX:+DumpPerfMapAtExit ...

[1]: s390: Stack tracing using Frame Pointer, Back Chain, and SFrame,
     https://conf.gnu-tools-cauldron.org/opo25/talk/Y3CVHY/

Fixes: ca76fb67ebdd ("perf evlist: Improve default event for s390")
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 tools/perf/util/evsel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ea9fa04429f0..c4d67d1b35f3 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1080,7 +1080,8 @@ static void __evsel__config_callchain(struct evsel *evsel, const struct record_o
 
 	if (EM_HOST == EM_S390 && param->record_mode == CALLCHAIN_FP) {
 		pr_warning_once(
-			"Framepointer unwinding lacks kernel support. Use '--call-graph dwarf'\n");
+			"Use '--call-graph dwarf' if user space does not maintain a s390 back chain "
+			"(e.g. is not built with '-mbackchain').\n");
 	}
 
 	evsel__set_sample_bit(evsel, CALLCHAIN);

base-commit: f9a2394a23482bfd330911e9c8295b71724feacd
-- 
2.53.0


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

* Re: [PATCH] perf evsel: Improve frame pointer unwinding warning for s390
  2026-08-07 10:49 [PATCH] perf evsel: Improve frame pointer unwinding warning for s390 Jens Remus
@ 2026-08-08  4:13 ` Ian Rogers
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2026-08-08  4:13 UTC (permalink / raw)
  To: Jens Remus, Thomas Richter, Jan Polensky
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, Ilya Leoshkevich, linux-kernel,
	linux-perf-users, linux-s390

On Fri, Aug 7, 2026 at 3:49 AM Jens Remus <jremus@linux.ibm.com> wrote:
>
> On s390 the kernel uses s390 back chain instead of frame pointers for
> stack tracing of user space since v6.7 commit aa44433ac4ee ("s390: add
> USER_STACKTRACE support").  This is because frame pointers on s390
> cannot be used for stack tracing. [1]
>
> This requires user space to maintain a s390 back chain.  For instance
> user space to be built with compiler option '-mbackchain' (instead of
> '-fno-omit-frame-pointer' used on other architectures, which should
> better not be used on s390 [1]).
>
> Only few distributions and users built user space with '-mbackchain'.
> Therefore '--call-graph fp' may not produce the expected results.
>
> Commit ca76fb67ebdd ("perf evlist: Improve default event for s390")
> added a warning for s390 that wrongly claimed that "Framepointer
> unwinding lacks kernel support".  Change the warning to hint at using
> '--call-graph dwarf' if user space does not maintain a s390 back chain.
>
> Note that '--call-graph fp' may also be useful for other applications,
> such as OpenJDK maintaining a s390 back chain (does not require JVM
> option '-XX:+PreserveFramePointer' on s390):
>
>   $ perf record --call-graph fp ... -- \
>     java -XX:+UnlockDiagnosticVMOptions -XX:+DumpPerfMapAtExit ...
>
> [1]: s390: Stack tracing using Frame Pointer, Back Chain, and SFrame,
>      https://conf.gnu-tools-cauldron.org/opo25/talk/Y3CVHY/
>
> Fixes: ca76fb67ebdd ("perf evlist: Improve default event for s390")
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
> ---
>  tools/perf/util/evsel.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index ea9fa04429f0..c4d67d1b35f3 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1080,7 +1080,8 @@ static void __evsel__config_callchain(struct evsel *evsel, const struct record_o
>
>         if (EM_HOST == EM_S390 && param->record_mode == CALLCHAIN_FP) {
>                 pr_warning_once(
> -                       "Framepointer unwinding lacks kernel support. Use '--call-graph dwarf'\n");
> +                       "Use '--call-graph dwarf' if user space does not maintain a s390 back chain "
> +                       "(e.g. is not built with '-mbackchain').\n");

Thanks Jens. The text was based on:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/s390/kernel/perf_cpum_sf.c#n853
```
static int cpumsf_pmu_event_init(struct perf_event *event)
...
 /* No support for callchain, stacks and registers */
if (has_branch_stack(event) || is_callchain_event(event))
return -EOPNOTSUPP;
```
The backchain option is never tested by perf or apparently in the
kernel, but this warning is supposed to pre-warn about "not supported"
being returned when frame pointer unwinding is requested. Of course,
lacking an s390 I've never tested this. I can imagine the warning
being overly broad, but my understanding is cpum_sf is the only PMU
capable of sampling on s390.

Perhaps what is needed is additional text after the "Use '--call-graph
dwarf'". The existing initial text at least appears to match the
kernel code. I'm not clear how the lack of back chains would be
reported as an error code, and this could introduce confusion as we
have lots of stack, chain and branch related terms in the perf
codebase.

Thanks,
Ian

>         }
>
>         evsel__set_sample_bit(evsel, CALLCHAIN);
>
> base-commit: f9a2394a23482bfd330911e9c8295b71724feacd
> --
> 2.53.0
>

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

end of thread, other threads:[~2026-08-08  4:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 10:49 [PATCH] perf evsel: Improve frame pointer unwinding warning for s390 Jens Remus
2026-08-08  4:13 ` Ian Rogers

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