Re: [PATCH v4 00/49] perf: Complete transition to standalone Python scripts

From: Ian Rogers

Date: Sat Sep 26 2026 - 19:12:24 EST


On Sat, Sep 26, 2026 at 3:46 PM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Sat, Sep 26, 2026 at 1:41 PM Arnaldo Carvalho de Melo
> <acme@xxxxxxxxxx> wrote:
> >
> > On Fri, Sep 25, 2026 at 11:19:27PM -0700, Ian Rogers wrote:
> > > The perf script command has historically supported running Python and Perl
> > > scripts by embedding libpython and libperl. That approach has several
> > > drawbacks:
> > > - high overhead from constructing Python dictionaries for every event
> > > (whether used by the script or not),
> > > - complex build dependencies on specific Python/Perl libraries,
> > > - threading and interpreter lifecycle complications from embedding the
> > > interpreter inside perf,
> > > - no unified model for standalone scripts such as ilist.py, treport.py,
> > > tracepoint.py, and twatch.py.
> >
> > So I applied it and tested on the containers, make -C tools/perf
> > build-test and 'perf test', that has some flakiness running the new
> > tests for these python scripts in parallel, nothing that prevents it
> > from being merged now tho:
> >
> > === Test Summary ===
> > Passed main tests : 146
> > Passed subtests : 156
> > Skipped tests : 28
> > Failed tests : 13
> > List of failed tests:
> > 72: Test dwarf unwind
> > 88: daemon operations
> > 101: perf kvm tests
> > 111: perf record tests
> > 112: perf record sample filtering (by BPF) tests
> > 117: perf sched tests
> > 137: check-perf-trace python test
> > 138: compaction-times python test
> > 141: failed-syscalls-by-pid python test
> > 142: failed-syscalls python test
> > 144: futex-contention python test
> > 157: sctop python test
> > 159: stat-cpi python test
> > root@x2:~# perf test 72
> > 72: Test dwarf unwind : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > root@x2:~# perf test 88
> > 88: daemon operations : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > root@x2:~# perf test 101
> > 101: perf kvm tests : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > root@x2:~# perf test 112 ; perf test 117 ; perf test 137 ; perf test 141 ; perf test 142 ; perf test 144 ; perf test 157; perf test 159
> > 112: perf record sample filtering (by BPF) tests : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 117: perf sched tests : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 137: check-perf-trace python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 141: failed-syscalls-by-pid python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 142: failed-syscalls python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 144: futex-contention python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 157: sctop python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > 159: stat-cpi python test : Ok
> >
> > === Test Summary ===
> > Passed main tests : 1
> > Passed subtests : 0
> > Skipped tests : 0
> > Failed tests : 0
> > root@x2:~# uname -a
> > Linux x2 7.2.5-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026 x86_64 GNU/Linux
> > root@x2:~# cat /etc/os-release
> > NAME="Fedora Linux"
> > VERSION="44 (Workstation Edition)"
> > RELEASE_TYPE=stable
> > ID=fedora
> > VERSION_ID=44
> > VERSION_CODENAME=""
> > PRETTY_NAME="Fedora Linux 44 (Workstation Edition)"
> > ANSI_COLOR="0;38;2;60;110;180"
> > LOGO=fedora-logo-icon
> > CPE_NAME="cpe:/o:fedoraproject:fedora:44"
> > DEFAULT_HOSTNAME="fedora"
> > HOME_URL="https://fedoraproject.org/";
> > DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f44/";
> > SUPPORT_URL="https://ask.fedoraproject.org/";
> > BUG_REPORT_URL="https://bugzilla.redhat.com/";
> > REDHAT_BUGZILLA_PRODUCT="Fedora"
> > REDHAT_BUGZILLA_PRODUCT_VERSION=44
> > REDHAT_SUPPORT_PRODUCT="Fedora"
> > REDHAT_SUPPORT_PRODUCT_VERSION=44
> > SUPPORT_END=2027-05-19
> > VARIANT="Workstation Edition"
> > VARIANT_ID=workstation
> > root@x2:~#
>
> That's great! I'll dig into the flakes.

Just to add, testing with perf-tools-next:
```
$ make -C tools/perf O=/tmp/perf DESTDIR=/tmp/perf-install DEBUG=1 install
...
$ PERF_EXEC_PATH=/tmp/perf-install/libexec/perf-core
/tmp/perf-install/bin/perf script -l
List of available scripts:
arm-cs-trace-disasm arm-cs-trace-disasm.py: ARM
CoreSight Trace Dump With Disassembler
check-perf-trace Basic test of Python scripting
support for perf.
compaction-times Report time spent in memory compaction.
counting Example for counting perf events.
event_analyzing_sample General event handler in
Python, using SQLite to analyze events.
export-to-postgresql Export perf data to a
postgresql database.
export-to-sqlite Export perf data to a sqlite3 database.
exported-sql-viewer exported-sql-viewer.py: view
data from sql database.
failed-syscalls Failed system call counts.
failed-syscalls-by-pid Displays system-wide failed
system call totals, broken down by pid.
flamegraph flamegraph.py - create flame
graphs from perf samples using perf python module
futex-contention Measures futex contention.
gecko gecko.py - Convert perf record
output to Firefox's gecko profile format
ilist Interactive perf list.
intel-pt-events Print Intel PT Events including
Power Events and PTWRITE.
libxed Python wrapper for libxed.so
mem-phys-addr mem-phys-addr.py: Resolve
physical address samples
net_dropmonitor Monitor the system for dropped
packets and produce a report of drop locations and counts.
netdev-times Display a process of packets
and processed time.
parallel-perf Parallel perf script.
perf_live Live event session helper using
perf.evlist.
powerpc-hcalls Hypervisor call statistics
rw-by-file Display r/w activity for files
read/written to for a given program.
rw-by-pid Display r/w activity for all processes.
rwtop Periodically displays
system-wide r/w call activity, broken down by pid.
sched-migration Cpu task migration overview toy
SchedGui SchedGui.py - Python extension
for perf script, basic GUI code for traces drawing and overview.
sctop System call top
stackcollapse stackcollapse.py - format perf
samples with one line per distinct call stack
stat-cpi Calculate CPI from perf stat
data or live.
syscall-counts Displays system-wide system
call totals, broken down by syscall.
syscall-counts-by-pid Displays system-wide system
call totals, broken down by syscall.
task-analyzer Comprehensive perf tasks analysis.
tracepoint Example showing how to enable a
tracepoint and access its fields.
treport treport.py - perf report like
tool written using textual.
twatch Example to show how to enable a
software event and track context switches.
wakeup-latency Display avg/min/max wakeup latency.
$ sudo bash -c "PERF_EXEC_PATH=/tmp/perf-install/libexec/perf-core
/tmp/perf-install/bin/perf script ilist"
...
```
:-D

Thanks!
Ian