RE: [PATCH v4 16/16] perf record: Retirement latency cleanup in evsel__config

Wang, Weilin
2025-04-10T03:12:41Z

> -----Original Message-----
> From: Ian Rogers <irogers@google.com>
> Sent: Tuesday, April 8, 2025 11:11 PM
> 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>; Hunter, Adrian
> <adrian.hunter@intel.com>; Kan Liang <kan.liang@linux.intel.com>; Wang,
> Weilin <weilin.wang@intel.com>; James Clark <james.clark@linaro.org>; Xu
> Yang <xu.yang_2@nxp.com>; John Garry <john.g.garry@oracle.com>; Howard
> Chu <howardchu95@gmail.com>; Levi Yun <yeoreum.yun@arm.com>;
> Dominique Martinet <asmadeus@codewreck.org>; linux-perf-
> users@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH v4 16/16] perf record: Retirement latency cleanup in
> evsel__config
>
> Perf record will fail with retirement latency events as the open
> doesn't do a perf_event_open system call. Use evsel__config to set up
> such events for recording by removing the flag and enabling sample
> weights - the sample weights containing the retirement latency.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Weilin Wang <weilin.wang@intel.com>

> ---
> tools/perf/util/evsel.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 661a07cbdb25..6a84893e3c58 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1440,9 +1440,10 @@ void evsel__config(struct evsel *evsel, struct
> record_opts *opts,
> attr->branch_sample_type = opts->branch_stack;
> }
>
> - if (opts->sample_weight)
> + if (opts->sample_weight || evsel->retire_lat) {
> arch_evsel__set_sample_weight(evsel);
> -
> + evsel->retire_lat = false;
> + }
> attr->task = track;
> attr->mmap = track;
> attr->mmap2 = track && !perf_missing_features.mmap2;
> --
> 2.49.0.504.g3bcea36a83-goog