[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240813132323.98728-2-james.clark@linaro.org>
Date: Tue, 13 Aug 2024 14:23:09 +0100
From: James Clark <james.clark@...aro.org>
To: irogers@...gle.com,
linux-perf-users@...r.kernel.org
Cc: James Clark <james.clark@...aro.org>,
John Garry <john.g.garry@...cle.com>,
Will Deacon <will@...nel.org>,
Mike Leach <mike.leach@...aro.org>,
Leo Yan <leo.yan@...ux.dev>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
Yang Jihong <yangjihong1@...wei.com>,
Ze Gao <zegao2021@...il.com>,
Dominique Martinet <asmadeus@...ewreck.org>,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Subject: [PATCH 1/7] perf stat: Initialize instead of overwriting clock event
This overwrite relies on the clock event remaining at index 0 and is
quite a way down from where the array is initialized, making it easy to
miss. Just initialize it with the correct clock event to begin with.
Signed-off-by: James Clark <james.clark@...aro.org>
---
tools/perf/builtin-stat.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1f92445f7480..a65f58f8783f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1817,7 +1817,9 @@ static int add_default_attributes(void)
{
struct perf_event_attr default_attrs0[] = {
- { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
+ { .type = PERF_TYPE_SOFTWARE, .config = target__has_cpu(&target) ?
+ PERF_COUNT_SW_CPU_CLOCK :
+ PERF_COUNT_SW_TASK_CLOCK },
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES },
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS },
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS },
@@ -2030,9 +2032,6 @@ static int add_default_attributes(void)
if (!evsel_list->core.nr_entries) {
/* No events so add defaults. */
- if (target__has_cpu(&target))
- default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;
-
if (evlist__add_default_attrs(evsel_list, default_attrs0) < 0)
return -1;
if (perf_pmus__have_event("cpu", "stalled-cycles-frontend")) {
--
2.34.1
Powered by blists - more mailing lists