tools/perf/builtin-list.c | 65 ++- .../arch/common/common/software.json | 92 ++++ tools/perf/pmu-events/empty-pmu-events.c | 266 +++++---- tools/perf/pmu-events/jevents.py | 15 +- tools/perf/python/ilist.py | 491 +++++++++++++++++ tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +- tools/perf/util/parse-events.c | 198 ++----- tools/perf/util/parse-events.h | 1 - tools/perf/util/parse-events.l | 38 +- tools/perf/util/parse-events.y | 29 +- tools/perf/util/pfm.c | 2 + tools/perf/util/pmu.c | 7 + tools/perf/util/pmus.c | 2 + tools/perf/util/print-events.c | 100 +--- tools/perf/util/print-events.h | 4 +- tools/perf/util/python.c | 519 +++++++++++++++++- tools/perf/util/tp_pmu.c | 209 +++++++ tools/perf/util/tp_pmu.h | 19 + 19 files changed, 1638 insertions(+), 441 deletions(-) create mode 100644 tools/perf/pmu-events/arch/common/common/software.json create mode 100755 tools/perf/python/ilist.py create mode 100644 tools/perf/util/tp_pmu.c create mode 100644 tools/perf/util/tp_pmu.h
This patch series builds up to the addition of a new ilist app written in python using textual [1] for the UI. The app presents perf PMUs and events, displays the event information as in `perf list` while at the bottom of the console showing recent activity of the event in total and across all CPUs. It also displays metrics, placed in a tree through their metric group, again with counts being displayed in the bottom panel. The first ground work patches of fixes, cleanup and refactoring were separated into their own series here: https://lore.kernel.org/lkml/20250709214029.1769089-1-irogers@google.com/ The second part of the patches adds event json for the software PMU and makes the tracepoint PMU support iteration of events and the like. Without these improvements the tracepoint and software PMUs will appear to have no events in the ilist app. As the software PMU moves parsing to json, the legacy hard coded parsing is removed. This has proven controversial for hardware events and so that cleanup isn't done here. The final patches expand the perf python APIs and add the ilist command. To run it you need the updated perf.cpython.so in your PYTHONPATH and then execute the script. Expanding PMUs and then selecting events will cause event informatin to be displayed in the top-right and the counters values to be displayed as sparklines and counts in the bottom half of the screen. [1] https://textual.textualize.io/ v7: Better handle errors in the python code and ignore errors when scanning PMU/events in ilist.py, improving the behavior when not root. Add a tp_pmu/python clean up. Minor kernel coding style clean up. Fix behavior of ilist if a search result isn't found but then next is chosen. v6: For metrics on hybrid systems don't purely match by name, also match the CPU and thread so that if the same metric exists for different PMUs the appropriate one is selected and counters may be read. Likewise use evsel maps and not the evlists. v5: Split the series in two. Add metric support. Various clean ups and tweaks to the app in particular around the handling of searches. v4: No conflict rebase. Picks up perf-tools-next DRM PMU which displays as expected. v3: Add a search dialog to the ilist app with 'n'ext and 'p'revious keys. No changes in the ground work first 14 patches. v2: In the jevents event description duplication, some minor changes accidentally missed from v1 meaning that in v1 the descriptions were still duplicated. Expand the cover letter with some thoughts on the series. Ian Rogers (16): perf python: Add more exceptions on error paths perf jevents: Add common software event json perf parse-events: Remove non-json software events perf tp_pmu: Factor existing tracepoint logic to new file perf tp_pmu: Add event APIs perf list: Remove tracepoint printing code perf list: Skip ABI PMUs when printing pmu values perf python: Improve the tracepoint function if no libtraceevent perf python: Add basic PMU abstraction and pmus sequence perf python: Add function returning dictionary of all events on a PMU perf ilist: Add new python ilist command perf python: Add parse_metrics function perf python: Add evlist metrics function perf python: Add evlist compute_metric perf python: Add metrics function perf ilist: Add support for metrics tools/perf/builtin-list.c | 65 ++- .../arch/common/common/software.json | 92 ++++ tools/perf/pmu-events/empty-pmu-events.c | 266 +++++---- tools/perf/pmu-events/jevents.py | 15 +- tools/perf/python/ilist.py | 491 +++++++++++++++++ tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +- tools/perf/util/parse-events.c | 198 ++----- tools/perf/util/parse-events.h | 1 - tools/perf/util/parse-events.l | 38 +- tools/perf/util/parse-events.y | 29 +- tools/perf/util/pfm.c | 2 + tools/perf/util/pmu.c | 7 + tools/perf/util/pmus.c | 2 + tools/perf/util/print-events.c | 100 +--- tools/perf/util/print-events.h | 4 +- tools/perf/util/python.c | 519 +++++++++++++++++- tools/perf/util/tp_pmu.c | 209 +++++++ tools/perf/util/tp_pmu.h | 19 + 19 files changed, 1638 insertions(+), 441 deletions(-) create mode 100644 tools/perf/pmu-events/arch/common/common/software.json create mode 100755 tools/perf/python/ilist.py create mode 100644 tools/perf/util/tp_pmu.c create mode 100644 tools/perf/util/tp_pmu.h -- 2.50.0.727.gbf7dc18ff4-goog
On Mon, Jul 14, 2025 at 9:44 AM Ian Rogers <irogers@google.com> wrote: > > This patch series builds up to the addition of a new ilist app written > in python using textual [1] for the UI. The app presents perf PMUs and > events, displays the event information as in `perf list` while at the > bottom of the console showing recent activity of the event in total > and across all CPUs. It also displays metrics, placed in a tree > through their metric group, again with counts being displayed in the > bottom panel. > > The first ground work patches of fixes, cleanup and refactoring were > separated into their own series here: > https://lore.kernel.org/lkml/20250709214029.1769089-1-irogers@google.com/ > > The second part of the patches adds event json for the software PMU > and makes the tracepoint PMU support iteration of events and the > like. Without these improvements the tracepoint and software PMUs will > appear to have no events in the ilist app. As the software PMU moves > parsing to json, the legacy hard coded parsing is removed. This has > proven controversial for hardware events and so that cleanup isn't > done here. > > The final patches expand the perf python APIs and add the ilist > command. To run it you need the updated perf.cpython.so in your > PYTHONPATH and then execute the script. Expanding PMUs and then > selecting events will cause event informatin to be displayed in the > top-right and the counters values to be displayed as sparklines and > counts in the bottom half of the screen. > > [1] https://textual.textualize.io/ > > v7: Better handle errors in the python code and ignore errors when > scanning PMU/events in ilist.py, improving the behavior when not > root. Add a tp_pmu/python clean up. Minor kernel coding style > clean up. Fix behavior of ilist if a search result isn't found but > then next is chosen. > > v6: For metrics on hybrid systems don't purely match by name, also > match the CPU and thread so that if the same metric exists for > different PMUs the appropriate one is selected and counters may be > read. Likewise use evsel maps and not the evlists. > > v5: Split the series in two. Add metric support. Various clean ups and > tweaks to the app in particular around the handling of searches. > > v4: No conflict rebase. Picks up perf-tools-next DRM PMU which > displays as expected. > > v3: Add a search dialog to the ilist app with 'n'ext and 'p'revious > keys. No changes in the ground work first 14 patches. > > v2: In the jevents event description duplication, some minor changes > accidentally missed from v1 meaning that in v1 the descriptions > were still duplicated. Expand the cover letter with some thoughts > on the series. > > Ian Rogers (16): > perf python: Add more exceptions on error paths > perf jevents: Add common software event json > perf parse-events: Remove non-json software events > perf tp_pmu: Factor existing tracepoint logic to new file > perf tp_pmu: Add event APIs > perf list: Remove tracepoint printing code > perf list: Skip ABI PMUs when printing pmu values > perf python: Improve the tracepoint function if no libtraceevent > perf python: Add basic PMU abstraction and pmus sequence > perf python: Add function returning dictionary of all events on a PMU > perf ilist: Add new python ilist command > perf python: Add parse_metrics function > perf python: Add evlist metrics function > perf python: Add evlist compute_metric > perf python: Add metrics function > perf ilist: Add support for metrics Hi, Is there any more I can do to get this series landed? I appreciate having: Tested-by: Gautam Menghani <gautam@linux.ibm.com> I think there is some follow up for "make install" for scripts like these, but I'm keen for the python API to move forward. Thanks, Ian > > tools/perf/builtin-list.c | 65 ++- > .../arch/common/common/software.json | 92 ++++ > tools/perf/pmu-events/empty-pmu-events.c | 266 +++++---- > tools/perf/pmu-events/jevents.py | 15 +- > tools/perf/python/ilist.py | 491 +++++++++++++++++ > tools/perf/util/Build | 1 + > tools/perf/util/evsel.c | 21 +- > tools/perf/util/parse-events.c | 198 ++----- > tools/perf/util/parse-events.h | 1 - > tools/perf/util/parse-events.l | 38 +- > tools/perf/util/parse-events.y | 29 +- > tools/perf/util/pfm.c | 2 + > tools/perf/util/pmu.c | 7 + > tools/perf/util/pmus.c | 2 + > tools/perf/util/print-events.c | 100 +--- > tools/perf/util/print-events.h | 4 +- > tools/perf/util/python.c | 519 +++++++++++++++++- > tools/perf/util/tp_pmu.c | 209 +++++++ > tools/perf/util/tp_pmu.h | 19 + > 19 files changed, 1638 insertions(+), 441 deletions(-) > create mode 100644 tools/perf/pmu-events/arch/common/common/software.json > create mode 100755 tools/perf/python/ilist.py > create mode 100644 tools/perf/util/tp_pmu.c > create mode 100644 tools/perf/util/tp_pmu.h > > -- > 2.50.0.727.gbf7dc18ff4-goog >
Hi Ian, On Wed, Jul 23, 2025 at 08:32:33AM -0700, Ian Rogers wrote: > On Mon, Jul 14, 2025 at 9:44 AM Ian Rogers <irogers@google.com> wrote: > > > > This patch series builds up to the addition of a new ilist app written > > in python using textual [1] for the UI. The app presents perf PMUs and > > events, displays the event information as in `perf list` while at the > > bottom of the console showing recent activity of the event in total > > and across all CPUs. It also displays metrics, placed in a tree > > through their metric group, again with counts being displayed in the > > bottom panel. > > > > The first ground work patches of fixes, cleanup and refactoring were > > separated into their own series here: > > https://lore.kernel.org/lkml/20250709214029.1769089-1-irogers@google.com/ > > > > The second part of the patches adds event json for the software PMU > > and makes the tracepoint PMU support iteration of events and the > > like. Without these improvements the tracepoint and software PMUs will > > appear to have no events in the ilist app. As the software PMU moves > > parsing to json, the legacy hard coded parsing is removed. This has > > proven controversial for hardware events and so that cleanup isn't > > done here. > > > > The final patches expand the perf python APIs and add the ilist > > command. To run it you need the updated perf.cpython.so in your > > PYTHONPATH and then execute the script. Expanding PMUs and then > > selecting events will cause event informatin to be displayed in the > > top-right and the counters values to be displayed as sparklines and > > counts in the bottom half of the screen. > > > > [1] https://textual.textualize.io/ > > > > v7: Better handle errors in the python code and ignore errors when > > scanning PMU/events in ilist.py, improving the behavior when not > > root. Add a tp_pmu/python clean up. Minor kernel coding style > > clean up. Fix behavior of ilist if a search result isn't found but > > then next is chosen. > > > > v6: For metrics on hybrid systems don't purely match by name, also > > match the CPU and thread so that if the same metric exists for > > different PMUs the appropriate one is selected and counters may be > > read. Likewise use evsel maps and not the evlists. > > > > v5: Split the series in two. Add metric support. Various clean ups and > > tweaks to the app in particular around the handling of searches. > > > > v4: No conflict rebase. Picks up perf-tools-next DRM PMU which > > displays as expected. > > > > v3: Add a search dialog to the ilist app with 'n'ext and 'p'revious > > keys. No changes in the ground work first 14 patches. > > > > v2: In the jevents event description duplication, some minor changes > > accidentally missed from v1 meaning that in v1 the descriptions > > were still duplicated. Expand the cover letter with some thoughts > > on the series. > > > > Ian Rogers (16): > > perf python: Add more exceptions on error paths > > perf jevents: Add common software event json > > perf parse-events: Remove non-json software events > > perf tp_pmu: Factor existing tracepoint logic to new file > > perf tp_pmu: Add event APIs > > perf list: Remove tracepoint printing code > > perf list: Skip ABI PMUs when printing pmu values > > perf python: Improve the tracepoint function if no libtraceevent > > perf python: Add basic PMU abstraction and pmus sequence > > perf python: Add function returning dictionary of all events on a PMU > > perf ilist: Add new python ilist command > > perf python: Add parse_metrics function > > perf python: Add evlist metrics function > > perf python: Add evlist compute_metric > > perf python: Add metrics function > > perf ilist: Add support for metrics > > Hi, > > Is there any more I can do to get this series landed? I appreciate having: > > Tested-by: Gautam Menghani <gautam@linux.ibm.com> > > I think there is some follow up for "make install" for scripts like > these, but I'm keen for the python API to move forward. I'll review the series today so that we can get some part of it, at least. Basically I think we need a wrapper script like perf-ilist to run this easily (maybe with documentation). Thanks, Namhyung > > > > tools/perf/builtin-list.c | 65 ++- > > .../arch/common/common/software.json | 92 ++++ > > tools/perf/pmu-events/empty-pmu-events.c | 266 +++++---- > > tools/perf/pmu-events/jevents.py | 15 +- > > tools/perf/python/ilist.py | 491 +++++++++++++++++ > > tools/perf/util/Build | 1 + > > tools/perf/util/evsel.c | 21 +- > > tools/perf/util/parse-events.c | 198 ++----- > > tools/perf/util/parse-events.h | 1 - > > tools/perf/util/parse-events.l | 38 +- > > tools/perf/util/parse-events.y | 29 +- > > tools/perf/util/pfm.c | 2 + > > tools/perf/util/pmu.c | 7 + > > tools/perf/util/pmus.c | 2 + > > tools/perf/util/print-events.c | 100 +--- > > tools/perf/util/print-events.h | 4 +- > > tools/perf/util/python.c | 519 +++++++++++++++++- > > tools/perf/util/tp_pmu.c | 209 +++++++ > > tools/perf/util/tp_pmu.h | 19 + > > 19 files changed, 1638 insertions(+), 441 deletions(-) > > create mode 100644 tools/perf/pmu-events/arch/common/common/software.json > > create mode 100755 tools/perf/python/ilist.py > > create mode 100644 tools/perf/util/tp_pmu.c > > create mode 100644 tools/perf/util/tp_pmu.h > > > > -- > > 2.50.0.727.gbf7dc18ff4-goog > >
On Wed, Jul 23, 2025 at 11:00:18AM -0700, Namhyung Kim wrote: > Hi Ian, > > On Wed, Jul 23, 2025 at 08:32:33AM -0700, Ian Rogers wrote: > > On Mon, Jul 14, 2025 at 9:44 AM Ian Rogers <irogers@google.com> wrote: > > > > > > This patch series builds up to the addition of a new ilist app written > > > in python using textual [1] for the UI. The app presents perf PMUs and > > > events, displays the event information as in `perf list` while at the > > > bottom of the console showing recent activity of the event in total > > > and across all CPUs. It also displays metrics, placed in a tree > > > through their metric group, again with counts being displayed in the > > > bottom panel. > > > > > > The first ground work patches of fixes, cleanup and refactoring were > > > separated into their own series here: > > > https://lore.kernel.org/lkml/20250709214029.1769089-1-irogers@google.com/ > > > > > > The second part of the patches adds event json for the software PMU > > > and makes the tracepoint PMU support iteration of events and the > > > like. Without these improvements the tracepoint and software PMUs will > > > appear to have no events in the ilist app. As the software PMU moves > > > parsing to json, the legacy hard coded parsing is removed. This has > > > proven controversial for hardware events and so that cleanup isn't > > > done here. > > > > > > The final patches expand the perf python APIs and add the ilist > > > command. To run it you need the updated perf.cpython.so in your > > > PYTHONPATH and then execute the script. Expanding PMUs and then > > > selecting events will cause event informatin to be displayed in the > > > top-right and the counters values to be displayed as sparklines and > > > counts in the bottom half of the screen. > > > > > > [1] https://textual.textualize.io/ > > > > > > v7: Better handle errors in the python code and ignore errors when > > > scanning PMU/events in ilist.py, improving the behavior when not > > > root. Add a tp_pmu/python clean up. Minor kernel coding style > > > clean up. Fix behavior of ilist if a search result isn't found but > > > then next is chosen. > > > > > > v6: For metrics on hybrid systems don't purely match by name, also > > > match the CPU and thread so that if the same metric exists for > > > different PMUs the appropriate one is selected and counters may be > > > read. Likewise use evsel maps and not the evlists. > > > > > > v5: Split the series in two. Add metric support. Various clean ups and > > > tweaks to the app in particular around the handling of searches. > > > > > > v4: No conflict rebase. Picks up perf-tools-next DRM PMU which > > > displays as expected. > > > > > > v3: Add a search dialog to the ilist app with 'n'ext and 'p'revious > > > keys. No changes in the ground work first 14 patches. > > > > > > v2: In the jevents event description duplication, some minor changes > > > accidentally missed from v1 meaning that in v1 the descriptions > > > were still duplicated. Expand the cover letter with some thoughts > > > on the series. > > > > > > Ian Rogers (16): > > > perf python: Add more exceptions on error paths > > > perf jevents: Add common software event json > > > perf parse-events: Remove non-json software events > > > perf tp_pmu: Factor existing tracepoint logic to new file > > > perf tp_pmu: Add event APIs > > > perf list: Remove tracepoint printing code > > > perf list: Skip ABI PMUs when printing pmu values > > > perf python: Improve the tracepoint function if no libtraceevent > > > perf python: Add basic PMU abstraction and pmus sequence > > > perf python: Add function returning dictionary of all events on a PMU > > > perf ilist: Add new python ilist command > > > perf python: Add parse_metrics function > > > perf python: Add evlist metrics function > > > perf python: Add evlist compute_metric > > > perf python: Add metrics function > > > perf ilist: Add support for metrics > > > > Hi, > > > > Is there any more I can do to get this series landed? I appreciate having: > > > > Tested-by: Gautam Menghani <gautam@linux.ibm.com> > > > > I think there is some follow up for "make install" for scripts like > > these, but I'm keen for the python API to move forward. > > I'll review the series today so that we can get some part of it, at > least. Basically I think we need a wrapper script like perf-ilist to > run this easily (maybe with documentation). I just tried, with the series applied: root@number:~# perf ilist perf: 'ilist' is not a perf-command. See 'perf --help'. Did you mean this? list root@number:~# Now trying to figure out why it is not running. - Arnaldo
On Wed, Jul 23, 2025 at 04:08:55PM -0300, Arnaldo Carvalho de Melo wrote: > On Wed, Jul 23, 2025 at 11:00:18AM -0700, Namhyung Kim wrote: > > > I think there is some follow up for "make install" for scripts like > > > these, but I'm keen for the python API to move forward. > > > > I'll review the series today so that we can get some part of it, at > > least. Basically I think we need a wrapper script like perf-ilist to > > run this easily (maybe with documentation). > > I just tried, with the series applied: > > root@number:~# perf ilist > perf: 'ilist' is not a perf-command. See 'perf --help'. > > Did you mean this? > list > root@number:~# > > Now trying to figure out why it is not running. So it is not wired up like 'perf archive', trying it directly: root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py Traceback (most recent call last): File "/home/acme/git/perf-tools-next/tools/perf/python/ilist.py", line 11, in <module> from textual import on ModuleNotFoundError: No module named 'textual' root@number:~# I thought there was some discussion about catching this exception and providing guidance, lemme try... - Arnaldo
On Wed, Jul 23, 2025 at 04:11:13PM -0300, Arnaldo Carvalho de Melo wrote: > On Wed, Jul 23, 2025 at 04:08:55PM -0300, Arnaldo Carvalho de Melo wrote: > > On Wed, Jul 23, 2025 at 11:00:18AM -0700, Namhyung Kim wrote: > > > > I think there is some follow up for "make install" for scripts like > > > > these, but I'm keen for the python API to move forward. > > > I'll review the series today so that we can get some part of it, at > > > least. Basically I think we need a wrapper script like perf-ilist to > > > run this easily (maybe with documentation). > > I just tried, with the series applied: > > root@number:~# perf ilist > > perf: 'ilist' is not a perf-command. See 'perf --help'. > > Did you mean this? > > list > > root@number:~# > > Now trying to figure out why it is not running. > So it is not wired up like 'perf archive', trying it directly: > root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py > Traceback (most recent call last): > File "/home/acme/git/perf-tools-next/tools/perf/python/ilist.py", line 11, in <module> > from textual import on > ModuleNotFoundError: No module named 'textual' > root@number:~# > I thought there was some discussion about catching this exception and > providing guidance, lemme try... root@number:~# sudo dnf install python-textual Updating and loading repositories: google-chrome 100% | 6.1 KiB/s | 1.3 KiB | 00m00s Copr repo for PyCharm owned by phracek 100% | 2.0 KiB/s | 2.1 KiB | 00m01s RPM Fusion for Fedora 42 - Nonfree - NVIDIA Driver 100% | 2.6 KiB/s | 2.5 KiB | 00m01s RPM Fusion for Fedora 42 - Nonfree - Steam 100% | 5.8 KiB/s | 2.4 KiB | 00m00s google-chrome 100% | 7.2 KiB/s | 3.2 KiB | 00m00s Copr repo for PyCharm owned by phracek 100% | 15.7 KiB/s | 4.8 KiB | 00m00s Repositories loaded. Package Arch Version Repository Size Installing: python3-textual noarch 1.0.0-1.fc42 fedora 6.6 MiB Installing dependencies: python3-linkify-it-py noarch 2.0.3-4.fc42 fedora 110.4 KiB python3-markdown-it-py noarch 3.0.0-8.fc42 fedora 496.3 KiB python3-markdown-it-py+linkify noarch 3.0.0-8.fc42 fedora 9.0 KiB python3-markdown-it-py+plugins noarch 3.0.0-8.fc42 fedora 9.0 KiB python3-mdit-py-plugins noarch 0.4.2-2.fc42 fedora 289.4 KiB python3-mdurl noarch 0.1.2-9.fc42 fedora 41.4 KiB python3-platformdirs noarch 4.2.2-4.fc42 fedora 162.0 KiB python3-pygments noarch 2.18.0-4.fc42 fedora 10.6 MiB python3-rich noarch 13.9.4-2.fc42 fedora 2.5 MiB python3-uc-micro-py noarch 1.0.3-4.fc42 fedora 13.1 KiB Transaction Summary: Installing: 11 packages Total size of inbound packages is 5 MiB. Need to download 5 MiB. After this operation, 21 MiB extra will be used (install 21 MiB, remove 0 B). Is this ok [y/N]: y <SNIP> [13/13] Installing python3-textual-0:1.0.0-1.fc42.noarch 100% | 10.1 MiB/s | 6.8 MiB | 00m01s Complete! root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py ╭────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────╮ │ /home/acme/git/perf-tools-next/tools/perf/python/ilist.py:470 in compose │ │ │ │ 467 │ │ │ return tree │ │ 468 │ │ │ │ 469 │ │ yield Header(id="header") │ │ ❱ 470 │ │ yield Horizontal(Vertical(metric_event_tree(), id="events"), │ │ 471 │ │ │ │ │ │ Vertical(Label("event name", id="event_name"), │ │ 472 │ │ │ │ │ │ │ │ Static("description", markup=False, id="event_descript │ │ 473 │ │ │ │ │ │ │ │ )) │ │ │ │ ╭───────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮ │ │ │ self = IListApp(title='Interactive Perf List', classes={'-dark-mode'}, pseudo_classes={'dark', 'focus'}) │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/acme/git/perf-tools-next/tools/perf/python/ilist.py:433 in metric_event_tree │ │ │ │ 430 │ │ │ """Create tree of PMUs and metricgroups with events or metrics under.""" ╭─────────── locals ────────────╮ │ │ 431 │ │ │ tree: Tree[TreeValue] = Tree("Root", id="root") │ pmus = TreeNode('PMUs', None) │ │ │ 432 │ │ │ pmus = tree.root.add("PMUs") │ tree = Tree(id='root') │ │ │ ❱ 433 │ │ │ for pmu in perf.pmus(): ╰───────────────────────────────╯ │ │ 434 │ │ │ │ pmu_name = pmu.name().lower() │ │ 435 │ │ │ │ pmu_node = pmus.add(pmu_name) │ │ 436 │ │ │ │ try: │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ AttributeError: module 'perf' has no attribute 'pmus' root@number:~# Ok, that was with the 'python-perf3' rpm package on fedora 42, trying with the new one... root@number:~# export PYTHONPATH=/tmp/build/perf-tools-next/python root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py Cool stuff! Lots of flashing lights! :-) Interesting to quickly browse all those events, I like it. I searched for "wakeup" and stumbled on ftrace:wakeup failures, but that should be just a minor adjustment, some exception list: root@number:~# ls -la /sys/kernel/tracing/events/ftrace/wakeup/ total 0 drwxr-xr-x. 1 root root 0 Jul 23 16:04 . drwxr-xr-x. 1 root root 0 Jul 23 16:04 .. -r--r-----. 1 root root 0 Jul 23 16:04 format -r--r-----. 1 root root 0 Jul 23 16:19 hist root@number:~# root@number:~# ls -la /sys/kernel/tracing/events/sched/sched_wakeup/ total 0 drwxr-xr-x. 1 root root 0 Jul 23 16:04 . drwxr-xr-x. 1 root root 0 Jul 23 16:04 .. -rw-r-----. 1 root root 0 Jul 23 16:19 enable -rw-r-----. 1 root root 0 Jul 23 16:19 filter -r--r-----. 1 root root 0 Jul 23 16:04 format -r--r-----. 1 root root 0 Jul 23 16:19 hist -r--r-----. 1 root root 0 Jul 23 16:04 id -rw-r-----. 1 root root 0 Jul 23 16:19 trigger root@number:~# Do you know how to take text screen shots in textual? Apart from the super minor nits, thanks for working on this: Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> - Arnaldo
On Wed, Jul 23, 2025 at 12:24 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Wed, Jul 23, 2025 at 04:11:13PM -0300, Arnaldo Carvalho de Melo wrote: > > On Wed, Jul 23, 2025 at 04:08:55PM -0300, Arnaldo Carvalho de Melo wrote: > > > On Wed, Jul 23, 2025 at 11:00:18AM -0700, Namhyung Kim wrote: > > > > > I think there is some follow up for "make install" for scripts like > > > > > these, but I'm keen for the python API to move forward. > > > > > I'll review the series today so that we can get some part of it, at > > > > least. Basically I think we need a wrapper script like perf-ilist to > > > > run this easily (maybe with documentation). > > > > I just tried, with the series applied: > > > > root@number:~# perf ilist > > > perf: 'ilist' is not a perf-command. See 'perf --help'. > > > > Did you mean this? > > > list > > > root@number:~# > > > > Now trying to figure out why it is not running. > > > So it is not wired up like 'perf archive', trying it directly: > > > root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py > > Traceback (most recent call last): > > File "/home/acme/git/perf-tools-next/tools/perf/python/ilist.py", line 11, in <module> > > from textual import on > > ModuleNotFoundError: No module named 'textual' > > root@number:~# > > > I thought there was some discussion about catching this exception and > > providing guidance, lemme try... > > root@number:~# sudo dnf install python-textual > Updating and loading repositories: > google-chrome 100% | 6.1 KiB/s | 1.3 KiB | 00m00s > Copr repo for PyCharm owned by phracek 100% | 2.0 KiB/s | 2.1 KiB | 00m01s > RPM Fusion for Fedora 42 - Nonfree - NVIDIA Driver 100% | 2.6 KiB/s | 2.5 KiB | 00m01s > RPM Fusion for Fedora 42 - Nonfree - Steam 100% | 5.8 KiB/s | 2.4 KiB | 00m00s > google-chrome 100% | 7.2 KiB/s | 3.2 KiB | 00m00s > Copr repo for PyCharm owned by phracek 100% | 15.7 KiB/s | 4.8 KiB | 00m00s > Repositories loaded. > Package Arch Version Repository Size > Installing: > python3-textual noarch 1.0.0-1.fc42 fedora 6.6 MiB > Installing dependencies: > python3-linkify-it-py noarch 2.0.3-4.fc42 fedora 110.4 KiB > python3-markdown-it-py noarch 3.0.0-8.fc42 fedora 496.3 KiB > python3-markdown-it-py+linkify noarch 3.0.0-8.fc42 fedora 9.0 KiB > python3-markdown-it-py+plugins noarch 3.0.0-8.fc42 fedora 9.0 KiB > python3-mdit-py-plugins noarch 0.4.2-2.fc42 fedora 289.4 KiB > python3-mdurl noarch 0.1.2-9.fc42 fedora 41.4 KiB > python3-platformdirs noarch 4.2.2-4.fc42 fedora 162.0 KiB > python3-pygments noarch 2.18.0-4.fc42 fedora 10.6 MiB > python3-rich noarch 13.9.4-2.fc42 fedora 2.5 MiB > python3-uc-micro-py noarch 1.0.3-4.fc42 fedora 13.1 KiB > > Transaction Summary: > Installing: 11 packages > > Total size of inbound packages is 5 MiB. Need to download 5 MiB. > After this operation, 21 MiB extra will be used (install 21 MiB, remove 0 B). > Is this ok [y/N]: y > <SNIP> > [13/13] Installing python3-textual-0:1.0.0-1.fc42.noarch 100% | 10.1 MiB/s | 6.8 MiB | 00m01s > Complete! > root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py > ╭────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────╮ > │ /home/acme/git/perf-tools-next/tools/perf/python/ilist.py:470 in compose │ > │ │ > │ 467 │ │ │ return tree │ > │ 468 │ │ │ > │ 469 │ │ yield Header(id="header") │ > │ ❱ 470 │ │ yield Horizontal(Vertical(metric_event_tree(), id="events"), │ > │ 471 │ │ │ │ │ │ Vertical(Label("event name", id="event_name"), │ > │ 472 │ │ │ │ │ │ │ │ Static("description", markup=False, id="event_descript │ > │ 473 │ │ │ │ │ │ │ │ )) │ > │ │ > │ ╭───────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮ │ > │ │ self = IListApp(title='Interactive Perf List', classes={'-dark-mode'}, pseudo_classes={'dark', 'focus'}) │ │ > │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │ > │ │ > │ /home/acme/git/perf-tools-next/tools/perf/python/ilist.py:433 in metric_event_tree │ > │ │ > │ 430 │ │ │ """Create tree of PMUs and metricgroups with events or metrics under.""" ╭─────────── locals ────────────╮ │ > │ 431 │ │ │ tree: Tree[TreeValue] = Tree("Root", id="root") │ pmus = TreeNode('PMUs', None) │ │ > │ 432 │ │ │ pmus = tree.root.add("PMUs") │ tree = Tree(id='root') │ │ > │ ❱ 433 │ │ │ for pmu in perf.pmus(): ╰───────────────────────────────╯ │ > │ 434 │ │ │ │ pmu_name = pmu.name().lower() │ > │ 435 │ │ │ │ pmu_node = pmus.add(pmu_name) │ > │ 436 │ │ │ │ try: │ > ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ > AttributeError: module 'perf' has no attribute 'pmus' > root@number:~# > > Ok, that was with the 'python-perf3' rpm package on fedora 42, trying > with the new one... > > root@number:~# export PYTHONPATH=/tmp/build/perf-tools-next/python > root@number:~# ~acme/git/perf-tools-next/tools/perf/python/ilist.py > > Cool stuff! > > Lots of flashing lights! :-) > > Interesting to quickly browse all those events, I like it. > > I searched for "wakeup" and stumbled on ftrace:wakeup failures, but that > should be just a minor adjustment, some exception list: > > root@number:~# ls -la /sys/kernel/tracing/events/ftrace/wakeup/ > total 0 > drwxr-xr-x. 1 root root 0 Jul 23 16:04 . > drwxr-xr-x. 1 root root 0 Jul 23 16:04 .. > -r--r-----. 1 root root 0 Jul 23 16:04 format > -r--r-----. 1 root root 0 Jul 23 16:19 hist > root@number:~# > root@number:~# ls -la /sys/kernel/tracing/events/sched/sched_wakeup/ > total 0 > drwxr-xr-x. 1 root root 0 Jul 23 16:04 . > drwxr-xr-x. 1 root root 0 Jul 23 16:04 .. > -rw-r-----. 1 root root 0 Jul 23 16:19 enable > -rw-r-----. 1 root root 0 Jul 23 16:19 filter > -r--r-----. 1 root root 0 Jul 23 16:04 format > -r--r-----. 1 root root 0 Jul 23 16:19 hist > -r--r-----. 1 root root 0 Jul 23 16:04 id > -rw-r-----. 1 root root 0 Jul 23 16:19 trigger > root@number:~# > > Do you know how to take text screen shots in textual? So there's a built-in screen shot thing. Press ctrl+p to bring up the inbuilt command palette, then select "Save screenshot" which will save an SVG screenshot. It should be possible to force a lowly terminal and then grab the characters, I tried but didn't get very far with it. There are console recorder apps. My preference has just been to grab regular screenshots and then cut out a PNG. Attaching any kind of non-standard character or image to an LKML post I think would cause it to be bounced. I've posted some images here: ilist working first on events: https://fosstodon.org/@irogers/114677152263351891 ilist metrics working on hybrid: https://fosstodon.org/@irogers/114831660998075850 ilist running on WSL on AMD: https://fosstodon.org/@irogers/114849910913098482 > Apart from the super minor nits, thanks for working on this: > > Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Thanks! I think there are still improvements to be had like improving the layout of the screen, deduplicating PMUs, etc. nothing that can't be incrementally added. Probably the biggest thing is what to do for "make install" and packaging it [1]. I think it is a very nice way to discover what perf can inform you about, and I think everyone I've talked to prefers doing it with this app rather than trying to get the same data from regular `perf list`. For example, I was surprised how much data I could get from WSL. Thanks, Ian [1] (some thoughts on packaging in reply to Namhyung) https://lore.kernel.org/lkml/CAP-5=fX1j_MdzjqLTYeNGFTWLaQp8Dmbi093QN98b2pNgFcpBA@mail.gmail.com/ > - Arnaldo
On Wed, Jul 23, 2025 at 11:00 AM Namhyung Kim <namhyung@kernel.org> wrote: > > Hi Ian, > > On Wed, Jul 23, 2025 at 08:32:33AM -0700, Ian Rogers wrote: > > On Mon, Jul 14, 2025 at 9:44 AM Ian Rogers <irogers@google.com> wrote: > > > > > > This patch series builds up to the addition of a new ilist app written > > > in python using textual [1] for the UI. The app presents perf PMUs and > > > events, displays the event information as in `perf list` while at the > > > bottom of the console showing recent activity of the event in total > > > and across all CPUs. It also displays metrics, placed in a tree > > > through their metric group, again with counts being displayed in the > > > bottom panel. > > > > > > The first ground work patches of fixes, cleanup and refactoring were > > > separated into their own series here: > > > https://lore.kernel.org/lkml/20250709214029.1769089-1-irogers@google.com/ > > > > > > The second part of the patches adds event json for the software PMU > > > and makes the tracepoint PMU support iteration of events and the > > > like. Without these improvements the tracepoint and software PMUs will > > > appear to have no events in the ilist app. As the software PMU moves > > > parsing to json, the legacy hard coded parsing is removed. This has > > > proven controversial for hardware events and so that cleanup isn't > > > done here. > > > > > > The final patches expand the perf python APIs and add the ilist > > > command. To run it you need the updated perf.cpython.so in your > > > PYTHONPATH and then execute the script. Expanding PMUs and then > > > selecting events will cause event informatin to be displayed in the > > > top-right and the counters values to be displayed as sparklines and > > > counts in the bottom half of the screen. > > > > > > [1] https://textual.textualize.io/ > > > > > > v7: Better handle errors in the python code and ignore errors when > > > scanning PMU/events in ilist.py, improving the behavior when not > > > root. Add a tp_pmu/python clean up. Minor kernel coding style > > > clean up. Fix behavior of ilist if a search result isn't found but > > > then next is chosen. > > > > > > v6: For metrics on hybrid systems don't purely match by name, also > > > match the CPU and thread so that if the same metric exists for > > > different PMUs the appropriate one is selected and counters may be > > > read. Likewise use evsel maps and not the evlists. > > > > > > v5: Split the series in two. Add metric support. Various clean ups and > > > tweaks to the app in particular around the handling of searches. > > > > > > v4: No conflict rebase. Picks up perf-tools-next DRM PMU which > > > displays as expected. > > > > > > v3: Add a search dialog to the ilist app with 'n'ext and 'p'revious > > > keys. No changes in the ground work first 14 patches. > > > > > > v2: In the jevents event description duplication, some minor changes > > > accidentally missed from v1 meaning that in v1 the descriptions > > > were still duplicated. Expand the cover letter with some thoughts > > > on the series. > > > > > > Ian Rogers (16): > > > perf python: Add more exceptions on error paths > > > perf jevents: Add common software event json > > > perf parse-events: Remove non-json software events > > > perf tp_pmu: Factor existing tracepoint logic to new file > > > perf tp_pmu: Add event APIs > > > perf list: Remove tracepoint printing code > > > perf list: Skip ABI PMUs when printing pmu values > > > perf python: Improve the tracepoint function if no libtraceevent > > > perf python: Add basic PMU abstraction and pmus sequence > > > perf python: Add function returning dictionary of all events on a PMU > > > perf ilist: Add new python ilist command > > > perf python: Add parse_metrics function > > > perf python: Add evlist metrics function > > > perf python: Add evlist compute_metric > > > perf python: Add metrics function > > > perf ilist: Add support for metrics > > > > Hi, > > > > Is there any more I can do to get this series landed? I appreciate having: > > > > Tested-by: Gautam Menghani <gautam@linux.ibm.com> > > > > I think there is some follow up for "make install" for scripts like > > these, but I'm keen for the python API to move forward. > > I'll review the series today so that we can get some part of it, at > least. Basically I think we need a wrapper script like perf-ilist to > run this easily (maybe with documentation). Sgtm, I'll hold off on a new version, Arnaldo has caught some useful nits to clean up in it. Something related are the scripting engine scripts like gecko and flamegraph. Something I've discovered is that those scripts work less well than standalone apps like the ilist.py here. One issue there is that the scripting engine tends to throw lots of data into a dictionary in case it is useful, which means there is a higher overhead than in the standalone app. Another issue is that the scripting engine wants perf to drive python to drive the script. This conflicts with python wanting to own the main thread, things like asyncio, etc. For textual it isn't possible for the app to run on anything other than the main thread, but it'd be useful to incrementally load data while displaying it. With the scripting engine it is only possible to run a textual app at trace_end (i.e. not incrementally). Something we found in the gecko work was that it was hard to handle command line arguments in a scripting engine style script, what options are for record, report and live mode. What does this mean? I think we want to move the scripting engine into the python.c and perf python .so and expose it with something like the session/tool API. I think we should migrate the existing scripts to use this and then I think we can deprecate the python interpreter script engine integration. Perhaps we can deprecate perl scripting engine support at the same time. Then things like ilist.py can be run with "perf script ilist", similar to how the scripting engine scripts run today. Your proposal would avoid the need for the script keyword, but perhaps that'd make it clear why the UI changes. I don't mind having or not having "script" in the command line :-) Thanks, Ian > Thanks, > Namhyung > > > > > > > tools/perf/builtin-list.c | 65 ++- > > > .../arch/common/common/software.json | 92 ++++ > > > tools/perf/pmu-events/empty-pmu-events.c | 266 +++++---- > > > tools/perf/pmu-events/jevents.py | 15 +- > > > tools/perf/python/ilist.py | 491 +++++++++++++++++ > > > tools/perf/util/Build | 1 + > > > tools/perf/util/evsel.c | 21 +- > > > tools/perf/util/parse-events.c | 198 ++----- > > > tools/perf/util/parse-events.h | 1 - > > > tools/perf/util/parse-events.l | 38 +- > > > tools/perf/util/parse-events.y | 29 +- > > > tools/perf/util/pfm.c | 2 + > > > tools/perf/util/pmu.c | 7 + > > > tools/perf/util/pmus.c | 2 + > > > tools/perf/util/print-events.c | 100 +--- > > > tools/perf/util/print-events.h | 4 +- > > > tools/perf/util/python.c | 519 +++++++++++++++++- > > > tools/perf/util/tp_pmu.c | 209 +++++++ > > > tools/perf/util/tp_pmu.h | 19 + > > > 19 files changed, 1638 insertions(+), 441 deletions(-) > > > create mode 100644 tools/perf/pmu-events/arch/common/common/software.json > > > create mode 100755 tools/perf/python/ilist.py > > > create mode 100644 tools/perf/util/tp_pmu.c > > > create mode 100644 tools/perf/util/tp_pmu.h > > > > > > -- > > > 2.50.0.727.gbf7dc18ff4-goog > > >
© 2016 - 2025 Red Hat, Inc.