]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf print-events: Remove print_symbol_events
authorIan Rogers <irogers@google.com>
Sun, 5 Oct 2025 18:24:18 +0000 (11:24 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 15 Oct 2025 14:59:11 +0000 (23:59 +0900)
Now legacy hardware events are in json there's no need for a specific
printing routine that previously served for both hardware and software
events. The associated event_symbols_hw is also removed. To support
the previous filtered version use an event glob of "legacy hardware"
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/parse-events.c
tools/perf/util/parse-events.h
tools/perf/util/print-events.c
tools/perf/util/print-events.h

index b6720ef3adf668e45fc970eae57cbdda8909ed79..16400366f8276a7abe56d80f1821aff0962c85f6 100644 (file)
@@ -633,10 +633,18 @@ int cmd_list(int argc, const char **argv)
                        zfree(&default_ps.pmu_glob);
                        default_ps.pmu_glob = old_pmu_glob;
                } else if (strcmp(argv[i], "hw") == 0 ||
-                        strcmp(argv[i], "hardware") == 0)
-                       print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE,
-                                       event_symbols_hw, PERF_COUNT_HW_MAX);
-               else if (strcmp(argv[i], "sw") == 0 ||
+                          strcmp(argv[i], "hardware") == 0) {
+                       char *old_event_glob = default_ps.event_glob;
+
+                       default_ps.event_glob = strdup("legacy hardware");
+                       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], "sw") == 0 ||
                         strcmp(argv[i], "software") == 0) {
                        char *old_pmu_glob = default_ps.pmu_glob;
                        static const char * const sw_globs[] = { "software", "tool" };
@@ -714,8 +722,6 @@ int cmd_list(int argc, const char **argv)
                                continue;
                        }
                        default_ps.event_glob = s;
-                       print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE,
-                                       event_symbols_hw, PERF_COUNT_HW_MAX);
                        perf_pmus__print_pmu_events(&print_cb, ps);
                        print_sdt_events(&print_cb, ps);
                        default_ps.metrics = true;
index 4e003abe90f0d14fc5a44a6c5a8356b09f3f1343..5fd910bf42f5cc41295c798f05e4a6c4b273c42b 100644 (file)
@@ -42,49 +42,6 @@ static int parse_events_terms__copy(const struct parse_events_terms *src,
                                    struct parse_events_terms *dest);
 static int parse_events_terms__to_strbuf(const struct parse_events_terms *terms, struct strbuf *sb);
 
-const struct event_symbol event_symbols_hw[PERF_COUNT_HW_MAX] = {
-       [PERF_COUNT_HW_CPU_CYCLES] = {
-               .symbol = "cpu-cycles",
-               .alias  = "cycles",
-       },
-       [PERF_COUNT_HW_INSTRUCTIONS] = {
-               .symbol = "instructions",
-               .alias  = "",
-       },
-       [PERF_COUNT_HW_CACHE_REFERENCES] = {
-               .symbol = "cache-references",
-               .alias  = "",
-       },
-       [PERF_COUNT_HW_CACHE_MISSES] = {
-               .symbol = "cache-misses",
-               .alias  = "",
-       },
-       [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = {
-               .symbol = "branch-instructions",
-               .alias  = "branches",
-       },
-       [PERF_COUNT_HW_BRANCH_MISSES] = {
-               .symbol = "branch-misses",
-               .alias  = "",
-       },
-       [PERF_COUNT_HW_BUS_CYCLES] = {
-               .symbol = "bus-cycles",
-               .alias  = "",
-       },
-       [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = {
-               .symbol = "stalled-cycles-frontend",
-               .alias  = "idle-cycles-frontend",
-       },
-       [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = {
-               .symbol = "stalled-cycles-backend",
-               .alias  = "idle-cycles-backend",
-       },
-       [PERF_COUNT_HW_REF_CPU_CYCLES] = {
-               .symbol = "ref-cycles",
-               .alias  = "",
-       },
-};
-
 static const char *const event_types[] = {
        [PERF_TYPE_HARDWARE]    = "hardware",
        [PERF_TYPE_SOFTWARE]    = "software",
index ad782da63c83e86e3cb8b074394714a07b2ec9ad..61402c021d5121c29c1687ae87f49b4ecc5d4104 100644 (file)
@@ -266,7 +266,6 @@ struct event_symbol {
        const char      *symbol;
        const char      *alias;
 };
-extern const struct event_symbol event_symbols_hw[];
 
 char *parse_events_formats_error_string(char *additional_terms);
 
index 91a5d9c7882ba4b0b852467353ddf4cdca455f94..8f3ed83853a9e4685300e7a9d49a429a2e3d342b 100644 (file)
@@ -186,60 +186,6 @@ bool is_event_supported(u8 type, u64 config)
        return ret;
 }
 
-void print_symbol_events(const struct print_callbacks *print_cb, void *print_state,
-                        unsigned int type, const struct event_symbol *syms,
-                        unsigned int max)
-{
-       struct strlist *evt_name_list = strlist__new(NULL, NULL);
-       struct str_node *nd;
-
-       if (!evt_name_list) {
-               pr_debug("Failed to allocate new strlist for symbol events\n");
-               return;
-       }
-       for (unsigned int i = 0; i < max; i++) {
-               /*
-                * New attr.config still not supported here, the latest
-                * example was PERF_COUNT_SW_CGROUP_SWITCHES
-                */
-               if (syms[i].symbol == NULL)
-                       continue;
-
-               if (!is_event_supported(type, i))
-                       continue;
-
-               if (strlen(syms[i].alias)) {
-                       char name[MAX_NAME_LEN];
-
-                       snprintf(name, MAX_NAME_LEN, "%s OR %s", syms[i].symbol, syms[i].alias);
-                       strlist__add(evt_name_list, name);
-               } else
-                       strlist__add(evt_name_list, syms[i].symbol);
-       }
-
-       strlist__for_each_entry(nd, evt_name_list) {
-               char *alias = strstr(nd->s, " OR ");
-
-               if (alias) {
-                       *alias = '\0';
-                       alias += 4;
-               }
-               print_cb->print_event(print_state,
-                               /*topic=*/NULL,
-                               /*pmu_name=*/NULL,
-                               type,
-                               nd->s,
-                               alias,
-                               /*scale_unit=*/NULL,
-                               /*deprecated=*/false,
-                               event_type_descriptors[type],
-                               /*desc=*/NULL,
-                               /*long_desc=*/NULL,
-                               /*encoding_desc=*/NULL);
-       }
-       strlist__delete(evt_name_list);
-}
-
 /** struct mep - RB-tree node for building printing information. */
 struct mep {
        /** nd - RB-tree element. */
@@ -378,9 +324,6 @@ void metricgroup__print(const struct print_callbacks *print_cb, void *print_stat
  */
 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);
-
        perf_pmus__print_pmu_events(print_cb, print_state);
 
        print_cb->print_event(print_state,
index 44e5dbd914004c5eec1c730d1e3eb8e32538fd2e..eabba5d4a1fd1c444207521bd70fd2dae10709dd 100644 (file)
@@ -33,9 +33,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);
 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,
-                        unsigned int max);
 void metricgroup__print(const struct print_callbacks *print_cb, void *print_state);
 bool is_event_supported(u8 type, u64 config);