Skip to content

perf metric: Fixes and allow modifiers

Ian Rogers linux-arm-kernel linux-perf-users lkml 2 versions – Applied

Status from this message: Thanks, applied. Replaced the v1 with this one since it never hit the

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest21 patches 16 repliesApplied
  2. v121 patches 7 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/21tools lib: Add list_sort.tools/include/linux/list_sort.h tools/lib/list_sort.c tools/perf/MANIFEST +3 more+275 -00 replies
2/21perf pmu: Add const to pmu_events_map.tools/perf/arch/arm64/util/pmu.c tools/perf/pmu-events/jevents.c tools/perf/pmu-events/pmu-events.h +8 more+36 -361 reply
3/21perf pmu: Make pmu_sys_event_tables const.tools/perf/pmu-events/jevents.c tools/perf/pmu-events/pmu-events.h tools/perf/tests/pmu-events.c +1 more+4 -42 replies
4/21perf pmu: Make pmu_event tables const.tools/perf/arch/powerpc/util/header.c tools/perf/pmu-events/jevents.c tools/perf/pmu-events/pmu-events.h +6 more+39 -393 replies
5/21perf metric: Move runtime value to the expr contexttools/perf/tests/expr.c tools/perf/tests/pmu-events.c tools/perf/util/expr.c +3 more+31 -281 reply
6/21perf metric: Add documentation and rename a variable.tools/perf/util/metricgroup.c+54 -51 reply
7/21perf metric: Add metric new and freetools/perf/util/metricgroup.c+75 -621 reply
8/21perf metric: Only add a referenced metric oncetools/perf/util/metricgroup.c+9 -30 replies
9/21perf metric: Modify resolution and recursion check.tools/perf/tests/expr.c tools/perf/util/expr.c tools/perf/util/expr.h +2 more+179 -2700 replies
10/21perf metric: Comment data structures.tools/perf/util/metricgroup.h+27 -00 replies
11/21perf metric: Document the internal 'struct metric'tools/perf/util/metricgroup.c+20 -00 replies
12/21perf metric: Simplify metric_refs calculation.tools/perf/util/metricgroup.c+23 -540 replies
13/21perf parse-events: Add const to evsel nametools/perf/util/parse-events-hybrid.c tools/perf/util/parse-events-hybrid.h tools/perf/util/parse-events.c +3 more+27 -200 replies
14/21perf parse-events: Add new "metric-id" term.tools/perf/util/evsel.c tools/perf/util/evsel.h tools/perf/util/parse-events-hybrid.c +5 more+107 -450 replies
15/21perf parse-events: Allow config on kernel PMU eventstools/perf/util/parse-events.c tools/perf/util/parse-events.h tools/perf/util/parse-events.y+52 -320 replies
16/21perf metric: Encode and use metric-id as qualifiertools/perf/tests/expr.c tools/perf/tests/pmu-events.c tools/perf/util/expr.l +3 more+242 -810 replies
17/21perf expr: Add subset utility.tools/perf/util/expr.c tools/perf/util/expr.h+17 -00 replies
18/21perf metrics: Modify setup and deduplicationtools/perf/util/metricgroup.c+262 -2510 replies
19/21perf metric: Switch fprintf to pr_err.tools/perf/util/metricgroup.c+1 -10 replies
20/21perf parse-events: Identify broken modifiers.tools/perf/util/parse-events.y+10 -00 replies
21/21perf metric: Allow modifiers on metrics.tools/perf/util/metricgroup.c+98 -276 replies

Reviews trailers per patch

All 21 patches have a Reviewed-by or Acked-by.

PatchAndi KleenJohn GarryKajol Jain
1/21A-b
2/21A-b R-b R-b
3/21A-b R-b R-b
4/21A-b R-b R-b
5/21A-b R-b
6/21A-b R-b
7/21A-b R-b
8/21A-b
9/21A-b
10/21A-b
11/21A-b
12/21A-b
13/21A-b
14/21A-b
15/21A-b
16/21A-b
17/21A-b
18/21A-b
19/21A-b
20/21A-b
21/21A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/21] perf metric: Fixes and allow modifiers

There are 4 main changes in this patch set:
- perf metric: Modify resolution and recursion check.
- perf parse-events: Add new "metric-id" term.
- perf metrics: Modify setup and deduplication
- perf metric: Allow modifiers on metrics.

In overview the changes start by trying to simplify the metric code, then it fixes various bugs and finally it builds a new feature of allowing metrics like:

$ perf stat -M IPC:u,IPC:k -a sleep 1

Performance counter stats for 'system wide':

        93,269,988      inst_retired.any:k        #     0.26 IPC:k                  
       352,037,460      cpu_clk_unhalted.thread:k                                   
        70,317,865      inst_retired.any:u        #     0.76 IPC:u                  
        92,762,220      cpu_clk_unhalted.thread:u                                   
       1.003754577 seconds time elapsed

