mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: James Clark <james.clark@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	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,
	 Atish Patra <atishp@rivosinc.com>,
	Beeman Strong <beeman@rivosinc.com>, Leo Yan <leo.yan@arm.com>,
	 Vince Weaver <vincent.weaver@maine.edu>
Cc: Ian Rogers <irogers@google.com>, Thomas Richter <tmricht@linux.ibm.com>
Subject: [PATCH v7 14/27] perf print-events: Remove print_hwcache_events
Date: Sun,  5 Oct 2025 11:24:17 -0700	[thread overview]
Message-ID: <20251005182430.2791371-15-irogers@google.com> (raw)
In-Reply-To: <20251005182430.2791371-1-irogers@google.com>

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>
---
 tools/perf/builtin-list.c      | 16 +++++++---
 tools/perf/util/print-events.c | 55 ----------------------------------
 tools/perf/util/print-events.h |  1 -
 3 files changed, 12 insertions(+), 60 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index caf42276bd0f..b6720ef3adf6 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -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;
diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index 4153124a9948..91a5d9c7882b 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -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,
diff --git a/tools/perf/util/print-events.h b/tools/perf/util/print-events.h
index d6ba384f0c66..44e5dbd91400 100644
--- a/tools/perf/util/print-events.h
+++ b/tools/perf/util/print-events.h
@@ -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,
-- 
2.51.0.618.g983fd99d29-goog


  parent reply	other threads:[~2025-10-05 18:25 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-05 18:24 [PATCH v7 00/27] Legacy hardware/cache events as json Ian Rogers
2025-10-05 18:24 ` [PATCH v7 01/27] perf parse-events: Fix legacy cache events if event is duplicated in a PMU Ian Rogers
2025-10-05 18:24 ` [PATCH v7 02/27] perf perf_api_probe: Avoid scanning all PMUs, try software PMU first Ian Rogers
2025-10-05 18:24 ` [PATCH v7 03/27] perf stat: Avoid wildcarding PMUs for default events Ian Rogers
2025-10-05 18:24 ` [PATCH v7 04/27] perf record: Skip don't fail for events that don't open Ian Rogers
2025-10-05 18:24 ` [PATCH v7 05/27] perf jevents: Support copying the source json files to OUTPUT Ian Rogers
2025-10-08 11:10   ` James Clark
2025-10-08 14:58     ` Ian Rogers
2025-10-08 15:14       ` James Clark
2025-10-08 21:43         ` Ian Rogers
2025-10-05 18:24 ` [PATCH v7 06/27] perf pmu: Don't eagerly parse event terms Ian Rogers
2025-10-05 18:24 ` [PATCH v7 07/27] perf parse-events: Remove unused FILE input argument to scanner Ian Rogers
2025-10-05 18:24 ` [PATCH v7 08/27] perf pmu: Use fd rather than FILE from new_alias Ian Rogers
2025-10-05 18:24 ` [PATCH v7 09/27] perf pmu: Factor term parsing into a perf_event_attr into a helper Ian Rogers
2025-10-05 18:24 ` [PATCH v7 10/27] perf parse-events: Add terms for legacy hardware and cache config values Ian Rogers
2025-10-05 18:24 ` [PATCH v7 11/27] perf jevents: Add legacy json terms and default_core event table helper Ian Rogers
2025-10-05 18:24 ` [PATCH v7 12/27] perf pmu: Add and use legacy_terms in alias information Ian Rogers
2025-10-05 18:24 ` [PATCH v7 13/27] perf jevents: Add legacy-hardware and legacy-cache json Ian Rogers
2025-10-05 18:24 ` Ian Rogers [this message]
2025-10-05 18:24 ` [PATCH v7 15/27] perf print-events: Remove print_symbol_events Ian Rogers
2025-10-05 18:24 ` [PATCH v7 16/27] perf parse-events: Remove hard coded legacy hardware and cache parsing Ian Rogers
2025-10-05 18:24 ` [PATCH v7 17/27] perf record: Use evlist__new_default when no events specified Ian Rogers
2025-10-05 18:24 ` [PATCH v7 18/27] perf top: " Ian Rogers
2025-10-05 18:24 ` [PATCH v7 19/27] perf evlist: Avoid scanning all PMUs for evlist__new_default Ian Rogers
2025-10-05 18:24 ` [PATCH v7 20/27] perf evsel: Improvements to __evsel__match Ian Rogers
2025-10-05 18:24 ` [PATCH v7 21/27] perf test parse-events: Use evsel__match for legacy events Ian Rogers
2025-10-05 18:24 ` [PATCH v7 22/27] perf test parse-events: Without a PMU use cpu-cycles rather than cycles Ian Rogers
2025-10-05 18:24 ` [PATCH v7 23/27] perf test parse-events: Remove cpu PMU requirement Ian Rogers
2025-10-05 18:24 ` [PATCH v7 24/27] perf test: Switch cycles event to cpu-cycles Ian Rogers
2025-10-05 18:24 ` [PATCH v7 25/27] perf test: Clean up test_..config helpers Ian Rogers
2025-10-05 18:24 ` [PATCH v7 26/27] perf test parse-events: Add evlist test helper Ian Rogers
2025-10-05 18:24 ` [PATCH v7 27/27] perf test parse-events: Add evsel " Ian Rogers
2025-10-08 11:06 ` [PATCH v7 00/27] Legacy hardware/cache events as json James Clark
2025-10-08 14:53   ` Ian Rogers
2025-10-15 15:53 ` Namhyung Kim
2025-10-15 17:39   ` James Clark
2025-10-15 21:24     ` Ian Rogers
2025-10-16 10:29       ` James Clark
2025-10-20 16:10         ` James Clark

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=20251005182430.2791371-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=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=thomas.falcon@intel.com \
    --cc=tmricht@linux.ibm.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

all inboxes | Powered by JetHome®