From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
Xu Yang <xu.yang_2@nxp.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
bpf@vger.kernel.org, Atish Patra <atishp@rivosinc.com>,
Beeman Strong <beeman@rivosinc.com>, Leo Yan <leo.yan@arm.com>,
Vince Weaver <vincent.weaver@maine.edu>
Subject: [PATCH v2 14/15] perf print-events: Remove print_symbol_events
Date: Thu, 28 Aug 2025 09:32:24 -0700 [thread overview]
Message-ID: <20250828163225.3839073-15-irogers@google.com> (raw)
In-Reply-To: <20250828163225.3839073-1-irogers@google.com>
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.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/builtin-list.c | 18 +++++++----
tools/perf/util/parse-events.c | 43 -------------------------
tools/perf/util/parse-events.h | 1 -
tools/perf/util/print-events.c | 57 ----------------------------------
tools/perf/util/print-events.h | 3 --
5 files changed, 12 insertions(+), 110 deletions(-)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index b6720ef3adf6..16400366f827 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -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;
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index be3e86e7b157..72cc59cfc46d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -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",
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index a64f0741cb4b..32bde974c9f5 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -264,7 +264,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);
diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index 91a5d9c7882b..8f3ed83853a9 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -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,
diff --git a/tools/perf/util/print-events.h b/tools/perf/util/print-events.h
index 44e5dbd91400..eabba5d4a1fd 100644
--- a/tools/perf/util/print-events.h
+++ b/tools/perf/util/print-events.h
@@ -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);
--
2.51.0.268.g9569e192d0-goog
next prev parent reply other threads:[~2025-08-28 16:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 16:32 [PATCH v2 00/15] Legacy hardware/cache events as json Ian Rogers
2025-08-28 16:32 ` [PATCH v2 01/15] perf parse-events: Fix legacy cache events if event is duplicated in a PMU Ian Rogers
2025-08-28 16:32 ` [PATCH v2 02/15] perf perf_api_probe: Avoid scanning all PMUs, try software PMU first Ian Rogers
2025-08-28 16:32 ` [PATCH v2 03/15] perf record: Skip don't fail for events that don't open Ian Rogers
2025-08-28 16:32 ` [PATCH v2 04/15] perf jevents: Support copying the source json files to OUTPUT Ian Rogers
2025-08-28 16:32 ` [PATCH v2 05/15] perf pmu: Don't eagerly parse event terms Ian Rogers
2025-08-28 16:32 ` [PATCH v2 06/15] perf parse-events: Remove unused FILE input argument to scanner Ian Rogers
2025-08-28 16:32 ` [PATCH v2 07/15] perf pmu: Use fd rather than FILE from new_alias Ian Rogers
2025-08-28 16:32 ` [PATCH v2 08/15] perf pmu: Factor term parsing into a perf_event_attr into a helper Ian Rogers
2025-08-28 16:32 ` [PATCH v2 09/15] perf parse-events: Add terms for legacy hardware and cache config values Ian Rogers
2025-08-28 16:32 ` [PATCH v2 10/15] perf jevents: Add legacy json terms and default_core event table helper Ian Rogers
2025-08-28 16:32 ` [PATCH v2 11/15] perf pmu: Add and use legacy_terms in alias information Ian Rogers
2025-08-28 16:32 ` [PATCH v2 12/15] perf jevents: Add legacy-hardware and legacy-cache json Ian Rogers
2025-08-28 16:32 ` [PATCH v2 13/15] perf print-events: Remove print_hwcache_events Ian Rogers
2025-08-28 16:32 ` Ian Rogers [this message]
2025-08-28 16:32 ` [PATCH v2 15/15] perf parse-events: Remove hard coded legacy hardware and cache parsing Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250828163225.3839073-15-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=atishp@rivosinc.com \
--cc=beeman@rivosinc.com \
--cc=bpf@vger.kernel.org \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=vincent.weaver@maine.edu \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).