From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Kajol Jain <kjain@linux.ibm.com>,
Kan Liang <kan.liang@linux.intel.com>,
Jin Yao <yao.jin@linux.intel.com>,
Hongbo Yao <yaohongbo@huawei.com>,
Thomas Richter <tmricht@linux.ibm.com>,
linux-kernel@vger.kernel.org
Cc: Stephane Eranian <eranian@google.com>,
Ian Rogers <irogers@google.com>,
Jin@google.com
Subject: [PATCH 2/3] perf metricgroup: Fix uncore metric expressions
Date: Wed, 9 Sep 2020 01:02:19 -0700 [thread overview]
Message-ID: <20200909080220.254585-2-irogers@google.com> (raw)
In-Reply-To: <20200909080220.254585-1-irogers@google.com>
A metric like DRAM_BW_Use has on SkylakeX events uncore_imc/cas_count_read/
and uncore_imc/case_count_write/. These events open 6 events per socket
with pmu names of uncore_imc_[0-5]. The current metric setup code in
find_evsel_group assumes one ID will map to 1 event to be recorded in
metric_events. For events with multiple matches, the first event is
recorded in metric_events (avoiding matching >1 event with the same
name) and the evlist_used updated so that duplicate events aren't
removed when the evlist has unused events removed.
Before this change:
$ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
Performance counter stats for 'system wide':
41.14 MiB uncore_imc/cas_count_read/
1,002,614,251 ns duration_time
1.002614251 seconds time elapsed
After this change:
$ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
Performance counter stats for 'system wide':
157.47 MiB uncore_imc/cas_count_read/ # 0.00 DRAM_BW_Use
126.97 MiB uncore_imc/cas_count_write/
1,003,019,728 ns duration_time
Erroneous duplication introduced in:
commit 2440689d62e9 ("perf metricgroup: Remove duped metric group events").
Fixes: ded80bda8bc9 ("perf expr: Migrate expr ids table to a hashmap").
Reported-by: Jin, Yao <yao.jin@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/metricgroup.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 8831b964288f..d216a161f41c 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -206,6 +206,18 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
sizeof(struct evsel *) * idnum);
current_leader = ev->leader;
}
+ /*
+ * Check for duplicate events with the same name. For example,
+ * uncore_imc/cas_count_read/ will turn into 6 events per socket
+ * on skylakex. Only the first such event is placed in
+ * metric_events.
+ */
+ for (i = 0; i < matched_events; i++) {
+ if (!strcmp(metric_events[i]->name, ev->name))
+ break;
+ }
+ if (i != matched_events)
+ continue;
if (hashmap__find(&pctx->ids, ev->name, (void **)&val_ptr)) {
if (has_constraint) {
/*
@@ -248,6 +260,16 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
ev = metric_events[i];
ev->metric_leader = ev;
set_bit(ev->idx, evlist_used);
+ /*
+ * Mark two events with identical names in the same group as
+ * being in use as uncore events may be duplicated for each pmu.
+ */
+ evlist__for_each_entry(perf_evlist, ev) {
+ if (metric_events[i]->leader == ev->leader &&
+ !strcmp(metric_events[i]->name, ev->name)) {
+ set_bit(ev->idx, evlist_used);
+ }
+ }
}
return metric_events[0];
--
2.28.0.526.ge36021eeef-goog
next prev parent reply other threads:[~2020-09-09 8:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 8:02 [PATCH 1/3] perf stat: Remove dead code Ian Rogers
2020-09-09 8:02 ` Ian Rogers [this message]
2020-09-09 9:53 ` [PATCH 2/3] perf metricgroup: Fix uncore metric expressions Namhyung Kim
2020-09-09 17:52 ` Ian Rogers
2020-09-10 3:40 ` Ian Rogers
2020-09-10 5:55 ` Namhyung Kim
[not found] ` <9d22f4d1-ea24-bc42-40bc-d25202f25678@linux.intel.com>
2020-09-09 17:38 ` Ian Rogers
2020-09-09 8:02 ` [PATCH 3/3] perf metricgroup: Fix typo in comment Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200909080220.254585-2-irogers@google.com \
--to=irogers@google.com \
--cc=Jin@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=jolsa@redhat.com \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tmricht@linux.ibm.com \
--cc=yao.jin@linux.intel.com \
--cc=yaohongbo@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome