]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf print-events: Remove print_hwcache_events
authorIan Rogers <irogers@google.com>
Sun, 5 Oct 2025 18:24:17 +0000 (11:24 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 15 Oct 2025 14:59:11 +0000 (23:59 +0900)
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>
tools/perf/builtin-list.c
tools/perf/util/print-events.c
tools/perf/util/print-events.h

index caf42276bd0f5e20c1d8a31faeeb8b01309ccdbb..b6720ef3adf668e45fc970eae57cbdda8909ed79 100644 (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;
index 4153124a9948ee678789aae6fa64b8ecdb36e1ef..91a5d9c7882ba4b0b852467353ddf4cdca455f94 100644 (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,
index d6ba384f0c66594f87f9d63c30fc2c7c6f2e9c3c..44e5dbd914004c5eec1c730d1e3eb8e32538fd2e 100644 (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,