perf metricgroup: Remove duped metric group events
authorIan Rogers <irogers@google.com>
Wed, 20 May 2020 18:20:09 +0000 (11:20 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 May 2020 13:03:28 +0000 (10:03 -0300)
commit2440689d62e93574ca71c87129f7d523ddff7679
treeb136e1f18896821145c07015a94917726ed88bbc
parent6bf2102bec4e600e72f87569d2c8e01a3efb340e
perf metricgroup: Remove duped metric group events

A metric group contains multiple metrics. These metrics may use the same
events. If metrics use separate events then it leads to more
multiplexing and overall metric counts fail to sum to 100%.

Modify how metrics are associated with events so that if the events in
an earlier group satisfy the current metric, the same events are used.
A record of used events is kept and at the end of processing unnecessary
events are eliminated.

Before:

  $ perf stat -a -M TopDownL1 sleep 1

   Performance counter stats for 'system wide':

       920,211,343   uops_issued.any             #      0.5 Backend_Bound   (16.56%)
     1,977,733,128   idq_uops_not_delivered.core                            (16.56%)
        51,668,510   int_misc.recovery_cycles                               (16.56%)
       732,305,692   uops_retired.retire_slots                              (16.56%)
     1,497,621,849   cycles                                                 (16.56%)
       721,098,274   uops_issued.any             #      0.1 Bad_Speculation (16.79%)
     1,332,681,791   cycles                                                 (16.79%)
       552,475,482   uops_retired.retire_slots                              (16.79%)
        47,708,340   int_misc.recovery_cycles                               (16.79%)
     1,383,713,292   cycles
                                                 #      0.4 Frontend_Bound  (16.76%)
     2,013,757,701   idq_uops_not_delivered.core                            (16.76%)
     1,373,363,790   cycles
                                                 #      0.1 Retiring        (33.54%)
       577,302,589   uops_retired.retire_slots                              (33.54%)
       392,766,987   inst_retired.any            #      0.3 IPC             (50.24%)
     1,351,873,350   cpu_clk_unhalted.thread                                (50.24%)
     1,332,510,318   cycles
                                                 # 5330041272.0 SLOTS       (49.90%)

       1.006336145 seconds time elapsed

After:

  $ perf stat -a -M TopDownL1 sleep 1

   Performance counter stats for 'system wide':

       765,949,145   uops_issued.any             #      0.1 Bad_Speculation
                                                 #      0.5 Backend_Bound   (50.09%)
     1,883,830,591   idq_uops_not_delivered.core #      0.3 Frontend_Bound  (50.09%)
        48,237,080   int_misc.recovery_cycles                               (50.09%)
       581,798,385   uops_retired.retire_slots   #      0.1 Retiring        (50.09%)
     1,361,628,527   cycles
                                                 # 5446514108.0 SLOTS       (50.09%)
       391,415,714   inst_retired.any            #      0.3 IPC             (49.91%)
     1,336,486,781   cpu_clk_unhalted.thread                                (49.91%)

       1.005469298 seconds time elapsed

Note: Bad_Speculation + Backend_Bound + Frontend_Bound + Retiring = 100%
after, where as before it is 110%. After there are 2 groups, whereas
before there are 6. After the cycles event appears once, before it
appeared 5 times.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200520182011.32236-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/metricgroup.c