New perf ilist app
Ian Rogers
reviewerv4 cover New perf ilist app
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.
The first part of the patches are a few perf and perf python C API fixes, most importantly the counter reading in python supports tool PMUs.
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 patch adds 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.
Some thoughts on the series:
- The PMU changes will conflict with the addition of the DRM PMU:
https://lore.kernel.org/lkml/[email protected]/
when these two are merged together ilist will show yet more counters. It'd be nice if the DRM stuff could land and then I can rebase these patches.
- The parse-events clean up of the software and tracepoint PMU. The software PMU hard coding to be legacy first has similar issues and will conflict with the clean up in:
https://lore.kernel.org/lkml/[email protected]/
Moving the software work to json means we don't need special parse events terms for software events, etc. We can just treat things like regular PMUs with json, etc. I'd much rather we had less special case logic so that series is best rebased on top of this work and it should drop the changes for software terms, etc. which this series removes. Maybe one day the whole event parsing can be much more regular in how PMUs are treated but there's always "cycles".
- Should python libraries have feature tests? How does this get packaged outside the kernel tree? I think these are open questions. Clearly textual is kind of a big dependency and we've largely been moving in the direction of fewer dependencies recently. Hopefully the app makes it clear why I think this one is worth carrying. We carry libslang as a dependency and I think textual clearly far surpasses it.
- How to launch? Currently I run tools/perf/python/ilist.py but it would be much nicer if we could do perf ilist much as we do for perf-archive.sh. There are probably other scripts that should be perf commands like flamegraph and gecko. It'd be nice to follow up the series with something to make using these commands easy.
- Additional thoughts were captured on the mailing list:
https://lore.kernel.org/lkml/CAP-5=fWC+doaVd5rEMWJXSQi_db_Wu2tyAe5Lm6jnQjcwXkF+w@mail.gmail.com/
[1] https://textual.textualize.io/
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 (15):
perf hwmon_pmu: Avoid shortening hwmon PMU name
perf parse-events: Minor tidy up of event_type helper
perf python: In str(evsel) use the evsel__pmu_name helper perf python: Fix thread check in pyrf_evsel__read
perf python: Correct pyrf_evsel__read for tool PMUs
perf python: Add basic PMU abstraction and pmus sequence perf python: Add function returning dictionary of all events on a PMU perf jevents: If the long_desc and desc are identical then drop the
long_desc
perf jevents: Add common software event json
perf pmu: Tolerate failure to read the type for wellknown PMUs 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 ilist: Add new python ilist command
tools/perf/builtin-list.c | 47 ++- .../arch/common/common/software.json | 92 +++++ tools/perf/pmu-events/empty-pmu-events.c | 266 ++++++++----- tools/perf/pmu-events/jevents.py | 18 +- tools/perf/python/ilist.py | 376 ++++++++++++++++++ tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +- tools/perf/util/hwmon_pmu.c | 2 +- tools/perf/util/parse-events.c | 225 ++++------- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.l | 38 +- tools/perf/util/parse-events.y | 29 +- tools/perf/util/pmu.c | 44 +- tools/perf/util/print-events.c | 95 ----- tools/perf/util/print-events.h | 1 - tools/perf/util/python.c | 248 +++++++++++- tools/perf/util/tp_pmu.c | 209 ++++++++++ tools/perf/util/tp_pmu.h | 19 + 18 files changed, 1282 insertions(+), 452 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
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 1/15 perf hwmon_pmu: Avoid shortening hwmon PMU name
Long names like ucsi_source_psy_USBC000:001 when prefixed with hwmon_ exceed the buffer size and the last digit is lost. This causes confusion with similar names like ucsi_source_psy_USBC000:002. Extend the buffer size to avoid this.
--- tools/perf/util/hwmon_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/hwmon_pmu.c +1 -1
@@ -344,7 +344,7 @@ static int hwmon_pmu__read_events(struct hwmon_pmu *pmu)struct perf_pmu *hwmon_pmu__new (struct list_head *pmus,int hwmon_dir,const char *sysfs_name,const char *name) { -char buf[32 ]; +char buf[64 ];struct hwmon_pmu *hwm;__u32 type =PERF_PMU_TYPE_HWMON_START +strtoul (sysfs_name +5 ,NULL ,10 );
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 2/15 perf parse-events: Minor tidy up of event_type helper
In reply to Ian RogersAdd missing breakpoint and raw types. Avoid a switch, just use a lookup array. Switch the type to unsigned to avoid checking negative values.
--- tools/perf/util/parse-events.c | 31 +++++++++++++------------------ tools/perf/util/parse-events.h | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-)
tools/perf/util/parse-events.c +13 -18
@@ -135,26 +135,21 @@ const struct event_symbol event_symbols_sw[PERF_COUNT_SW_MAX] = { }, }; -const char *event_type (int type) -{ -switch (type) { -case PERF_TYPE_HARDWARE : -return "hardware" ; - -case PERF_TYPE_SOFTWARE : -return "software" ; - -case PERF_TYPE_TRACEPOINT : -return "tracepoint" ; - -case PERF_TYPE_HW_CACHE : -return "hardware-cache" ; +static const char *const event_types[] = { + [PERF_TYPE_HARDWARE ] ="hardware" , + [PERF_TYPE_SOFTWARE ] ="software" , + [PERF_TYPE_TRACEPOINT ] ="tracepoint" , + [PERF_TYPE_HW_CACHE ] ="hardware-cache" , + [PERF_TYPE_RAW ] ="raw" , + [PERF_TYPE_BREAKPOINT ] ="breakpoint" , +}; -default : -break ; - } +const char *event_type (size_t type) +{ +if (type >=PERF_TYPE_MAX ) +return "unknown" ; -return "unknown" ; +return event_types[type]; } static char *get_config_str(const struct parse_events_terms *head_terms,
tools/perf/util/parse-events.h +1 -1
@@ -21,7 +21,7 @@ struct option;struct perf_pmu ;struct strbuf ; -const char *event_type (int type); +const char *event_type (size_t type);/* Arguments encoded in opt->value. */ struct parse_events_option_args {
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 3/15 perf python: In str(evsel) use the evsel__pmu_name helper
In reply to Ian RogersThe evsel__pmu_name helper will internally use evsel__find_pmu that handles legacy events, extended types, etc. in determining a PMU and will provide a better value than just trying to access the PMU's name directly as the PMU may not have been computed.
--- tools/perf/util/python.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/perf/util/python.c +1 -4
@@ -924,10 +924,7 @@ static PyObject *pyrf_evsel__str(PyObject *self)struct pyrf_evsel *pevsel = (void *)self;struct evsel *evsel = &pevsel->evsel; -if (!evsel->pmu) -return PyUnicode_FromFormat ("evsel(%s)" ,evsel__name (evsel)); - -return PyUnicode_FromFormat ("evsel(%s/%s/)" , evsel->pmu->name,evsel__name (evsel)); +return PyUnicode_FromFormat ("evsel(%s/%s/)" ,evsel__pmu_name (evsel),evsel__name (evsel)); }static PyMethodDef pyrf_evsel__methods[] = {
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 4/15 perf python: Fix thread check in pyrf_evsel__read
In reply to Ian RogersThe CPU index is incorrectly checked rather than the thread index.
--- tools/perf/util/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/python.c +1 -1
@@ -909,7 +909,7 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,return NULL ; } thread_idx =perf_thread_map__idx (evsel->core.threads, thread); -if (cpu_idx <0 ) { +if (thread_idx <0 ) {PyErr_Format (PyExc_TypeError,"Thread %d is not part of evsel's threads" , thread);return NULL ;
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 5/15 perf python: Correct pyrf_evsel__read for tool PMUs
In reply to Ian RogersTool PMUs assume that stat's process_counter_values is being used to read the counters. Specifically they hold onto old values in evsel->prev_raw_counts and give the cumulative count based off of this value. Update pyrf_evsel__read to allocate counts and prev_raw_counts, use evsel__read_counter rather than perf_evsel__read so tool PMUs are read from not just perf_event_open events, make the returned pyrf_counts_values contain the delta value rather than the cumulative value.
--- tools/perf/util/python.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
tools/perf/util/python.c +31 -3
@@ -10,6 +10,7 @@#endif #include <perf/mmap.h> #include "callchain.h" +#include "counts.h" #include "evlist.h" #include "evsel.h" #include "event.h"
@@ -893,7 +894,7 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel, {struct evsel *evsel = &pevsel->evsel;int cpu =0 , cpu_idx, thread =0 , thread_idx; -struct perf_counts_values counts; +struct perf_counts_values *old_count, *new_count; struct pyrf_counts_values *count_values = PyObject_New(struct pyrf_counts_values, &pyrf_counts_values__type);
@@ -914,8 +915,35 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel, thread);return NULL ; } -perf_evsel__read (&(evsel->core), cpu_idx, thread_idx, &counts); - count_values->values = counts; + +/* +* Ensure evsel's counts and prev_raw_counts are allocated, the latter +* used by tool PMUs to compute the cumulative count as expected by +* stat's process_counter_values. +*/ +if (evsel->counts ==NULL ) { +int nthreads =perf_thread_map__nr (evsel->core.threads); +int ncpus =perf_cpu_map__nr (evsel->core.cpus); + + evsel->counts =perf_counts__new (ncpus, nthreads); +if (evsel->counts ==NULL ) +return NULL ; + evsel->prev_raw_counts =perf_counts__new (ncpus, nthreads); +if (evsel->prev_raw_counts ==NULL ) +return NULL ; + } +/* Set up pointers to the old and newly read counter values. */ + old_count =perf_counts (evsel->prev_raw_counts, cpu_idx, thread_idx); + new_count =perf_counts (evsel->counts, cpu_idx, thread_idx); +/* Update the value in evsel->counts. */ +evsel__read_counter (evsel, cpu_idx, thread_idx); +/* Copy the value and turn it into the delta from old_count. */ + count_values->values = *new_count; + count_values->values.val -= old_count->val; + count_values->values.ena -= old_count->ena; + count_values->values.run -= old_count->run; +/* Save the new count over the old_count for the next read. */ + *old_count = *new_count;return (PyObject *)count_values; }
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 6/15 perf python: Add basic PMU abstraction and pmus sequence
In reply to Ian RogersAdd an ability to iterate over PMUs and a basic PMU type then can just show the PMU's name.
An example usage:
``` $ python Python 3.12.9 (main, Feb 5 2025, 01:31:18) [GCC 14.2.0] on linux >>> import perf >>> list(perf.pmus()) [pmu(cpu), pmu(breakpoint), pmu(cstate_core), pmu(cstate_pkg), pmu(hwmon_acpitz), pmu(hwmon_ac), pmu(hwmon_bat0), pmu(hwmon_coretemp), pmu(hwmon_iwlwifi_1), pmu(hwmon_nvme), pmu(hwmon_thinkpad), pmu(hwmon_ucsi_source_psy_usbc000_0), pmu(hwmon_ucsi_source_psy_usbc000_0), pmu(i915), pmu(intel_bts), pmu(intel_pt), pmu(kprobe), pmu(msr), pmu(power), pmu(software), pmu(tool), pmu(tracepoint), pmu(uncore_arb), pmu(uncore_cbox_0), pmu(uncore_cbox_1), pmu(uncore_cbox_2), pmu(uncore_cbox_3), pmu(uncore_cbox_4), pmu(uncore_cbox_5), pmu(uncore_cbox_6), pmu(uncore_cbox_7), pmu(uncore_clock), pmu(uncore_imc_free_running_0), pmu(uncore_imc_free_running_1), pmu(uprobe)] ```
--- tools/perf/util/python.c | 140 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+)
tools/perf/util/python.c +140 -0
@@ -627,6 +627,138 @@ static int pyrf_thread_map__setup_types(void)return PyType_Ready (&pyrf_thread_map__type); } +/** +* A python wrapper for perf_pmus that are globally owned by the pmus.c code. +*/ +struct pyrf_pmu { +PyObject_HEAD + + struct perf_pmu *pmu; +}; + +static void pyrf_pmu__delete (struct pyrf_pmu *ppmu) +{ +Py_TYPE (ppmu)->tp_free ((PyObject *)ppmu); +} + +static PyObject *pyrf_pmu__name (PyObject *self) +{ +struct pyrf_pmu *ppmu = (void *)self; + +return PyUnicode_FromString (ppmu->pmu->name); +} + +static PyObject *pyrf_pmu__repr (PyObject *self) +{ +struct pyrf_pmu *ppmu = (void *)self; + +return PyUnicode_FromFormat ("pmu(%s)" , ppmu->pmu->name); +} + +static const char pyrf_pmu__doc[] =PyDoc_STR ("perf Performance Monitoring Unit (PMU) object." ); + +static PyMethodDef pyrf_pmu__methods[] = { + { + .ml_name ="name" , + .ml_meth = (PyCFunction )pyrf_pmu__name, + .ml_flags =METH_NOARGS , + .ml_doc =PyDoc_STR ("Name of the PMU including suffixes." ) + }, + { .ml_name =NULL , } +}; + +/** The python type for a perf.pmu. */ +static PyTypeObject pyrf_pmu__type = { +PyVarObject_HEAD_INIT (NULL ,0 ) + .tp_name ="perf.pmu" , + .tp_basicsize =sizeof (struct pyrf_pmu ), + .tp_dealloc = (destructor )pyrf_pmu__delete, + .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, + .tp_doc = pyrf_pmu__doc, + .tp_methods = pyrf_pmu__methods, + .tp_str = pyrf_pmu__name, + .tp_repr = pyrf_pmu__repr, +}; + +static int pyrf_pmu__setup_types (void ) +{ + pyrf_pmu__type.tp_new = PyType_GenericNew; +return PyType_Ready (&pyrf_pmu__type); +} + + +/** A python iterator for pmus that has no equivalent in the C code. */ +struct pyrf_pmu_iterator { +PyObject_HEAD + struct perf_pmu *pmu; +}; + +static void pyrf_pmu_iterator__dealloc (struct pyrf_pmu_iterator *self) +{ +Py_TYPE (self)->tp_free ((PyObject *) self); +} + +static PyObject *pyrf_pmu_iterator__new (PyTypeObject *type,PyObject *args__maybe_unused , +PyObject *kwds__maybe_unused ) +{ +struct pyrf_pmu_iterator *itr = (void *)type->tp_alloc (type,0 ); + +if (itr !=NULL ) + itr->pmu =perf_pmus__scan (/*pmu=*/ NULL ); + +return (PyObject *) itr; +} + +static PyObject *pyrf_pmu_iterator__iter (PyObject *self) +{ +Py_INCREF (self); +return self; +} + +static PyObject *pyrf_pmu_iterator__iternext (PyObject *self) +{ +struct pyrf_pmu_iterator *itr = (void *)self; +struct pyrf_pmu *ppmu; + +if (itr->pmu ==NULL ) { +PyErr_SetNone (PyExc_StopIteration); +return NULL ; + } +// Create object to return. + ppmu = PyObject_New(struct pyrf_pmu, &pyrf_pmu__type); +if (ppmu) { + ppmu->pmu = itr->pmu; +// Advance iterator. + itr->pmu =perf_pmus__scan (itr->pmu); + } +return (PyObject *)ppmu; +} + +/** The python type for the PMU iterator. */ +static PyTypeObject pyrf_pmu_iterator__type = { +PyVarObject_HEAD_INIT (NULL ,0 ) + .tp_name ="pmus.iterator" , + .tp_doc ="Iterator for the pmus string sequence." , + .tp_basicsize =sizeof (struct pyrf_pmu_iterator ), + .tp_itemsize =0 , + .tp_flags = Py_TPFLAGS_DEFAULT, + .tp_new = pyrf_pmu_iterator__new, + .tp_dealloc = (destructor ) pyrf_pmu_iterator__dealloc, + .tp_iter = pyrf_pmu_iterator__iter, + .tp_iternext = pyrf_pmu_iterator__iternext, +}; + +static int pyrf_pmu_iterator__setup_types (void ) +{ +return PyType_Ready (&pyrf_pmu_iterator__type); +} + +static PyObject *pyrf__pmus (PyObject *self,PyObject *args) +{ +// Calling the class creates an instance of the iterator. +return PyObject_CallObject ((PyObject *) &pyrf_pmu_iterator__type,/*args=*/ NULL ); +} +struct pyrf_counts_values {PyObject_HEAD
@@ -1613,6 +1745,12 @@ static PyMethodDef perf__methods[] = { .ml_flags = METH_VARARGS, .ml_doc = PyDoc_STR("Parse a string of events and return an evlist.") }, + { + .ml_name = "pmus", + .ml_meth = (PyCFunction) pyrf__pmus, + .ml_flags = METH_NOARGS, + .ml_doc = PyDoc_STR("Returns a sequence of pmus.") + }, { .ml_name = NULL, } };
@@ -1640,6 +1778,8 @@ PyMODINIT_FUNC PyInit_perf(void)pyrf_evsel__setup_types () <0 ||pyrf_thread_map__setup_types () <0 ||pyrf_cpu_map__setup_types () <0 || +pyrf_pmu_iterator__setup_types () <0 || +pyrf_pmu__setup_types () <0 || pyrf_counts_values__setup_types() < 0) return module;
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 7/15 perf python: Add function returning dictionary of all events on a PMU
In reply to Ian RogersAllow all events on a PMU to be gathered, similar to how perf list gathers event information.
An example usage:
```
$ python
Python 3.12.9 (main, Feb 5 2025, 01:31:18) [GCC 14.2.0] on linux
>>> import perf
>>> for pmu in perf.pmus():
... print(pmu.events())
...
[{'name': 'mem_load_retired.l3_hit', 'desc': 'Retired load instructions...
```--- tools/perf/util/python.c | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
tools/perf/util/python.c +67 -0
@@ -648,6 +648,67 @@ static PyObject *pyrf_pmu__name(PyObject *self)return PyUnicode_FromString (ppmu->pmu->name); } +static bool add_to_dict (PyObject *dict,const char *key,const char *value) +{ +PyObject *pkey, *pvalue; +bool ret; + +if (value ==NULL ) +return true; + + pkey =PyUnicode_FromString (key); + pvalue =PyUnicode_FromString (value); + + ret = pkey && pvalue &&PyDict_SetItem (dict, pkey, pvalue) ==0 ; +Py_XDECREF (pkey); +Py_XDECREF (pvalue); +return ret; +} + +static int pyrf_pmu__events_cb (void *state,struct pmu_event_info *info) +{ +PyObject *py_list = state; +PyObject *dict =PyDict_New (); + +if (!dict) +return -ENOMEM ; + +if (!add_to_dict (dict,"name" , info->name) || + !add_to_dict (dict,"alias" , info->alias) || + !add_to_dict (dict,"scale_unit" , info->scale_unit) || + !add_to_dict (dict,"desc" , info->desc) || + !add_to_dict (dict,"long_desc" , info->long_desc) || + !add_to_dict (dict,"encoding_desc" , info->encoding_desc) || + !add_to_dict (dict,"topic" , info->topic) || + !add_to_dict (dict,"event_type_desc" , info->event_type_desc) || + !add_to_dict (dict,"str" , info->str) || + !add_to_dict (dict,"deprecated" , info->deprecated ?"deprecated" :NULL ) || +PyList_Append (py_list, dict) !=0 ) { +Py_DECREF (dict); +return -ENOMEM ; + } +Py_DECREF (dict); +return 0 ; +} + +static PyObject *pyrf_pmu__events (PyObject *self) +{ +struct pyrf_pmu *ppmu = (void *)self; +PyObject *py_list =PyList_New (0 ); + +if (!py_list) +return NULL ; + +if (perf_pmu__for_each_event (ppmu->pmu, +/*skip_duplicate_pmus=*/ false, + py_list, + pyrf_pmu__events_cb) !=0 ) { +Py_DECREF (py_list); +return NULL ; + } +return py_list; +} +static PyObject *pyrf_pmu__repr (PyObject *self) {struct pyrf_pmu *ppmu = (void *)self;
@@ -658,6 +719,12 @@ static PyObject *pyrf_pmu__repr(PyObject *self)static const char pyrf_pmu__doc[] =PyDoc_STR ("perf Performance Monitoring Unit (PMU) object." );static PyMethodDef pyrf_pmu__methods[] = { + { + .ml_name ="events" , + .ml_meth = (PyCFunction )pyrf_pmu__events, + .ml_flags =METH_NOARGS , + .ml_doc =PyDoc_STR ("Name of the PMU including suffixes." ) + }, { .ml_name ="name" , .ml_meth = (PyCFunction )pyrf_pmu__name,
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 8/15 perf jevents: If the long_desc and desc are identical then drop the long_desc
In reply to Ian RogersIf the short and long descriptions are the same then save space and don't store both of them. When storing the desc in the perf_pmu_alias, don't duplicate the desc into the long_desc.
By avoiding storing the duplicate the size of the events string in the binary on x86 is reduced by 29,840 bytes.
--- tools/perf/pmu-events/empty-pmu-events.c | 128 +++++++++++------------ tools/perf/pmu-events/jevents.py | 3 + tools/perf/util/pmu.c | 3 +- 3 files changed, 68 insertions(+), 66 deletions(-)
tools/perf/pmu-events/empty-pmu-events.c +64 -64
@@ -40,38 +40,38 @@ static const char *const big_c_string =/* offset=1475 */ "dispatch_blocked.any\000other\000Memory cluster signals to block micro-op dispatch for any reason\000event=9,period=200000,umask=0x20\000\00000\000\000\000\000\000" /* offset=1608 */ "eist_trans\000other\000Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions\000event=0x3a,period=200000\000\00000\000\000\000\000\000" /* offset=1726 */ "hisi_sccl,ddrc\000" -/* offset=1741 */ "uncore_hisi_ddrc.flux_wcmd\000uncore\000DDRC write commands\000event=2\000\00000\000\000\000\000DDRC write commands\000" -/* offset=1830 */ "uncore_cbox\000" -/* offset=1842 */ "unc_cbo_xsnp_response.miss_eviction\000uncore\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000event=0x22,umask=0x81\000\00000\000\000\000\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000" -/* offset=2076 */ "event-hyphen\000uncore\000UNC_CBO_HYPHEN\000event=0xe0\000\00000\000\000\000\000UNC_CBO_HYPHEN\000" -/* offset=2144 */ "event-two-hyph\000uncore\000UNC_CBO_TWO_HYPH\000event=0xc0\000\00000\000\000\000\000UNC_CBO_TWO_HYPH\000" -/* offset=2218 */ "hisi_sccl,l3c\000" -/* offset=2232 */ "uncore_hisi_l3c.rd_hit_cpipe\000uncore\000Total read hits\000event=7\000\00000\000\000\000\000Total read hits\000" -/* offset=2315 */ "uncore_imc_free_running\000" -/* offset=2339 */ "uncore_imc_free_running.cache_miss\000uncore\000Total cache misses\000event=0x12\000\00000\000\000\000\000Total cache misses\000" -/* offset=2437 */ "uncore_imc\000" -/* offset=2448 */ "uncore_imc.cache_hits\000uncore\000Total cache hits\000event=0x34\000\00000\000\000\000\000Total cache hits\000" -/* offset=2529 */ "uncore_sys_ddr_pmu\000" -/* offset=2548 */ "sys_ddr_pmu.write_cycles\000uncore\000ddr write-cycles event\000event=0x2b\000v8\00000\000\000\000\000\000" -/* offset=2624 */ "uncore_sys_ccn_pmu\000" -/* offset=2643 */ "sys_ccn_pmu.read_cycles\000uncore\000ccn read-cycles event\000config=0x2c\0000x01\00000\000\000\000\000\000" -/* offset=2720 */ "uncore_sys_cmn_pmu\000" -/* offset=2739 */ "sys_cmn_pmu.hnf_cache_miss\000uncore\000Counts total cache misses in first lookup result (high priority)\000eventid=1,type=5\000(434|436|43c|43a).*\00000\000\000\000\000\000" -/* offset=2882 */ "CPI\000\0001 / IPC\000\000\000\000\000\000\000\00000" -/* offset=2904 */ "IPC\000group1\000inst_retired.any / cpu_clk_unhalted.thread\000\000\000\000\000\000\000\00000" -/* offset=2967 */ "Frontend_Bound_SMT\000\000idq_uops_not_delivered.core / (4 * (cpu_clk_unhalted.thread / 2 * (1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk)))\000\000\000\000\000\000\000\00000" -/* offset=3133 */ "dcache_miss_cpi\000\000l1d\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000" -/* offset=3197 */ "icache_miss_cycles\000\000l1i\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000" -/* offset=3264 */ "cache_miss_cycles\000group1\000dcache_miss_cpi + icache_miss_cycles\000\000\000\000\000\000\000\00000" -/* offset=3335 */ "DCache_L2_All_Hits\000\000l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit\000\000\000\000\000\000\000\00000" -/* offset=3429 */ "DCache_L2_All_Miss\000\000max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + l2_rqsts.pf_miss + l2_rqsts.rfo_miss\000\000\000\000\000\000\000\00000" -/* offset=3563 */ "DCache_L2_All\000\000DCache_L2_All_Hits + DCache_L2_All_Miss\000\000\000\000\000\000\000\00000" -/* offset=3627 */ "DCache_L2_Hits\000\000d_ratio(DCache_L2_All_Hits, DCache_L2_All)\000\000\000\000\000\000\000\00000" -/* offset=3695 */ "DCache_L2_Misses\000\000d_ratio(DCache_L2_All_Miss, DCache_L2_All)\000\000\000\000\000\000\000\00000" -/* offset=3765 */ "M1\000\000ipc + M2\000\000\000\000\000\000\000\00000" -/* offset=3787 */ "M2\000\000ipc + M1\000\000\000\000\000\000\000\00000" -/* offset=3809 */ "M3\000\0001 / M3\000\000\000\000\000\000\000\00000" -/* offset=3829 */ "L1D_Cache_Fill_BW\000\00064 * l1d.replacement / 1e9 / duration_time\000\000\000\000\000\000\000\00000" +/* offset=1741 */ "uncore_hisi_ddrc.flux_wcmd\000uncore\000DDRC write commands\000event=2\000\00000\000\000\000\000\000" +/* offset=1811 */ "uncore_cbox\000" +/* offset=1823 */ "unc_cbo_xsnp_response.miss_eviction\000uncore\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000event=0x22,umask=0x81\000\00000\000\000\000\000\000" +/* offset=1977 */ "event-hyphen\000uncore\000UNC_CBO_HYPHEN\000event=0xe0\000\00000\000\000\000\000\000" +/* offset=2031 */ "event-two-hyph\000uncore\000UNC_CBO_TWO_HYPH\000event=0xc0\000\00000\000\000\000\000\000" +/* offset=2089 */ "hisi_sccl,l3c\000" +/* offset=2103 */ "uncore_hisi_l3c.rd_hit_cpipe\000uncore\000Total read hits\000event=7\000\00000\000\000\000\000\000" +/* offset=2171 */ "uncore_imc_free_running\000" +/* offset=2195 */ "uncore_imc_free_running.cache_miss\000uncore\000Total cache misses\000event=0x12\000\00000\000\000\000\000\000" +/* offset=2275 */ "uncore_imc\000" +/* offset=2286 */ "uncore_imc.cache_hits\000uncore\000Total cache hits\000event=0x34\000\00000\000\000\000\000\000" +/* offset=2351 */ "uncore_sys_ddr_pmu\000" +/* offset=2370 */ "sys_ddr_pmu.write_cycles\000uncore\000ddr write-cycles event\000event=0x2b\000v8\00000\000\000\000\000\000" +/* offset=2446 */ "uncore_sys_ccn_pmu\000" +/* offset=2465 */ "sys_ccn_pmu.read_cycles\000uncore\000ccn read-cycles event\000config=0x2c\0000x01\00000\000\000\000\000\000" +/* offset=2542 */ "uncore_sys_cmn_pmu\000" +/* offset=2561 */ "sys_cmn_pmu.hnf_cache_miss\000uncore\000Counts total cache misses in first lookup result (high priority)\000eventid=1,type=5\000(434|436|43c|43a).*\00000\000\000\000\000\000" +/* offset=2704 */ "CPI\000\0001 / IPC\000\000\000\000\000\000\000\00000" +/* offset=2726 */ "IPC\000group1\000inst_retired.any / cpu_clk_unhalted.thread\000\000\000\000\000\000\000\00000" +/* offset=2789 */ "Frontend_Bound_SMT\000\000idq_uops_not_delivered.core / (4 * (cpu_clk_unhalted.thread / 2 * (1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk)))\000\000\000\000\000\000\000\00000" +/* offset=2955 */ "dcache_miss_cpi\000\000l1d\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000" +/* offset=3019 */ "icache_miss_cycles\000\000l1i\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000" +/* offset=3086 */ "cache_miss_cycles\000group1\000dcache_miss_cpi + icache_miss_cycles\000\000\000\000\000\000\000\00000" +/* offset=3157 */ "DCache_L2_All_Hits\000\000l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit\000\000\000\000\000\000\000\00000" +/* offset=3251 */ "DCache_L2_All_Miss\000\000max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + l2_rqsts.pf_miss + l2_rqsts.rfo_miss\000\000\000\000\000\000\000\00000" +/* offset=3385 */ "DCache_L2_All\000\000DCache_L2_All_Hits + DCache_L2_All_Miss\000\000\000\000\000\000\000\00000" +/* offset=3449 */ "DCache_L2_Hits\000\000d_ratio(DCache_L2_All_Hits, DCache_L2_All)\000\000\000\000\000\000\000\00000" +/* offset=3517 */ "DCache_L2_Misses\000\000d_ratio(DCache_L2_All_Miss, DCache_L2_All)\000\000\000\000\000\000\000\00000" +/* offset=3587 */ "M1\000\000ipc + M2\000\000\000\000\000\000\000\00000" +/* offset=3609 */ "M2\000\000ipc + M1\000\000\000\000\000\000\000\00000" +/* offset=3631 */ "M3\000\0001 / M3\000\000\000\000\000\000\000\00000" +/* offset=3651 */ "L1D_Cache_Fill_BW\000\00064 * l1d.replacement / 1e9 / duration_time\000\000\000\000\000\000\000\00000" ;static const struct compact_pmu_event pmu_events__common_tool[] = {
@@ -107,21 +107,21 @@ static const struct compact_pmu_event pmu_events__test_soc_cpu_default_core[] = { 1373 }, /* segment_reg_loads.any\000other\000Number of segment register loads\000event=6,period=200000,umask=0x80\000\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_cpu_hisi_sccl_ddrc[] = { -{1741 },/* uncore_hisi_ddrc.flux_wcmd\000uncore\000DDRC write commands\000event=2\000\00000\000\000\000\000DDRC write commands\000 */ +{1741 },/* uncore_hisi_ddrc.flux_wcmd\000uncore\000DDRC write commands\000event=2\000\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_cpu_hisi_sccl_l3c[] = { -{2232 },/* uncore_hisi_l3c.rd_hit_cpipe\000uncore\000Total read hits\000event=7\000\00000\000\000\000\000Total read hits\000 */ +{2103 },/* uncore_hisi_l3c.rd_hit_cpipe\000uncore\000Total read hits\000event=7\000\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_cpu_uncore_cbox[] = { -{2076 },/* event-hyphen\000uncore\000UNC_CBO_HYPHEN\000event=0xe0\000\00000\000\000\000\000UNC_CBO_HYPHEN\000 */ -{2144 },/* event-two-hyph\000uncore\000UNC_CBO_TWO_HYPH\000event=0xc0\000\00000\000\000\000\000UNC_CBO_TWO_HYPH\000 */ -{1842 },/* unc_cbo_xsnp_response.miss_eviction\000uncore\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000event=0x22,umask=0x81\000\00000\000\000\000\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000 */ +{1977 },/* event-hyphen\000uncore\000UNC_CBO_HYPHEN\000event=0xe0\000\00000\000\000\000\000\000 */ +{2031 },/* event-two-hyph\000uncore\000UNC_CBO_TWO_HYPH\000event=0xc0\000\00000\000\000\000\000\000 */ +{1823 },/* unc_cbo_xsnp_response.miss_eviction\000uncore\000A cross-core snoop resulted from L3 Eviction which misses in some processor core\000event=0x22,umask=0x81\000\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_cpu_uncore_imc[] = { -{2448 },/* uncore_imc.cache_hits\000uncore\000Total cache hits\000event=0x34\000\00000\000\000\000\000Total cache hits\000 */ +{2286 },/* uncore_imc.cache_hits\000uncore\000Total cache hits\000event=0x34\000\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_cpu_uncore_imc_free_running[] = { -{2339 },/* uncore_imc_free_running.cache_miss\000uncore\000Total cache misses\000event=0x12\000\00000\000\000\000\000Total cache misses\000 */ +{2195 },/* uncore_imc_free_running.cache_miss\000uncore\000Total cache misses\000event=0x12\000\00000\000\000\000\000\000 */ };
@@ -139,41 +139,41 @@ const struct pmu_table_entry pmu_events__test_soc_cpu[] = { { .entries = pmu_events__test_soc_cpu_hisi_sccl_l3c, .num_entries = ARRAY_SIZE(pmu_events__test_soc_cpu_hisi_sccl_l3c), - .pmu_name = { 2218 /* hisi_sccl,l3c\000 */ }, + .pmu_name = { 2089 /* hisi_sccl,l3c\000 */ }, }, { .entries = pmu_events__test_soc_cpu_uncore_cbox, .num_entries = ARRAY_SIZE(pmu_events__test_soc_cpu_uncore_cbox), - .pmu_name = { 1830 /* uncore_cbox\000 */ }, + .pmu_name = { 1811 /* uncore_cbox\000 */ }, }, { .entries = pmu_events__test_soc_cpu_uncore_imc, .num_entries = ARRAY_SIZE(pmu_events__test_soc_cpu_uncore_imc), - .pmu_name = { 2437 /* uncore_imc\000 */ }, + .pmu_name = { 2275 /* uncore_imc\000 */ }, }, { .entries = pmu_events__test_soc_cpu_uncore_imc_free_running, .num_entries = ARRAY_SIZE(pmu_events__test_soc_cpu_uncore_imc_free_running), - .pmu_name = { 2315 /* uncore_imc_free_running\000 */ }, + .pmu_name = { 2171 /* uncore_imc_free_running\000 */ }, }, }; static const struct compact_pmu_event pmu_metrics__test_soc_cpu_default_core[] = { -{ 2882 }, /* CPI\000\0001 / IPC\000\000\000\000\000\000\000\00000 */ -{ 3563 }, /* DCache_L2_All\000\000DCache_L2_All_Hits + DCache_L2_All_Miss\000\000\000\000\000\000\000\00000 */ -{ 3335 }, /* DCache_L2_All_Hits\000\000l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit\000\000\000\000\000\000\000\00000 */ -{ 3429 }, /* DCache_L2_All_Miss\000\000max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + l2_rqsts.pf_miss + l2_rqsts.rfo_miss\000\000\000\000\000\000\000\00000 */ -{ 3627 }, /* DCache_L2_Hits\000\000d_ratio(DCache_L2_All_Hits, DCache_L2_All)\000\000\000\000\000\000\000\00000 */ -{ 3695 }, /* DCache_L2_Misses\000\000d_ratio(DCache_L2_All_Miss, DCache_L2_All)\000\000\000\000\000\000\000\00000 */ -{ 2967 }, /* Frontend_Bound_SMT\000\000idq_uops_not_delivered.core / (4 * (cpu_clk_unhalted.thread / 2 * (1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk)))\000\000\000\000\000\000\000\00000 */ -{ 2904 }, /* IPC\000group1\000inst_retired.any / cpu_clk_unhalted.thread\000\000\000\000\000\000\000\00000 */ -{ 3829 }, /* L1D_Cache_Fill_BW\000\00064 * l1d.replacement / 1e9 / duration_time\000\000\000\000\000\000\000\00000 */ -{ 3765 }, /* M1\000\000ipc + M2\000\000\000\000\000\000\000\00000 */ -{ 3787 }, /* M2\000\000ipc + M1\000\000\000\000\000\000\000\00000 */ -{ 3809 }, /* M3\000\0001 / M3\000\000\000\000\000\000\000\00000 */ -{ 3264 }, /* cache_miss_cycles\000group1\000dcache_miss_cpi + icache_miss_cycles\000\000\000\000\000\000\000\00000 */ -{ 3133 }, /* dcache_miss_cpi\000\000l1d\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000 */ -{ 3197 }, /* icache_miss_cycles\000\000l1i\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000 */ +{ 2704 }, /* CPI\000\0001 / IPC\000\000\000\000\000\000\000\00000 */ +{ 3385 }, /* DCache_L2_All\000\000DCache_L2_All_Hits + DCache_L2_All_Miss\000\000\000\000\000\000\000\00000 */ +{ 3157 }, /* DCache_L2_All_Hits\000\000l2_rqsts.demand_data_rd_hit + l2_rqsts.pf_hit + l2_rqsts.rfo_hit\000\000\000\000\000\000\000\00000 */ +{ 3251 }, /* DCache_L2_All_Miss\000\000max(l2_rqsts.all_demand_data_rd - l2_rqsts.demand_data_rd_hit, 0) + l2_rqsts.pf_miss + l2_rqsts.rfo_miss\000\000\000\000\000\000\000\00000 */ +{ 3449 }, /* DCache_L2_Hits\000\000d_ratio(DCache_L2_All_Hits, DCache_L2_All)\000\000\000\000\000\000\000\00000 */ +{ 3517 }, /* DCache_L2_Misses\000\000d_ratio(DCache_L2_All_Miss, DCache_L2_All)\000\000\000\000\000\000\000\00000 */ +{ 2789 }, /* Frontend_Bound_SMT\000\000idq_uops_not_delivered.core / (4 * (cpu_clk_unhalted.thread / 2 * (1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk)))\000\000\000\000\000\000\000\00000 */ +{ 2726 }, /* IPC\000group1\000inst_retired.any / cpu_clk_unhalted.thread\000\000\000\000\000\000\000\00000 */ +{ 3651 }, /* L1D_Cache_Fill_BW\000\00064 * l1d.replacement / 1e9 / duration_time\000\000\000\000\000\000\000\00000 */ +{ 3587 }, /* M1\000\000ipc + M2\000\000\000\000\000\000\000\00000 */ +{ 3609 }, /* M2\000\000ipc + M1\000\000\000\000\000\000\000\00000 */ +{ 3631 }, /* M3\000\0001 / M3\000\000\000\000\000\000\000\00000 */ +{ 3086 }, /* cache_miss_cycles\000group1\000dcache_miss_cpi + icache_miss_cycles\000\000\000\000\000\000\000\00000 */ +{ 2955 }, /* dcache_miss_cpi\000\000l1d\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000 */ +{ 3019 }, /* icache_miss_cycles\000\000l1i\\-loads\\-misses / inst_retired.any\000\000\000\000\000\000\000\00000 */ };
@@ -186,13 +186,13 @@ const struct pmu_table_entry pmu_metrics__test_soc_cpu[] = { };static const struct compact_pmu_event pmu_events__test_soc_sys_uncore_sys_ccn_pmu[] = { -{2643 },/* sys_ccn_pmu.read_cycles\000uncore\000ccn read-cycles event\000config=0x2c\0000x01\00000\000\000\000\000\000 */ +{2465 },/* sys_ccn_pmu.read_cycles\000uncore\000ccn read-cycles event\000config=0x2c\0000x01\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_sys_uncore_sys_cmn_pmu[] = { -{2739 },/* sys_cmn_pmu.hnf_cache_miss\000uncore\000Counts total cache misses in first lookup result (high priority)\000eventid=1,type=5\000(434|436|43c|43a).*\00000\000\000\000\000\000 */ +{2561 },/* sys_cmn_pmu.hnf_cache_miss\000uncore\000Counts total cache misses in first lookup result (high priority)\000eventid=1,type=5\000(434|436|43c|43a).*\00000\000\000\000\000\000 */ };static const struct compact_pmu_event pmu_events__test_soc_sys_uncore_sys_ddr_pmu[] = { -{2548 },/* sys_ddr_pmu.write_cycles\000uncore\000ddr write-cycles event\000event=0x2b\000v8\00000\000\000\000\000\000 */ +{2370 },/* sys_ddr_pmu.write_cycles\000uncore\000ddr write-cycles event\000event=0x2b\000v8\00000\000\000\000\000\000 */ };
@@ -200,17 +200,17 @@ const struct pmu_table_entry pmu_events__test_soc_sys[] = { { .entries = pmu_events__test_soc_sys_uncore_sys_ccn_pmu, .num_entries = ARRAY_SIZE(pmu_events__test_soc_sys_uncore_sys_ccn_pmu), - .pmu_name = { 2624 /* uncore_sys_ccn_pmu\000 */ }, + .pmu_name = { 2446 /* uncore_sys_ccn_pmu\000 */ }, }, { .entries = pmu_events__test_soc_sys_uncore_sys_cmn_pmu, .num_entries = ARRAY_SIZE(pmu_events__test_soc_sys_uncore_sys_cmn_pmu), - .pmu_name = { 2720 /* uncore_sys_cmn_pmu\000 */ }, + .pmu_name = { 2542 /* uncore_sys_cmn_pmu\000 */ }, }, { .entries = pmu_events__test_soc_sys_uncore_sys_ddr_pmu, .num_entries = ARRAY_SIZE(pmu_events__test_soc_sys_uncore_sys_ddr_pmu), - .pmu_name = { 2529 /* uncore_sys_ddr_pmu\000 */ }, + .pmu_name = { 2351 /* uncore_sys_ddr_pmu\000 */ }, }, };
tools/perf/pmu-events/jevents.py +3 -0
@@ -397,6 +397,9 @@ class JsonEvent: self.desc += extra_desc if self.long_desc and extra_desc: self.long_desc += extra_desc + if self.desc and self.long_desc and self.desc == self.long_desc: + # Avoid duplicated descriptions. + self.long_desc = None if arch_std: if arch_std.lower() in _arch_std_events: event = _arch_std_events[arch_std.lower()].event
tools/perf/util/pmu.c +1 -2
@@ -623,8 +623,7 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name, alias->name =strdup (name); alias->desc = desc ?strdup (desc) :NULL ; - alias->long_desc = long_desc ?strdup (long_desc) : - desc ?strdup (desc) :NULL ; + alias->long_desc = long_desc ?strdup (long_desc) :NULL ; alias->topic = topic ?strdup (topic) :NULL ; alias->pmu_name = pmu_name ?strdup (pmu_name) :NULL ;if (unit) {
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 9/15 perf jevents: Add common software event json
In reply to Ian RogersAdd json for software events so that in perf list the events can have a description. Common json exists for the tool PMU but it has no sysfs equivalent. Modify the map_for_pmu code to return the common map (rather than an architecture specific one) when a PMU with a common name is being looked for, this allows the events to be found.
--- .../arch/common/common/software.json | 92 ++++++ tools/perf/pmu-events/empty-pmu-events.c | 266 +++++++++++------- tools/perf/pmu-events/jevents.py | 15 +- 3 files changed, 264 insertions(+), 109 deletions(-) create mode 100644 tools/perf/pmu-events/arch/common/common/software.json
tools/perf/pmu-events/arch/common/common/software.json new file +92 -0
@@ -0,0 +1,92 @@ +[ + { + "Unit": "software", + "EventName": "cpu-clock", + "BriefDescription": "Per-CPU high-resolution timer based event", + "ConfigCode": "0" + }, + { + "Unit": "software", + "EventName": "task-clock", + "BriefDescription": "Task based high-resolution timer based event", + "ConfigCode": "1" + }, + { + "Unit": "software", + "EventName": "faults", + "BriefDescription": "Number of page faults [This event is an alias of page-faults]", + "ConfigCode": "2" + }, + { + "Unit": "software", + "EventName": "page-faults", + "BriefDescription": "Number of page faults [This event is an alias of faults]", + "ConfigCode": "2" + }, + { + "Unit": "software", + "EventName": "context-switches", + "BriefDescription": "Number of context switches [This event is an alias of cs]", + "ConfigCode": "3" + }, + { + "Unit": "software", + "EventName": "cs", + "BriefDescription": "Number of context switches [This event is an alias of context-switches]", + "ConfigCode": "3" + }, + { + "Unit": "software", + "EventName": "cpu-migrations", + "BriefDescription": "Number of times a process has migrated to a new CPU [This event is an alias of migrations]", + "ConfigCode": "4" + }, + { + "Unit": "software", + "EventName": "migrations", + "BriefDescription": "Number of times a process has migrated to a new CPU [This event is an alias of cpu-migrations]", + "ConfigCode": "4" + }, + { + "Unit": "software", + "EventName": "minor-faults", + "BriefDescription": "Number of minor page faults. Minor faults don't require I/O to handle", + "ConfigCode": "5" + }, + { + "Unit": "software", + "EventName": "major-faults", + "BriefDescription": "Number of major page faults. Major faults require I/O to handle", + "ConfigCode": "6" + }, + { + "Unit": "software", + "EventName": "alignment-faults", + "BriefDescription": "Number of kernel handled memory alignment faults", + "ConfigCode": "7" + }, + { + "Unit": "software", + "EventName": "emulation-faults", + "BriefDescription": "Number of kernel handled unimplemented instruction faults handled through emulation", + "ConfigCode": "8" + }, + { + "Unit": "software", + "EventName": "dummy", + "BriefDescription": "A placeholder event that doesn't count anything", + "ConfigCode": "9" + }, + { + "Unit": "software", + "EventName": "bpf-output", + "BriefDescription": "An event used by BPF programs to write to the perf ring buffer", + "ConfigCode": "10" + }, + { + "Unit": "software", + "EventName": "cgroup-switches", + "BriefDescription": "Number of context switches to a task in a different cgroup", + "ConfigCode": "11" + } +]
tools/perf/pmu-events/empty-pmu-events.c +158 -108
361 lines not on this page · raw message
tools/perf/pmu-events/jevents.py +14 -1
@@ -295,6 +295,7 @@ class JsonEvent: 'cpu_atom': 'cpu_atom', 'ali_drw': 'ali_drw', 'arm_cmn': 'arm_cmn', + 'software': 'software', 'tool': 'tool', } return table[unit] if unit in table else f'uncore_{unit.lower()}'
@@ -1158,8 +1159,20 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) { struct perf_cpu cpu = {-1}; - if (pmu) + if (pmu) { + for (size_t i=0; i < ARRAY_SIZE(pmu_events__common); i++) { + const char *pmu_name = &big_c_string[pmu_events__common[i].pmu_name.offset]; + + if (!strcmp(pmu_name, pmu->name)) { + const struct pmu_events_map *map = &pmu_events_map[0]; + + while (strcmp("common", map->arch)) + map++; + return map; + } + } cpu = perf_cpu_map__min(pmu->cpus); + } return map_for_cpu(cpu); }
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 10/15 perf pmu: Tolerate failure to read the type for wellknown PMUs
In reply to Ian RogersIf sysfs isn't mounted then we may fail to read a PMU's type. In this situation resort to lookup of wellknown types. Only applies to software, tracepoint and breakpoint PMUs.
--- tools/perf/util/pmu.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
tools/perf/util/pmu.c +32 -2
@@ -1181,6 +1181,32 @@ int perf_pmu__init(struct perf_pmu *pmu, __u32 type, const char *name)return 0 ; } +static __u32 wellknown_pmu_type (const char *pmu_name) +{ +struct { +const char *pmu_name; +__u32 type; + } wellknown_pmus[] = { + { +"software" , +PERF_TYPE_SOFTWARE + }, + { +"tracepoint" , +PERF_TYPE_TRACEPOINT + }, + { +"breakpoint" , +PERF_TYPE_BREAKPOINT + }, + }; +for (size_t i =0 ; i <ARRAY_SIZE (wellknown_pmus); i++) { +if (!strcmp (wellknown_pmus[i].pmu_name, pmu_name)) +return wellknown_pmus[i].type; + } +return PERF_TYPE_MAX ; +} +struct perf_pmu *perf_pmu__lookup (struct list_head *pmus,int dirfd,const char *name,bool eager_load) {
@@ -1200,8 +1226,12 @@ struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char* that type value is successfully assigned (return 1). */ if (perf_pmu__scan_file_at (pmu, dirfd,"type" ,"%u" , &pmu->type) !=1 ) { -perf_pmu__delete (pmu); -return NULL ; +/* Double check the PMU's name isn't wellknown. */ + pmu->type =wellknown_pmu_type (name); +if (pmu->type ==PERF_TYPE_MAX ) { +perf_pmu__delete (pmu); +return NULL ; + } }/*
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 11/15 perf parse-events: Remove non-json software events
In reply to Ian RogersRemove the hard coded encodings from parse-events. This has the consequence that software events are matched using the sysfs/json priority, will be case insensitive and will be wildcarded across PMUs. As there were software and hardware types in the parsing code, the removal means software vs hardware logic can be removed and hardware assumed.
Now the perf json provides detailed descriptions of software events, remove the previous listing support that didn't contain event descriptions. When globbing is required for the "sw" option in perf list, use string PMU globbing as was done previously for the tool PMU.
--- tools/perf/builtin-list.c | 19 ++++++------- tools/perf/util/parse-events.c | 51 ---------------------------------- tools/perf/util/parse-events.h | 1 - tools/perf/util/parse-events.l | 38 +++++++++---------------- tools/perf/util/parse-events.y | 29 ++++++++----------- tools/perf/util/print-events.c | 2 -- 6 files changed, 33 insertions(+), 107 deletions(-)
tools/perf/builtin-list.c +9 -10
@@ -623,16 +623,17 @@ int cmd_list(int argc, const char **argv)else if (strcmp (argv[i],"sw" ) ==0 ||strcmp (argv[i],"software" ) ==0 ) {char *old_pmu_glob = default_ps.pmu_glob; +static const char *const sw_globs[] = {"software" ,"tool" }; -print_symbol_events (&print_cb, ps,PERF_TYPE_SOFTWARE , - event_symbols_sw,PERF_COUNT_SW_MAX ); - default_ps.pmu_glob =strdup ("tool" ); -if (!default_ps.pmu_glob) { - ret =-1 ; - goto out; +for (size_t j =0 ; j <ARRAY_SIZE (sw_globs); j++) { + default_ps.pmu_glob =strdup (sw_globs[j]); +if (!default_ps.pmu_glob) { + ret =-1 ; + goto out; + } +perf_pmus__print_pmu_events (&print_cb, ps); +zfree (&default_ps.pmu_glob); } -perf_pmus__print_pmu_events (&print_cb, ps); -zfree (&default_ps.pmu_glob); default_ps.pmu_glob = old_pmu_glob; }else if (strcmp (argv[i],"cache" ) ==0 ||strcmp (argv[i],"hwcache" ) ==0 )
@@ -679,8 +680,6 @@ int cmd_list(int argc, const char **argv) default_ps.event_glob = s;print_symbol_events (&print_cb, ps,PERF_TYPE_HARDWARE , event_symbols_hw,PERF_COUNT_HW_MAX ); -print_symbol_events (&print_cb, ps,PERF_TYPE_SOFTWARE , - event_symbols_sw,PERF_COUNT_SW_MAX );print_hwcache_events (&print_cb, ps);perf_pmus__print_pmu_events (&print_cb, ps);print_tracepoint_events (&print_cb, ps);
tools/perf/util/parse-events.c +0 -51
57 lines not on this page · raw message
tools/perf/util/parse-events.h +0 -1
@@ -264,7 +264,6 @@ struct event_symbol {const char *alias; };extern const struct event_symbol event_symbols_hw[]; -extern const struct event_symbol event_symbols_sw[];char *parse_events_formats_error_string (char *additional_terms);
tools/perf/util/parse-events.l +13 -25
@@ -117,12 +117,12 @@ do { \ yyless(0); \ } while (0) -static int sym(yyscan_t scanner, int type, int config) +static int sym(yyscan_t scanner, int config) { YYSTYPE *yylval = parse_events_get_lval(scanner); - yylval->num = (type << 16) + config; - return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW; + yylval->num = config; + return PE_VALUE_SYM_HW; } static int term(yyscan_t scanner, enum parse_events__term_type type)
@@ -391,28 +391,16 @@ r0x{num_raw_hex} { return str(yyscanner, PE_RAW); } <<EOF>> { BEGIN(INITIAL); } } -cpu-cycles|cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); } -stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } -stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } -instructions { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); } -cache-references { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); } -cache-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); } -branch-instructions|branches { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } -branch-misses { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); } -bus-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); } -ref-cycles { return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); } -cpu-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); } -task-clock { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); } -page-faults|faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); } -minor-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); } -major-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); } -context-switches|cs { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); } -cpu-migrations|migrations { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); } -alignment-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); } -emulation-faults { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); } -dummy { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); } -bpf-output { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); } -cgroup-switches { return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CGROUP_SWITCHES); } +cpu-cycles|cycles { return sym(yyscanner, PERF_COUNT_HW_CPU_CYCLES); } +stalled-cycles-frontend|idle-cycles-frontend { return sym(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); } +stalled-cycles-backend|idle-cycles-backend { return sym(yyscanner, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); } +instructions { return sym(yyscanner, PERF_COUNT_HW_INSTRUCTIONS); } +cache-references { return sym(yyscanner, PERF_COUNT_HW_CACHE_REFERENCES); } +cache-misses { return sym(yyscanner, PERF_COUNT_HW_CACHE_MISSES); } +branch-instructions|branches { return sym(yyscanner, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); } +branch-misses { return sym(yyscanner, PERF_COUNT_HW_BRANCH_MISSES); } +bus-cycles { return sym(yyscanner, PERF_COUNT_HW_BUS_CYCLES); } +ref-cycles { return sym(yyscanner, PERF_COUNT_HW_REF_CPU_CYCLES); } {lc_type} { return str(yyscanner, PE_LEGACY_CACHE); } {lc_type}-{lc_op_result} { return str(yyscanner, PE_LEGACY_CACHE); }
tools/perf/util/parse-events.y +11 -18
@@ -55,7 +55,7 @@ static void free_list_evsel(struct list_head* list_evsel) %} %token PE_START_EVENTS PE_START_TERMS -%token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_TERM +%token PE_VALUE PE_VALUE_SYM_HW PE_TERM %token PE_EVENT_NAME %token PE_RAW PE_NAME %token PE_MODIFIER_EVENT PE_MODIFIER_BP PE_BP_COLON PE_BP_SLASH
@@ -66,10 +66,8 @@ static void free_list_evsel(struct list_head* list_evsel) %token PE_TERM_HW %type <num> PE_VALUE %type <num> PE_VALUE_SYM_HW -%type <num> PE_VALUE_SYM_SW %type <mod> PE_MODIFIER_EVENT %type <term_type> PE_TERM -%type <num> value_sym %type <str> PE_RAW %type <str> PE_NAME %type <str> PE_LEGACY_CACHE
@@ -306,24 +304,19 @@ PE_NAME sep_dc $$ = list; } -value_sym: -PE_VALUE_SYM_HW -| -PE_VALUE_SYM_SW - event_legacy_symbol: -value_sym '/' event_config '/' +PE_VALUE_SYM_HW '/' event_config '/' { struct list_head *list; - int type = $1 >> 16; - int config = $1 & 255; int err; - bool wildcard = (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE); list = alloc_list(); if (!list) YYNOMEM; - err = parse_events_add_numeric(_parse_state, list, type, config, $3, wildcard); + err = parse_events_add_numeric(_parse_state, list, + PERF_TYPE_HARDWARE, $1, + $3, + /*wildcard=*/true); parse_events_terms__delete($3); if (err) { free_list_evsel(list);
@@ -332,18 +325,18 @@ value_sym '/' event_config '/' $$ = list; } | -value_sym sep_slash_slash_dc +PE_VALUE_SYM_HW sep_slash_slash_dc { struct list_head *list; - int type = $1 >> 16; - int config = $1 & 255; - bool wildcard = (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE); int err; list = alloc_list(); if (!list) YYNOMEM; - err = parse_events_add_numeric(_parse_state, list, type, config, /*head_config=*/NULL, wildcard); + err = parse_events_add_numeric(_parse_state, list, + PERF_TYPE_HARDWARE, $1, + /*head_config=*/NULL, + /*wildcard=*/true); if (err) PE_ABORT(err); $$ = list;
tools/perf/util/print-events.c +0 -2
@@ -388,8 +388,6 @@ void print_events(const struct print_callbacks *print_cb, void *print_state) {print_symbol_events (print_cb, print_state,PERF_TYPE_HARDWARE , event_symbols_hw,PERF_COUNT_HW_MAX ); -print_symbol_events (print_cb, print_state,PERF_TYPE_SOFTWARE , - event_symbols_sw,PERF_COUNT_SW_MAX );print_hwcache_events (print_cb, print_state);
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 12/15 perf tp_pmu: Factor existing tracepoint logic to new file
In reply to Ian RogersStart the creation of a tracepoint PMU abstraction. Tracepoint events don't follow the regular sysfs perf conventions. Eventually the new PMU abstraction will bridge the gap so tracepoint events look more like regular perf ones.
--- tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +---- tools/perf/util/parse-events.c | 147 ++++++++++++++------------------- tools/perf/util/tp_pmu.c | 95 +++++++++++++++++++++ tools/perf/util/tp_pmu.h | 12 +++ 5 files changed, 170 insertions(+), 106 deletions(-) create mode 100644 tools/perf/util/tp_pmu.c create mode 100644 tools/perf/util/tp_pmu.h
tools/perf/util/Build +1 -0
@@ -88,6 +88,7 @@ perf-util-y += pmu-bison.o perf-util-y += drm_pmu.o perf-util-y += hwmon_pmu.o perf-util-y += tool_pmu.o +perf-util-y += tp_pmu.o perf-util-y += svghelper.o perf-util-y += trace-event-info.o perf-util-y += trace-event-scripting.o
tools/perf/util/evsel.c +2 -19
@@ -59,6 +59,7 @@#include "drm_pmu.h" #include "hwmon_pmu.h" #include "tool_pmu.h" +#include "tp_pmu.h" #include "rlimit.h" #include "../perf-sys.h" #include "util/parse-branch-options.h"
@@ -571,24 +572,6 @@ struct evsel *evsel__clone(struct evsel *dest, struct evsel *orig)return NULL ; } -static int trace_event__id (const char *sys,const char *name) -{ -char *tp_dir =get_events_file (sys); -char path[PATH_MAX ]; -int id, err; - -if (!tp_dir) -return -1 ; - -scnprintf (path,PATH_MAX ,"%s/%s/id" , tp_dir, name); -put_events_file (tp_dir); - err =filename__read_int (path, &id); -if (err) -return err; - -return id; -} -/* * Returns pointer with encoded error via <linux/err.h> interface. */
@@ -622,7 +605,7 @@ struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx, boolevent_attr_init (&attr);if (format) { - id =trace_event__id (sys, name); + id =tp_pmu__id (sys, name);if (id <0 ) { err = id; goto out_free;
tools/perf/util/parse-events.c +60 -87
196 lines not on this page · raw message
tools/perf/util/tp_pmu.c new file +95 -0
95 lines not on this page · raw message
tools/perf/util/tp_pmu.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ +#ifndef __TP_PMU_H +#define __TP_PMU_H + +typedef int (*tp_sys_callback )(void *state,const char *sys_name); +typedef int (*tp_event_callback )(void *state,const char *sys_name,const char *evt_name); + +int tp_pmu__id (const char *sys,const char *name); +int tp_pmu__for_each_tp_event (const char *sys,void *state,tp_event_callback cb); +int tp_pmu__for_each_tp_sys (void *state,tp_sys_callback cb); + +#endif /* __TP_PMU_H */
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 13/15 perf tp_pmu: Add event APIs
In reply to Ian RogersAdd event APIs for the tracepoint PMU allowing things like perf list to function using it. For perf list add the tracepoint format in the long description (shown with -v).
--- tools/perf/util/pmu.c | 7 +++ tools/perf/util/tp_pmu.c | 114 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/tp_pmu.h | 7 +++ 3 files changed, 128 insertions(+)
tools/perf/util/pmu.c +7 -0
@@ -24,6 +24,7 @@#include "hwmon_pmu.h" #include "pmus.h" #include "tool_pmu.h" +#include "tp_pmu.h" #include <util/pmu-bison.h> #include <util/pmu-flex.h> #include "parse-events.h"
@@ -1983,6 +1984,8 @@ bool perf_pmu__have_event(struct perf_pmu *pmu, const char *name)return false;if (perf_pmu__is_tool (pmu) &&tool_pmu__skip_event (name))return false; +if (perf_pmu__is_tracepoint (pmu)) +return tp_pmu__have_event (pmu, name);if (perf_pmu__is_hwmon (pmu))return hwmon_pmu__have_event (pmu, name);if (perf_pmu__is_drm (pmu))
@@ -1998,6 +2001,8 @@ size_t perf_pmu__num_events(struct perf_pmu *pmu) {size_t nr; +if (perf_pmu__is_tracepoint (pmu)) +return tp_pmu__num_events (pmu);if (perf_pmu__is_hwmon (pmu))return hwmon_pmu__num_events (pmu);if (perf_pmu__is_drm (pmu))
@@ -2068,6 +2073,8 @@ int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus,struct hashmap_entry *entry;size_t bkt; +if (perf_pmu__is_tracepoint (pmu)) +return tp_pmu__for_each_event (pmu, state, cb);if (perf_pmu__is_hwmon (pmu))return hwmon_pmu__for_each_event (pmu, state, cb);if (perf_pmu__is_drm (pmu))
tools/perf/util/tp_pmu.c +114 -0
122 lines not on this page · raw message
tools/perf/util/tp_pmu.h +7 -0
@@ -2,6 +2,8 @@#ifndef __TP_PMU_H#define __TP_PMU_H +#include "pmu.h" +typedef int (*tp_sys_callback )(void *state,const char *sys_name);typedef int (*tp_event_callback )(void *state,const char *sys_name,const char *evt_name);
@@ -9,4 +11,9 @@ int tp_pmu__id(const char *sys, const char *name);int tp_pmu__for_each_tp_event (const char *sys,void *state,tp_event_callback cb);int tp_pmu__for_each_tp_sys (void *state,tp_sys_callback cb); +bool perf_pmu__is_tracepoint (const struct perf_pmu *pmu); +int tp_pmu__for_each_event (struct perf_pmu *pmu,void *state,pmu_event_callback cb); +size_t tp_pmu__num_events (struct perf_pmu *pmu); +bool tp_pmu__have_event (struct perf_pmu *pmu,const char *name); +#endif /* __TP_PMU_H */
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 14/15 perf list: Remove tracepoint printing code
In reply to Ian RogersNow that the tp_pmu can iterate and describe events remove the custom tracepoint printing logic, this avoids perf list showing the tracepoint events twice.
--- tools/perf/builtin-list.c | 28 +++++++--- tools/perf/util/print-events.c | 93 ---------------------------------- tools/perf/util/print-events.h | 1 - 3 files changed, 22 insertions(+), 100 deletions(-)
tools/perf/builtin-list.c +22 -6
@@ -614,9 +614,18 @@ int cmd_list(int argc, const char **argv)for (i =0 ; i < argc; ++i) {char *sep, *s; -if (strcmp (argv[i],"tracepoint" ) ==0 ) -print_tracepoint_events (&print_cb, ps); -else if (strcmp (argv[i],"hw" ) ==0 || +if (strcmp (argv[i],"tracepoint" ) ==0 ) { +char *old_pmu_glob = default_ps.pmu_glob; + + default_ps.pmu_glob =strdup ("tracepoint" ); +if (!default_ps.pmu_glob) { + ret =-1 ; + goto out; + } +perf_pmus__print_pmu_events (&print_cb, ps); +zfree (&default_ps.pmu_glob); + default_ps.pmu_glob = old_pmu_glob; + }else if (strcmp (argv[i],"hw" ) ==0 ||strcmp (argv[i],"hardware" ) ==0 )print_symbol_events (&print_cb, ps,PERF_TYPE_HARDWARE , event_symbols_hw,PERF_COUNT_HW_MAX );
@@ -658,6 +667,7 @@ int cmd_list(int argc, const char **argv)#endif else if ((sep = strchr(argv[i], ':')) != NULL) { char *old_pmu_glob = default_ps.pmu_glob; +char *old_event_glob = default_ps.event_glob; default_ps.event_glob =strdup (argv[i]);if (!default_ps.event_glob) {
@@ -665,13 +675,20 @@ int cmd_list(int argc, const char **argv) goto out; } -print_tracepoint_events (&print_cb, ps); + default_ps.pmu_glob =strdup ("tracepoint" ); +if (!default_ps.pmu_glob) { +zfree (&default_ps.event_glob); + ret =-1 ; + goto out; + } +perf_pmus__print_pmu_events (&print_cb, ps); + default_ps.pmu_glob = old_pmu_glob;print_sdt_events (&print_cb, ps); default_ps.metrics = true; default_ps.metricgroups = true;metricgroup__print (&print_cb, ps);zfree (&default_ps.event_glob); - default_ps.pmu_glob = old_pmu_glob; + default_ps.event_glob = old_event_glob; }else {if (asprintf (&s,"*%s*" , argv[i]) <0 ) {printf ("Critical: Not enough memory! Trying to continue...\n" );
@@ -682,7 +699,6 @@ int cmd_list(int argc, const char **argv) event_symbols_hw, PERF_COUNT_HW_MAX);print_hwcache_events (&print_cb, ps);perf_pmus__print_pmu_events (&print_cb, ps); -print_tracepoint_events (&print_cb, ps);print_sdt_events (&print_cb, ps); default_ps.metrics = true; default_ps.metricgroups = true;
tools/perf/util/print-events.c +0 -93
105 lines not on this page · raw message
tools/perf/util/print-events.h +0 -1
@@ -37,7 +37,6 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)void print_symbol_events (const struct print_callbacks *print_cb,void *print_state,unsigned int type,const struct event_symbol *syms,unsigned int max); -void print_tracepoint_events (const struct print_callbacks *print_cb,void *print_state);bool is_event_supported (u8 type,u64 config);#endif /* __PERF_PRINT_EVENTS_H */
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerPATCH v4 15/15 perf ilist: Add new python ilist command
In reply to Ian RogersThe perf ilist command is a textual app [1] similar to perf list. In the top-left pane a tree of PMUs is displayed. Selecting a PMU expands the events within it. Selecting an event displays the perf list style event information in the top-right pane.
When an event is selected it is opened and the counters on each CPU the event is for are periodically read. The bottom of the screen contains a scrollable set of sparklines showing the events in total and on each CPU. Scrolling below the sparklines shows the same data as raw counts. The sparklines are small graphs where the height of the bar is in relation to maximum of the other counts in the graph.
By default the counts are read with an interval of 0.1 seconds (10 times per second). A -I/--interval command line option allows the interval to be changed. The oldest read counts are dropped when the counts fill the line causing the sparkline to move from right to left.
A search box can be pulled up with the 's' key. 'n' and 'p' iterate through the search results. As some PMUs have hundreds of events a 'c' key will collapse the events in the current PMU to make navigating the PMUs easier.
[1] https://textual.textualize.io/
--- tools/perf/python/ilist.py | 376 +++++++++++++++++++++++++++++++++++++ 1 file changed, 376 insertions(+) create mode 100755 tools/perf/python/ilist.py
tools/perf/python/ilist.py new file +376 -0
@@ -0,0 +1,376 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +"""Interactive perf list.""" + +import argparse +from typing import Any, Dict, Tuple +import perf +from textual import on +from textual.app import App, ComposeResult +from textual.binding import Binding +from textual.containers import Horizontal, HorizontalGroup, Vertical, VerticalScroll +from textual.command import SearchIcon +from textual.screen import ModalScreen +from textual.widgets import Button, Footer, Header, Input, Label, Sparkline, Static, Tree +from textual.widgets.tree import TreeNode + +class ErrorScreen(ModalScreen[bool]): + """Pop up dialog for errors.""" + + CSS=""" + ErrorScreen { + align: center middle; + } + """ + def __init__(self, error: str): + self.error = error + super().__init__() + + def compose(self) -> ComposeResult: + yield Button(f"Error: {self.error}", variant="primary", id="error") + + def on_button_pressed(self, event: Button.Pressed) -> None: + self.dismiss(True) + + +class SearchScreen(ModalScreen[str]): + """Pop up dialog for search.""" + + CSS=""" + SearchScreen Horizontal { + align: center middle; + margin-top: 1; + } + SearchScreen Input { + width: 1fr; + } + """ + def compose(self) -> ComposeResult: + yield Horizontal(SearchIcon(), Input(placeholder="Event name")) + + def on_input_submitted(self, event: Input.Submitted) -> None: + """Handle the user pressing Enter in the input field.""" + self.dismiss(event.value) + + +class Counter(HorizontalGroup): + """Two labels for a CPU and its counter value.""" + + CSS=""" + Label { + gutter: 1; + } + """ + + def __init__(self, cpu: int) -> None: + self.cpu = cpu + super().__init__() + + def compose(self) -> ComposeResult: + label = f"cpu{self.cpu}" if self.cpu >= 0 else "total" + yield Label(label + " ") + yield Label("0", id=f"counter_{label}") + + +class CounterSparkline(HorizontalGroup): + """A Sparkline for a performance counter.""" + + def __init__(self, cpu: int) -> None: + self.cpu = cpu + super().__init__() + + def compose(self) -> ComposeResult: + label = f"cpu{self.cpu}" if self.cpu >= 0 else "total" + yield Label(label) + yield Sparkline([], summary_function=max, id=f"sparkline_{label}") + + +class IListApp(App): + TITLE = "Interactive Perf List" + + BINDINGS = [ + Binding(key="s", action="search", description="Search", + tooltip="Search events and PMUs"), + Binding(key="n", action="next", description="Next", + tooltip="Next search result or item"), + Binding(key="p", action="prev", description="Previous", + tooltip="Previous search result or item"), + Binding(key="q", action="quit", description="Quit the app"), + Binding(key="c", action="collapse", description="Collapse", + tooltip="Collapse the current PMU"), + ] + + # Make the 'total' sparkline a different color. + CSS = """ + #sparkline_total > .sparkline--min-color { + color: $accent; + } + #sparkline_total > .sparkline--max-color { + color: $accent 30%; + } + """ + + + def __init__(self, interval: float) -> None: + self.interval = interval + self.evlist = None + self.search_results: list[TreeNode[str]] = [] + self.cur_search_result: TreeNode[str] | None = None + super().__init__() + + + + def expand_and_select(self, node: TreeNode[Any]) -> None: + """Expand select a node in the tree.""" + if node.parent: + node.parent.expand() + if node.parent.parent: + node.parent.parent.expand() + node.expand() + node.tree.select_node(node) + node.tree.scroll_to_node(node) + + + def set_searched_tree_node(self, previous: bool) -> None: + """Set the cur_search_result node to either the next or previous.""" + l = len(self.search_results) + + if l < 1: + tree: Tree[str] = self.query_one("#pmus", Tree) + if previous: + tree.action_cursor_up() + else: + tree.action_cursor_down() + return + + if self.cur_search_result: + idx = self.search_results.index(self.cur_search_result) + if previous: + idx = idx - 1 if idx > 0 else l - 1 + else: + idx = idx + 1 if idx < l - 1 else 0 + else: + idx = l - 1 if previous else 0 + + node = self.search_results[idx] + if node == self.cur_search_result: + return + + self.cur_search_result = node + self.expand_and_select(node) + + def action_search(self) -> None: + """Search was chosen.""" + def set_initial_focus(event: str | None) -> None: + """Sets the focus after the SearchScreen is dismissed.""" + if not event: + return + + event = event.lower() + self.query_one("#active_search", Label) \ + .update(f'Searching for events matching "{event}"') + tree: Tree[str] = self.query_one("#pmus", Tree) + def find_search_results(event: str, node: TreeNode[str], \ + cursor_seen: bool = False, \ + match_after_cursor: TreeNode[str] | None = None) \ + -> Tuple[bool, TreeNode[str] | None]: + """Find nodes that match the search remembering the one after the cursor.""" + if not cursor_seen and node == tree.cursor_node: + cursor_seen = True + if node.data and event in node.data: + if cursor_seen and not match_after_cursor: + match_after_cursor = node + self.search_results.append(node) + + if node.children: + for child in node.children: + (cursor_seen, match_after_cursor) = \ + find_search_results(event, child, cursor_seen, match_after_cursor) + return (cursor_seen, match_after_cursor) + + self.search_results.clear() + (_ , self.cur_search_result) = find_search_results(event, tree.root) + if len(self.search_results) < 1: + self.push_screen(ErrorScreen(f"Failed to find pmu/event {event}")) + elif self.cur_search_result: + self.expand_and_select(self.cur_search_result) + else: + self.set_searched_tree_node(previous=False) + + self.push_screen(SearchScreen(), set_initial_focus) + + + def action_next(self) -> None: + """Next was chosen.""" + self.set_searched_tree_node(previous=False) + + + def action_prev(self) -> None: + """Previous was chosen.""" + self.set_searched_tree_node(previous=True) + + + def action_collapse(self) -> None: + """Collapse the potentially large number of events under a PMU.""" + tree: Tree[str] = self.query_one("#pmus", Tree) + node = tree.cursor_node + if node and node.parent and node.parent.parent: + node.parent.collapse_all() + node.tree.scroll_to_node(node.parent) + + + def update_counts(self) -> None: + """Called every interval to update counts.""" + if not self.evlist: + return + + def update_count(cpu: int, count: int): + # Update the raw count display. + counter: Label = self.query(f"#counter_cpu{cpu}" if cpu >= 0 else "#counter_total") + if not counter: + return + counter = counter.first(Label) + counter.update(str(count)) + + # Update the sparkline. + line: Sparkline = self.query(f"#sparkline_cpu{cpu}" if cpu >= 0 else "#sparkline_total") + if not line: + return + line = line.first(Sparkline) + # If there are more events than the width, remove the front event. + if len(line.data) > line.size.width: + line.data.pop(0) + line.data.append(count) + line.mutate_reactive(Sparkline.data) + + # Update the total and each CPU counts, assume there's just 1 evsel. + total = 0 + self.evlist.disable() + for evsel in self.evlist: + for cpu in evsel.cpus(): + aggr = 0 + for thread in evsel.threads(): + counts = evsel.read(cpu, thread) + aggr += counts.val + update_count(cpu, aggr) + total += aggr + update_count(-1, total) + self.evlist.enable() + + + def on_mount(self) -> None: + """When App starts set up periodic event updating.""" + self.update_counts() + self.set_interval(self.interval, self.update_counts) + + + def set_pmu_and_event(self, pmu: str, event: str) -> None: + """Updates the event/description and starts the counters.""" + # Remove previous event information. + if self.evlist: + self.evlist.disable() + self.evlist.close() + lines = self.query(CounterSparkline) + for line in lines: + line.remove() + lines = self.query(Counter) + for line in lines: + line.remove() + + def pmu_event_description(pmu: str, event: str) -> str: + """Find and format event description for {pmu}/{event}/.""" + def get_info(info: Dict[str, str], key: str): + return (info[key] + "\n") if key in info else "" + + for p in perf.pmus(): + if p.name() != pmu: + continue + for info in p.events(): + if "name" not in info or info["name"] != event: + continue + + desc = get_info(info, "topic") + desc += get_info(info, "event_type_desc") + desc += get_info(info, "desc") + desc += get_info(info, "long_desc") + desc += get_info(info, "encoding_desc") + return desc + return "description" + + # Parse event, update event text and description. + full_name = event if event.startswith(pmu) or ':' in event else f"{pmu}/{event}/" + self.query_one("#event_name", Label).update(full_name) + self.query_one("#event_description", Static).update(pmu_event_description(pmu, event)) + + # Open the event. + try: + self.evlist = perf.parse_events(full_name) + if self.evlist: + self.evlist.open() + self.evlist.enable() + except: + self.evlist = None + + if not self.evlist: + self.push_screen(ErrorScreen(f"Failed to open {full_name}")) + return + + # Add spark lines for all the CPUs. Note, must be done after + # open so that the evlist CPUs have been computed by propagate + # maps. + lines = self.query_one("#lines") + line = CounterSparkline(cpu=-1) + lines.mount(line) + for cpu in self.evlist.all_cpus(): + line = CounterSparkline(cpu) + lines.mount(line) + line = Counter(cpu=-1) + lines.mount(line) + for cpu in self.evlist.all_cpus(): + line = Counter(cpu) + lines.mount(line) + + + def compose(self) -> ComposeResult: + """Draws the app.""" + def pmu_event_tree() -> Tree: + """Create tree of PMUs with events under.""" + tree: Tree[str] = Tree("PMUs", id="pmus") + tree.root.expand() + for pmu in perf.pmus(): + pmu_name = pmu.name().lower() + pmu_node = tree.root.add(pmu_name, data=pmu_name) + for event in sorted(pmu.events(), key=lambda x: x["name"]): + if "name" in event: + e = event["name"].lower() + if "alias" in event: + pmu_node.add_leaf(f'{e} ({event["alias"]})', data=e) + else: + pmu_node.add_leaf(e, data=e) + return tree + + yield Header(id="header") + yield Horizontal(Vertical(pmu_event_tree(), id="events"), + Vertical(Label("event name", id="event_name"), + Static("description", markup=False, id="event_description"), + Label(id="active_search") + )) + yield VerticalScroll(id="lines") + yield Footer(id="footer") + + + @on(Tree.NodeSelected) + def on_tree_node_selected(self, event: Tree.NodeSelected[str]) -> None: + """Called when a tree node is selected, selecting the event.""" + if event.node.parent and event.node.parent.parent: + assert event.node.parent.data is not None + assert event.node.data is not None + self.set_pmu_and_event(event.node.parent.data, event.node.data) + + +if __name__ == "__main__": + ap = argparse.ArgumentParser() + ap.add_argument('-I', '--interval', help="Counter update interval in seconds", default=0.1) + args = ap.parse_args() + app = IListApp(float(args.interval)) + app.run()
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Namhyung Kim
maintainerHi Ian,
Sorry for the delay.
Quoted 9 lines · Ian Rogers
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 listwhile at the bottom of the console showing recent activity of the event in total and across all CPUs.The first part of the patches are a few perf and perf python C API fixes, most importantly the counter reading in python supports tool PMUs.
The first part looks ok. It'd be nice if you can send it separately.
Quoted 8 lines
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.
I think it's ok to move hardware events to JSON as well. Then we can probably remove the hard coded parsing code.
The tricky part is the hybrid machines. Would it be possible to define common hardware with standard (legacy) encoding and to mark it "weak" or overridable by arch-specific events with the same name?
Quoted 8 lines
The final patch adds 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.
Quoted 7 lines
Some thoughts on the series:
- The PMU changes will conflict with the addition of the DRM PMU:
https://lore.kernel.org/lkml/[email protected]/
when these two are merged together ilist will show yet more counters. It'd be nice if the DRM stuff could land and then I can rebase these patches.
Yep, it's merged now. Please rebase the series.
Quoted 13 lines
- The parse-events clean up of the software and tracepoint PMU. The software PMU hard coding to be legacy first has similar issues and will conflict with the clean up in:
https://lore.kernel.org/lkml/[email protected]/
Moving the software work to json means we don't need special parse events terms for software events, etc. We can just treat things like regular PMUs with json, etc. I'd much rather we had less special case logic so that series is best rebased on top of this work and it should drop the changes for software terms, etc. which this series removes. Maybe one day the whole event parsing can be much more regular in how PMUs are treated but there's always "cycles".
As I said, moving the hardware events would be a solution as long as it can handle complexities in hybrid.
Quoted 8 lines
- Should python libraries have feature tests? How does this get packaged outside the kernel tree? I think these are open questions. Clearly textual is kind of a big dependency and we've largely been moving in the direction of fewer dependencies recently. Hopefully the app makes it clear why I think this one is worth carrying. We carry libslang as a dependency and I think textual clearly far surpasses it.
Hmm.. I think it can be checked at runtime. And maybe it can ask users to install the required packages.
Quoted 6 lines
- How to launch? Currently I run
tools/perf/python/ilist.pybut it would be much nicer if we could doperf ilistmuch as we do forperf-archive.sh. There are probably other scripts that should be perf commands like flamegraph and gecko. It'd be nice to follow up the series with something to make using these commands easy.
Sounds good.
Thanks,
Namhyung
Quoted 62 lines
- Additional thoughts were captured on the mailing list:
https://lore.kernel.org/lkml/CAP-5=fWC+doaVd5rEMWJXSQi_db_Wu2tyAe5Lm6jnQjcwXkF+w@mail.gmail.com/[1] https://textual.textualize.io/
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 (15):
perfhwmon_pmu: Avoid shortening hwmon PMU name
perf parse-events: Minor tidy up ofevent_typehelper
perf python: In str(evsel) use theevsel__pmu_namehelper perf python: Fix thread check inpyrf_evsel__read
perf python: Correctpyrf_evsel__readfor tool PMUs
perf python: Add basic PMU abstraction and pmus sequence perf python: Add function returning dictionary of all events on a PMU perf jevents: If thelong_descand desc are identical then drop the
long_desc
perf jevents: Add common software event json
perf pmu: Tolerate failure to read the type for wellknown PMUs perf parse-events: Remove non-json software events
perftp_pmu: Factor existing tracepoint logic to new file perftp_pmu: Add event APIs
perf list: Remove tracepoint printing code
perf ilist: Add new python ilist commandtools/perf/builtin-list.c | 47 ++- .../arch/common/common/software.json | 92 +++++ tools/perf/pmu-events/empty-pmu-events.c | 266 ++++++++----- tools/perf/pmu-events/jevents.py | 18 +- tools/perf/python/ilist.py | 376 ++++++++++++++++++ tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +- tools/perf/util/hwmon_pmu.c | 2 +- tools/perf/util/parse-events.c | 225 ++++------- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.l | 38 +- tools/perf/util/parse-events.y | 29 +- tools/perf/util/pmu.c | 44 +- tools/perf/util/print-events.c | 95 ----- tools/perf/util/print-events.h | 1 - tools/perf/util/python.c | 248 +++++++++++- tools/perf/util/tp_pmu.c | 209 ++++++++++ tools/perf/util/tp_pmu.h | 19 + 18 files changed, 1282 insertions(+), 452 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.hSignature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Ian Rogers
reviewerQuoted 12 lines · Namhyung Kim
Hi Ian,
Sorry for the delay.
Quoted 6 lines · Ian Rogers
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 listwhile at the bottom of the console showing recent activity of the event in total and across all CPUs.
Quoted 5 lines
Quoted 3 lines
The first part of the patches are a few perf and perf python C API fixes, most importantly the counter reading in python supports tool PMUs.
The first part looks ok. It'd be nice if you can send it separately.
Thanks Namhyung!
I'm working on a longer series to add metrics to the display. Breaking up this series I have:
Fixes/cleanup:
perf hwmon_pmu: Avoid shortening hwmon PMU name perf parse-events: Minor tidy up of event_type helper perf python: In str(evsel) use the evsel__pmu_name helper perf python: Fix thread check in pyrf_evsel__read perf python: Correct pyrf_evsel__read for tool PMUs
New python PMU/PMUs abstractions:
perf python: Add basic PMU abstraction and pmus sequence perf python: Add function returning dictionary of all events on a PMU
jevents changes and a proper "software" PMU:
perf jevents: If the long_desc and desc are identical then drop the
long_desc
perf jevents: Add common software event json
perf pmu: Tolerate failure to read the type for wellknown PMUs perf parse-events: Remove non-json software events
tracepoint PMU:
perf tp_pmu: Factor existing tracepoint logic to new file perf tp_pmu: Add event APIs
perf list: Remove tracepoint printing code
ilist app:
perf ilist: Add new python ilist command
I'll resend the fixes/cleanup to start with.
Quoted 11 lines
Quoted 8 lines
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.
I think it's ok to move hardware events to JSON as well. Then we can probably remove the hard coded parsing code.
A complication here is that in the json we have a "Unit" entry that maps to a named PMU. For "software" the /sys/bus/event_source/devices/software exists, similarly for tracepoint, but for legacy hardware and hardware cache we may need to keep the legacy type and not use the PMU type, the naming of the PMU isn't consistent, etc.
Quoted 3 lines
The tricky part is the hybrid machines. Would it be possible to define common hardware with standard (legacy) encoding and to mark it "weak" or overridable by arch-specific events with the same name?
My thought is that eventually things could work like unionfs. The code looks for a PMU/events in one place, then if that misses look in the next, etc. This way we could allow users to have a directory where they define things like events and metrics, expanding perf's capabilities. We could also compress the event/metric data which may be able to half the perf binary size (beyond the pretty simple reuse/offset optimizations jevents.py tries today). With the unionfs approach there would be a default prioritization of where to look probably matching:
https://lore.kernel.org/lkml/[email protected]/
(maybe we need to treat cycles as a special case given ARM). We can then have a config setting to make the order different. There are two issues though, the event encoding/description/.. legacy vs sysfs/json/user encoding and the behavior of wildcarding/case-sensitivity/.. the non-legacy stuff inherently supports wildcarding and case insensitivity, but this may surprise people.
Quoted 9 lines
Quoted 9 lines
The final patch adds 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.
Some thoughts on the series:
Quoted 7 lines
Quoted 5 lines
- The PMU changes will conflict with the addition of the DRM PMU:
https://lore.kernel.org/lkml/[email protected]/
when these two are merged together ilist will show yet more counters. It'd be nice if the DRM stuff could land and then I can rebase these patches.Yep, it's merged now. Please rebase the series.
Ack. Thanks!
Quoted 26 lines
Quoted 13 lines
- The parse-events clean up of the software and tracepoint PMU. The software PMU hard coding to be legacy first has similar issues and will conflict with the clean up in:
https://lore.kernel.org/lkml/[email protected]/
Moving the software work to json means we don't need special parse events terms for software events, etc. We can just treat things like regular PMUs with json, etc. I'd much rather we had less special case logic so that series is best rebased on top of this work and it should drop the changes for software terms, etc. which this series removes. Maybe one day the whole event parsing can be much more regular in how PMUs are treated but there's always "cycles".As I said, moving the hardware events would be a solution as long as it can handle complexities in hybrid.
Quoted 8 lines
- Should python libraries have feature tests? How does this get packaged outside the kernel tree? I think these are open questions. Clearly textual is kind of a big dependency and we've largely been moving in the direction of fewer dependencies recently. Hopefully the app makes it clear why I think this one is worth carrying. We carry libslang as a dependency and I think textual clearly far surpasses it.
Quoted 2 lines
Hmm.. I think it can be checked at runtime. And maybe it can ask users to install the required packages.
Yeah, rather than:
```
import textual
```
we can do something like:
```
import importlib
try:
textual = importlib.import_module('textual')
except ModuleNotFoundError:
print("The textual library isn't found. Please install with pip, uv
or your distributions package manager")
exit(1)
```I'll add it to the patch with the app in it.
Quoted 7 lines
Quoted 5 lines
- How to launch? Currently I run
tools/perf/python/ilist.pybut it would be much nicer if we could doperf ilistmuch as we do forperf-archive.sh. There are probably other scripts that should be perf commands like flamegraph and gecko. It'd be nice to follow up the series with something to make using these commands easy.Sounds good.
Thanks,
Ian
Quoted 65 lines
Thanks,
NamhyungQuoted 62 lines
- Additional thoughts were captured on the mailing list:
https://lore.kernel.org/lkml/CAP-5=fWC+doaVd5rEMWJXSQi_db_Wu2tyAe5Lm6jnQjcwXkF+w@mail.gmail.com/[1] https://textual.textualize.io/
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 (15):
perfhwmon_pmu: Avoid shortening hwmon PMU name
perf parse-events: Minor tidy up ofevent_typehelper
perf python: In str(evsel) use theevsel__pmu_namehelper perf python: Fix thread check inpyrf_evsel__read
perf python: Correctpyrf_evsel__readfor tool PMUs
perf python: Add basic PMU abstraction and pmus sequence perf python: Add function returning dictionary of all events on a PMU perf jevents: If thelong_descand desc are identical then drop the
long_desc
perf jevents: Add common software event json
perf pmu: Tolerate failure to read the type for wellknown PMUs perf parse-events: Remove non-json software events
perftp_pmu: Factor existing tracepoint logic to new file perftp_pmu: Add event APIs
perf list: Remove tracepoint printing code
perf ilist: Add new python ilist commandtools/perf/builtin-list.c | 47 ++- .../arch/common/common/software.json | 92 +++++ tools/perf/pmu-events/empty-pmu-events.c | 266 ++++++++----- tools/perf/pmu-events/jevents.py | 18 +- tools/perf/python/ilist.py | 376 ++++++++++++++++++ tools/perf/util/Build | 1 + tools/perf/util/evsel.c | 21 +- tools/perf/util/hwmon_pmu.c | 2 +- tools/perf/util/parse-events.c | 225 ++++------- tools/perf/util/parse-events.h | 3 +- tools/perf/util/parse-events.l | 38 +- tools/perf/util/parse-events.y | 29 +- tools/perf/util/pmu.c | 44 +- tools/perf/util/print-events.c | 95 ----- tools/perf/util/print-events.h | 1 - tools/perf/util/python.c | 248 +++++++++++- tools/perf/util/tp_pmu.c | 209 ++++++++++ tools/perf/util/tp_pmu.h | 19 + 18 files changed, 1282 insertions(+), 452 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