Skip to content

Fix incorrect counts when count the same uncore event multiple time

Chun-Tse Shao linux-perf-users lkml 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 0 repliesNew
  2. v33 patches 3 repliesSuperseded
  3. v23 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches1 replySuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3perf evlist: Make uniquifying counter names consistenttools/perf/builtin-record.c tools/perf/builtin-top.c tools/perf/util/evlist.c +5 more+177 -1740 replies
2/3perf parse-events: Use wildcard processing to set an event to merge intotools/perf/util/evsel.c tools/perf/util/evsel.h tools/perf/util/parse-events.c +2 more+88 -720 replies
3/3perf test: Add stat uniquifying testtools/perf/tests/shell/stat+event_uniquifying.sh+69 -00 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by.

PatchChun-Tse Shao
1/3T-b
2/3T-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] Fix incorrect counts when count the same uncore event multiple time

Let's take a look an example, the machine is SKX with 6 IMC devices.

perf stat -e clockticks,clockticks -I 1000
# time counts unit events

       1.001127430      6,901,503,174      uncore_imc_0/clockticks/
       1.001127430      3,940,896,301      uncore_imc_0/clockticks/
       2.002649722        988,376,876      uncore_imc_0/clockticks/
       2.002649722        988,376,141      uncore_imc_0/clockticks/
       3.004071319      1,000,292,675      uncore_imc_0/clockticks/
       3.004071319      1,000,294,160      uncore_imc_0/clockticks/

1) The events name should not be uniquified.
2) The initial count for the first clockticks is doubled.
3) Subsequent count only report for the first IMC device.

The first patch fixes 1) and 3), and the second patch fixes 2).

After these fix:

perf stat -e clockticks,clockticks -I 1000
# time counts unit events

       1.001127586      4,126,938,857      clockticks
       1.001127586      4,121,564,277      clockticks
       2.001686014      3,953,806,350      clockticks
       2.001686014      3,953,809,541      clockticks
       3.003121403      4,137,750,252      clockticks
       3.003121403      4,137,749,048      clockticks

I also tested -A, --per-socket, --per-die and --per-core, all looks good.

Ian tested hybrid-merge and hwmon, all looks good as well.

Chun-Tse Shao (1):
perf test: Add stat uniquifying test

Ian Rogers (2):
perf evlist: Make uniquifying counter names consistent perf parse-events: Use wildcard processing to set an event to merge
into

 tools/perf/builtin-record.c                   |   7 +-
 tools/perf/builtin-top.c                      |   7 +-
 .../tests/shell/stat+event_uniquifying.sh     |  69 ++++++++
 tools/perf/util/evlist.c                      |  66 +++++---
 tools/perf/util/evlist.h                      |   3 +-
 tools/perf/util/evsel.c                       | 119 ++++++++++++-
 tools/perf/util/evsel.h                       |  11 +-
 tools/perf/util/parse-events.c                |  90 +++++++---
 tools/perf/util/stat-display.c                | 160 ++----------------
 tools/perf/util/stat.c                        |  40 +----
 10 files changed, 332 insertions(+), 240 deletions(-)
 create mode 100755 tools/perf/tests/shell/stat+event_uniquifying.sh

Chun-Tse Shao (1):
perf test: Add stat uniquifying test

Ian Rogers (2):
perf evlist: Make uniquifying counter names consistent perf parse-events: Use wildcard processing to set an event to merge
into

 tools/perf/builtin-record.c                   |   7 +-
 tools/perf/builtin-top.c                      |   7 +-
 .../tests/shell/stat+event_uniquifying.sh     |  69 ++++++++
 tools/perf/util/evlist.c                      |  66 +++++---
 tools/perf/util/evlist.h                      |   3 +-
 tools/perf/util/evsel.c                       | 119 ++++++++++++-
 tools/perf/util/evsel.h                       |  11 +-
 tools/perf/util/parse-events.c                |  86 +++++++---
 tools/perf/util/stat-display.c                | 160 ++----------------
 tools/perf/util/stat.c                        |  40 +----
 10 files changed, 328 insertions(+), 240 deletions(-)
 create mode 100755 tools/perf/tests/shell/stat+event_uniquifying.sh

--
v4: Fix a compiling error on patch v3 1/3.

v3: lore.kernel.org/[email protected]
Rebase with tmp.perf-tools-next. Since most of the conflicts are from lore.kernel.org/[email protected], tested v3 patches with:

perf stat -A -C 0,4-5,8 -e "instructions/cpu=0/,l1d-misses/cpu=4,cpu=5/,inst_retired.any/cpu=8/,cycles" -a sleep 0.1

Performance counter stats for 'system wide':

  CPU0              682,860      instructions/cpu=0/              #    0.27  insn per cycle
  CPU4               53,774      l1d-misses
  CPU5               18,725      l1d-misses
  CPU8              608,698      inst_retired.any/cpu=8/
  CPU0            2,574,325      cycles
  CPU4            4,267,115      cycles
  CPU5            1,741,536      cycles
  CPU8            1,969,547      cycles
         0.102746958 seconds time elapsed

v2: lore.kernel.org/[email protected]
- Fixes for hwmon and --hybrid-merge.
- Add a test for event uniquifying.

v1: lore.kernel.org/[email protected]

2.49.0.1045.g170613ef41-goog