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

perf print-events: Print legacy cache events for each PMU

Mirroring parse_events_add_cache, list the legacy name alongside its
alias with the PMU. Remove the now unnecessary hybrid logic.

Note, the alias output removes the event type descriptor, so:
  L1-dcache-loads                                    [Hardware cache event]
becomes:
  L1-dcache-loads OR cpu/L1-dcache-loads/
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ahmad Yasin <ahmad.yasin@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kang Minchul <tegongkang@gmail.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Samantha Alt <samantha.alt@intel.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20230502223851.2234828-26-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2bdf4d7e
...@@ -414,7 +414,7 @@ static int config_attr(struct perf_event_attr *attr, ...@@ -414,7 +414,7 @@ static int config_attr(struct perf_event_attr *attr,
* contain hyphens and the longest name * contain hyphens and the longest name
* should always be selected. * should always be selected.
*/ */
static int parse_events__decode_legacy_cache(const char *name, int pmu_type, __u64 *config) int parse_events__decode_legacy_cache(const char *name, int pmu_type, __u64 *config)
{ {
int len, cache_type = -1, cache_op = -1, cache_result = -1; int len, cache_type = -1, cache_op = -1, cache_result = -1;
const char *name_end = &name[strlen(name) + 1]; const char *name_end = &name[strlen(name) + 1];
......
...@@ -173,6 +173,7 @@ int parse_events_add_tool(struct parse_events_state *parse_state, ...@@ -173,6 +173,7 @@ int parse_events_add_tool(struct parse_events_state *parse_state,
int parse_events_add_cache(struct list_head *list, int *idx, const char *name, int parse_events_add_cache(struct list_head *list, int *idx, const char *name,
struct parse_events_error *error, struct parse_events_error *error,
struct list_head *head_config); struct list_head *head_config);
int parse_events__decode_legacy_cache(const char *name, int pmu_type, __u64 *config);
int parse_events_add_breakpoint(struct list_head *list, int *idx, int parse_events_add_breakpoint(struct list_head *list, int *idx,
u64 addr, char *type, u64 len); u64 addr, char *type, u64 len);
int parse_events_add_pmu(struct parse_events_state *parse_state, int parse_events_add_pmu(struct parse_events_state *parse_state,
......
...@@ -230,56 +230,50 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state) ...@@ -230,56 +230,50 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)
int print_hwcache_events(const struct print_callbacks *print_cb, void *print_state) int print_hwcache_events(const struct print_callbacks *print_cb, void *print_state)
{ {
struct perf_pmu *pmu = NULL;
const char *event_type_descriptor = event_type_descriptors[PERF_TYPE_HW_CACHE]; const char *event_type_descriptor = event_type_descriptors[PERF_TYPE_HW_CACHE];
for (int type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) { while ((pmu = perf_pmu__scan(pmu)) != NULL) {
for (int op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) { /*
/* skip invalid cache type */ * Skip uncore PMUs for performance. PERF_TYPE_HW_CACHE type
if (!evsel__is_cache_op_valid(type, op)) * attributes can accept software PMUs in the extended type, so
continue; * also skip.
*/
for (int res = 0; res < PERF_COUNT_HW_CACHE_RESULT_MAX; res++) { if (pmu->is_uncore || pmu->type == PERF_TYPE_SOFTWARE)
struct perf_pmu *pmu = NULL; continue;
char name[64];
for (int type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
__evsel__hw_cache_type_op_res_name(type, op, res, for (int op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
name, sizeof(name)); /* skip invalid cache type */
if (!perf_pmu__has_hybrid()) { if (!evsel__is_cache_op_valid(type, op))
if (is_event_supported(PERF_TYPE_HW_CACHE,
type | (op << 8) | (res << 16))) {
print_cb->print_event(print_state,
"cache",
/*pmu_name=*/NULL,
name,
/*event_alias=*/NULL,
/*scale_unit=*/NULL,
/*deprecated=*/false,
event_type_descriptor,
/*desc=*/NULL,
/*long_desc=*/NULL,
/*encoding_desc=*/NULL);
}
continue; continue;
}
perf_pmu__for_each_hybrid_pmu(pmu) { for (int res = 0; res < PERF_COUNT_HW_CACHE_RESULT_MAX; res++) {
if (is_event_supported(PERF_TYPE_HW_CACHE, char name[64];
type | (op << 8) | (res << 16) | char alias_name[128];
((__u64)pmu->type << PERF_PMU_TYPE_SHIFT))) { __u64 config;
char new_name[128]; int ret;
snprintf(new_name, sizeof(new_name),
"%s/%s/", pmu->name, name); __evsel__hw_cache_type_op_res_name(type, op, res,
print_cb->print_event(print_state, name, sizeof(name));
"cache",
pmu->name, ret = parse_events__decode_legacy_cache(name, pmu->type,
name, &config);
new_name, if (ret || !is_event_supported(PERF_TYPE_HW_CACHE, config))
/*scale_unit=*/NULL, continue;
/*deprecated=*/false, snprintf(alias_name, sizeof(alias_name), "%s/%s/",
event_type_descriptor, pmu->name, name);
/*desc=*/NULL, print_cb->print_event(print_state,
/*long_desc=*/NULL, "cache",
/*encoding_desc=*/NULL); pmu->name,
} name,
alias_name,
/*scale_unit=*/NULL,
/*deprecated=*/false,
event_type_descriptor,
/*desc=*/NULL,
/*long_desc=*/NULL,
/*encoding_desc=*/NULL);
} }
} }
} }
......
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