Commit 714b4511 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf parse-events x86: Avoid sorting uops_retired.slots

As topdown.slots may appear as slots it may get confused with
uops_retired.slots which is an invalid perf metric event group leader.

Special case uops_retired.slots to avoid this confusion.
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20230801053634.1142634-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e8ca4f0f
...@@ -75,11 +75,12 @@ int arch_evlist__add_default_attrs(struct evlist *evlist, ...@@ -75,11 +75,12 @@ int arch_evlist__add_default_attrs(struct evlist *evlist,
int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs) int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
{ {
if (topdown_sys_has_perf_metrics() && evsel__sys_has_perf_metrics(lhs)) { if (topdown_sys_has_perf_metrics() &&
(arch_evsel__must_be_in_group(lhs) || arch_evsel__must_be_in_group(rhs))) {
/* Ensure the topdown slots comes first. */ /* Ensure the topdown slots comes first. */
if (strcasestr(lhs->name, "slots")) if (strcasestr(lhs->name, "slots") && !strcasestr(lhs->name, "uops_retired.slots"))
return -1; return -1;
if (strcasestr(rhs->name, "slots")) if (strcasestr(rhs->name, "slots") && !strcasestr(rhs->name, "uops_retired.slots"))
return 1; return 1;
/* Followed by topdown events. */ /* Followed by topdown events. */
if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown")) if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown"))
......
...@@ -40,12 +40,11 @@ bool evsel__sys_has_perf_metrics(const struct evsel *evsel) ...@@ -40,12 +40,11 @@ bool evsel__sys_has_perf_metrics(const struct evsel *evsel)
bool arch_evsel__must_be_in_group(const struct evsel *evsel) bool arch_evsel__must_be_in_group(const struct evsel *evsel)
{ {
if (!evsel__sys_has_perf_metrics(evsel)) if (!evsel__sys_has_perf_metrics(evsel) || !evsel->name ||
strcasestr(evsel->name, "uops_retired.slots"))
return false; return false;
return evsel->name && return strcasestr(evsel->name, "topdown") || strcasestr(evsel->name, "slots");
(strcasestr(evsel->name, "slots") ||
strcasestr(evsel->name, "topdown"));
} }
int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment