[PATCH v9 00/23] perf python: Modernize and extend Python API (Phase 1)
Arnaldo Carvalho de Melo
acme at kernel.org
Mon May 25 13:14:22 PDT 2026
On Fri, May 22, 2026 at 03:04:11PM -0700, Ian Rogers wrote:
> The perf script command has long supported running Python and Perl scripts by
> embedding libpython and libperl. This approach has several drawbacks:
> - overhead by creating Python dictionaries for every event (whether used or
> not),
> - complex build dependencies on specific Python/Perl versions,
> - complications with threading due to perf being the interpreter,
> - no clear way to run standalone scripts like ilist.py.
>
> This series takes a different approach with some initial implementation posted
> as an RFC last October:
> https://lore.kernel.org/linux-perf-users/20251029053413.355154-1-irogers@google.com/
> with the motivation coming up on the mailing list earlier:
> https://lore.kernel.org/lkml/CAP-5=fWDqE8SYfOLZkg_0=4Ayx6E7O+h7uUp4NDeCFkiN4b7-w@mail.gmail.com/
>
> The ultimate goal is to remove the embedded libpython and libperl support from
> perf entirely, expanding the existing perf Python module to provide full access
> to perf data files and events, allowing scripts to be run as standalone Python
> applications.
>
> To make the review process more manageable, the original 58-patch series has
> been split. This v9 series represents "Phase 1: API & Infrastructure" (23 patches).
> It contains:
> 1. Missed explicit dependency cleanups and header sorting.
> 2. Crucial core safety infrastructure (reference counting for evlist/evsel)
> to support safe lifecycle management in garbage-collected Python.
> 3. The core Python API extensions (session wrappers, perf_data wrappers,
> sample accessors, stubs, and LiveSession helper).
>
> The subsequent "Phase 2" series will contain the actual porting of all
> existing Python/Perl scripts to the new API (which yields up to 35x speedups
> as demonstrated previously) and the final removal of embedded interpreters.
I tried applying it now and got this:
Cover: ./v9_20260522_irogers_perf_python_modernize_and_extend_python_api_phase_1.cover
Link: https://lore.kernel.org/r/20260522220435.2378363-1-irogers@google.com
Base: not specified
git am ./v9_20260522_irogers_perf_python_modernize_and_extend_python_api_phase_1.mbx
⬢ [acme at toolbx perf-tools-next2]$ git am ./v9_20260522_irogers_perf_python_modernize_and_extend_python_api_phase_1.mbx
Applying: perf arch arm: Sort includes and add missed explicit dependencies
Applying: perf arch x86: Sort includes and add missed explicit dependencies
Applying: perf tests: Sort includes and add missed explicit dependencies
Applying: perf script: Sort includes and add missed explicit dependencies
Applying: perf util: Sort includes and add missed explicit dependencies
error: patch failed: tools/perf/util/evsel.c:11
error: tools/perf/util/evsel.c: patch does not apply
Patch failed at 0005 perf util: Sort includes and add missed explicit dependencies
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
⬢ [acme at toolbx perf-tools-next2]$ git am --abort
⬢ [acme at toolbx perf-tools-next2]$ git diff
⬢ [acme at toolbx perf-tools-next2]$
I agree with the intent and plan on reviewing and testing it.
- Arnaldo
More information about the linux-arm-kernel
mailing list