Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH 0/5] perf python: Honor more perf script options
@ 2026-12-04 16:24 Jens Remus
  2026-12-04 16:24 ` [PATCH 1/5] perf python: Support inlined frames in callchains Jens Remus
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jens Remus @ 2026-12-04 16:24 UTC (permalink / raw)
  To: Ian Rogers, Arnaldo Carvalho de Melo, Namhyung Kim,
	Peter Zijlstra, Ingo Molnar
  Cc: Jens Remus, Jan Polensky, Sumanth Korikkar, Heiko Carstens,
	Vasily Gorbik, Alexander Gordeev, linux-perf-users, linux-kernel

While updating my own perf scripts for commit b02aa1d1343f ("perf
script: Support standalone scripts and remove embedded scripting") I
noticed that perf script accepts but ignores most of its options when
running a Python script:

  $ perf script [<options>] -s ~/my_script.py

Only --vmlinux, --kallsyms, --symfs and --itrace are forwarded to the
script's perf.session, via environment variables.  perf.session itself
hard-codes the other symbol settings, and two of them differ from the
perf script defaults: it does not resolve inlined frames, and it reports
the kernel DSO by its vmlinux path.  So a script cannot reproduce the
output of plain perf script.  Neither the command line nor the script
itself can change these settings, because perf.session has no arguments
for them.  I use some of these options, so this series forwards
--inline, --show-kernel-path, --max-stack, --demangle and
--demangle-kernel.

For each option, perf.session gains a keyword argument, so a script can
set it itself.  If it is not given, perf.session uses an environment
variable set by perf script from the option, and otherwise the previous
hard-coded value.  Scripts run directly only gain the keyword arguments,
their defaults do not change.

Behavior change: Python scripts run by perf script now resolve inlined
frames and report the kernel DSO as "[kernel.kallsyms]", like perf script
does.  Use --no-inline and --show-kernel-path to get the old behavior.

Patch 1 also adds callchain_node.inlined, so scripts can tell inlined
frames from the frame they are inlined into.  Patch 2 exports this flag
in the SQLite and PostgreSQL export scripts, which adds a column to the
symbols table.

Note: On s390 test_export_to_sqlite_python.sh fails, independent of this
series, because "perf record -g" defaults to --call-graph dwarf there.
The resulting samples exceed sizeof(union perf_event), which commit
2c672ffdad4b ("perf python: Lazily copy events and samples from
process_events") rejects with "Unexpected event size: 4168 < 8536".

Based on v7.4-rc4.

Regards,
Jens

Jens Remus (5):
  perf python: Support inlined frames in callchains
  perf python: Export inlined symbol flag in DB export scripts
  perf python: Honor perf script --show-kernel-path
  perf python: Honor perf script --demangle and --demangle-kernel
  perf python: Honor perf script --max-stack

 .../perf/Documentation/perf-script-python.txt |  11 +-
 tools/perf/builtin-script.c                   |   9 ++
 tools/perf/python/export-to-postgresql.py     |  32 ++---
 tools/perf/python/export-to-sqlite.py         |  18 +--
 tools/perf/python/perf.pyi                    |  24 +++-
 tools/perf/util/python.c                      | 119 +++++++++++++++++-
 6 files changed, 180 insertions(+), 33 deletions(-)


base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
-- 
2.53.0


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

end of thread, other threads:[~2026-12-04 17:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 16:24 [PATCH 0/5] perf python: Honor more perf script options Jens Remus
2026-12-04 16:24 ` [PATCH 1/5] perf python: Support inlined frames in callchains Jens Remus
2026-12-04 16:46   ` sashiko-bot
2026-12-04 16:24 ` [PATCH 2/5] perf python: Export inlined symbol flag in DB export scripts Jens Remus
2026-12-04 16:59   ` sashiko-bot
2026-12-04 16:24 ` [PATCH 3/5] perf python: Honor perf script --show-kernel-path Jens Remus
2026-12-04 17:13   ` sashiko-bot
2026-12-04 16:24 ` [PATCH 4/5] perf python: Honor perf script --demangle and --demangle-kernel Jens Remus
2026-12-04 16:24 ` [PATCH 5/5] perf python: Honor perf script --max-stack Jens Remus
2026-12-04 17:35   ` sashiko-bot
2026-12-04 17:35 ` [PATCH 0/5] perf python: Honor more perf script options sashiko-bot

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