perf print-events: Remove print_hwcache_events

Now legacy cache events are in json there's no need for a specific
printing routine. To support the previous filtered version use an
event glob of "legacy cache" which matches the topic of the json
events.

Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
Ian Rogers 2025-10-05 11:24:17 -07:00 committed by Namhyung Kim
parent 0012e0fa22
commit b12b5b531a
3 changed files with 12 additions and 60 deletions

View File

@ -652,9 +652,18 @@ int cmd_list(int argc, const char **argv)
}
default_ps.pmu_glob = old_pmu_glob;
} else if (strcmp(argv[i], "cache") == 0 ||
strcmp(argv[i], "hwcache") == 0)
print_hwcache_events(&print_cb, ps);
else if (strcmp(argv[i], "pmu") == 0) {
strcmp(argv[i], "hwcache") == 0) {
char *old_event_glob = default_ps.event_glob;
default_ps.event_glob = strdup("legacy cache");
if (!default_ps.event_glob) {
ret = -1;
goto out;
}
perf_pmus__print_pmu_events(&print_cb, ps);
zfree(&default_ps.event_glob);
default_ps.event_glob = old_event_glob;
} else if (strcmp(argv[i], "pmu") == 0) {
default_ps.exclude_abi = true;
perf_pmus__print_pmu_events(&print_cb, ps);
default_ps.exclude_abi = false;
@ -707,7 +716,6 @@ int cmd_list(int argc, const char **argv)
default_ps.event_glob = s;
print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE,
event_symbols_hw, PERF_COUNT_HW_MAX);
print_hwcache_events(&print_cb, ps);
perf_pmus__print_pmu_events(&print_cb, ps);
print_sdt_events(&print_cb, ps);
default_ps.metrics = true;

View File

@ -186,59 +186,6 @@ bool is_event_supported(u8 type, u64 config)
return ret;
}
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];
/*
* Only print core PMUs, skipping uncore for performance and
* PERF_TYPE_SOFTWARE that can succeed in opening legacy cache evenst.
*/
while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
if (pmu->is_uncore || pmu->type == PERF_TYPE_SOFTWARE)
continue;
for (int type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
for (int op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
/* skip invalid cache type */
if (!evsel__is_cache_op_valid(type, op))
continue;
for (int res = 0; res < PERF_COUNT_HW_CACHE_RESULT_MAX; res++) {
char name[64];
char alias_name[128];
__u64 config;
int ret;
__evsel__hw_cache_type_op_res_name(type, op, res,
name, sizeof(name));
ret = parse_events__decode_legacy_cache(name, pmu->type,
&config);
if (ret || !is_event_supported(PERF_TYPE_HW_CACHE, config))
continue;
snprintf(alias_name, sizeof(alias_name), "%s/%s/",
pmu->name, name);
print_cb->print_event(print_state,
"cache",
pmu->name,
pmu->type,
name,
alias_name,
/*scale_unit=*/NULL,
/*deprecated=*/false,
event_type_descriptor,
/*desc=*/NULL,
/*long_desc=*/NULL,
/*encoding_desc=*/NULL);
}
}
}
}
return 0;
}
void print_symbol_events(const struct print_callbacks *print_cb, void *print_state,
unsigned int type, const struct event_symbol *syms,
unsigned int max)
@ -434,8 +381,6 @@ void print_events(const struct print_callbacks *print_cb, void *print_state)
print_symbol_events(print_cb, print_state, PERF_TYPE_HARDWARE,
event_symbols_hw, PERF_COUNT_HW_MAX);
print_hwcache_events(print_cb, print_state);
perf_pmus__print_pmu_events(print_cb, print_state);
print_cb->print_event(print_state,

View File

@ -32,7 +32,6 @@ struct print_callbacks {
/** Print all events, the default when no options are specified. */
void print_events(const struct print_callbacks *print_cb, void *print_state);
int print_hwcache_events(const struct print_callbacks *print_cb, void *print_state);
void print_sdt_events(const struct print_callbacks *print_cb, void *print_state);
void print_symbol_events(const struct print_callbacks *print_cb, void *print_state,
unsigned int type, const struct event_symbol *syms,