Previous complexity came from using the evsel->name as the identifier for events in metrics, however, this name isn't stable and has issues around wildcard expansion. These changes fix this by adding a dedicated metric_id to evsels, performing deduplication on IDs before event parsing and not handling all evsels on a single evlist.

The recursion and metric_ref logic is simplified, the first by moving data from the heap to the stack, the latter by building in an array rather than a linked list. This logic is integral to metric set up and simplification makes the effects of the changes easier to follow, in particular as there are fewer structs being maintained.

Event parsing is modified to allow qualifiers on kernel PMU events, this is necessary to allow the metric-id to be added, but allows qualifiers in other cases like specifying callgraph or a name.

There is a certain amount of comment adding and const-ification, this is with a view to making the code more intention revealing and to aid following its logic. For example, the pmu event tables should never change and it'd be a bug if they ever did, it's therefore strange to access it using non-const pointers.

The kernel list_sort.c/h are added for use sorting metrics in order to deduplicate/reuse events from a larger group in a smaller one. This was previously done by inserting in size order, but that only worked within a metric group.

Some of the commit messages show the TopDownL1 metrics being used on a SkylakeX machine. These metrics were removed by c4ad8fabd03f76ed3a2a4c8aef6baf6cd4f24542 ("perf vendor events: Update metrics for SkyLake Server") and the data was gathered with this patch reverted.

v2. Add METADATA fixes to 'Add list_sort' suggested by
Arnaldo Carvalho de Melo <[email protected]>.
Fix arm64 function declaration in 'Add const to pmu_events_map' found by Andrew Kilroy <[email protected]>.
Add a static in 'Make pmu_event tables const' suggested by John Garry <[email protected]>.
Add acked-by: Andi Kleen <[email protected]>.
Fix/handle 0 events case in 'Modify setup and deduplication'. Fix a missed strdup that resulted in a double free in 'Allow modifiers on metrics.'

Ian Rogers (21):
tools lib: Add list_sort.
perf pmu: Add const to pmu_events_map.
perf pmu: Make pmu_sys_event_tables const. perf pmu: Make pmu_event tables const.
perf metric: Move runtime value to the expr context perf metric: Add documentation and rename a variable. perf metric: Add metric new and free
perf metric: Only add a referenced metric once perf metric: Modify resolution and recursion check. perf metric: Comment data structures.
perf metric: Document the internal 'struct metric' perf metric: Simplify metric_refs calculation. perf parse-events: Add const to evsel name perf parse-events: Add new "metric-id" term. perf parse-events: Allow config on kernel PMU events perf metric: Encode and use metric-id as qualifier perf expr: Add subset utility.
perf metrics: Modify setup and deduplication perf metric: Switch fprintf to pr_err.
perf parse-events: Identify broken modifiers. perf metric: Allow modifiers on metrics.

 tools/include/linux/list_sort.h       |   14 +
 tools/lib/list_sort.c                 |  252 +++++
 tools/perf/MANIFEST                   |    1 +
 tools/perf/arch/arm64/util/pmu.c      |    2 +-
 tools/perf/arch/powerpc/util/header.c |    2 +-
 tools/perf/check-headers.sh           |    2 +
 tools/perf/pmu-events/jevents.c       |    6 +-
 tools/perf/pmu-events/pmu-events.h    |    8 +-
 tools/perf/tests/expand-cgroup.c      |    2 +-
 tools/perf/tests/expr.c               |   29 +-
 tools/perf/tests/parse-metric.c       |    2 +-
 tools/perf/tests/pmu-events.c         |   59 +-
 tools/perf/util/Build                 |    5 +
 tools/perf/util/evsel.c               |   17 +
 tools/perf/util/evsel.h               |    2 +
 tools/perf/util/expr.c                |   56 +-
 tools/perf/util/expr.h                |   16 +-
 tools/perf/util/expr.l                |    6 +-
 tools/perf/util/expr.y                |    2 +-
 tools/perf/util/metricgroup.c         | 1461 ++++++++++++++-----------
 tools/perf/util/metricgroup.h         |   35 +-
 tools/perf/util/parse-events-hybrid.c |   34 +-
 tools/perf/util/parse-events-hybrid.h |    6 +-
 tools/perf/util/parse-events.c        |  166 +--
 tools/perf/util/parse-events.h        |   11 +-
 tools/perf/util/parse-events.l        |   18 +-
 tools/perf/util/parse-events.y        |   27 +-
 tools/perf/util/pfm.c                 |    3 +-
 tools/perf/util/pmu.c                 |   22 +-
 tools/perf/util/pmu.h                 |   10 +-
 tools/perf/util/python-ext-sources    |    1 +
 tools/perf/util/s390-sample-raw.c     |    6 +-
 tools/perf/util/stat-shadow.c         |   27 +-
 33 files changed, 1470 insertions(+), 840 deletions(-)
 create mode 100644 tools/include/linux/list_sort.h
 create mode 100644 tools/lib/list_sort.c
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog