From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Namhyung Kim" <namhyung@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Kan Liang" <kan.liang@linux.intel.com>,
"Andreas Färber" <afaerber@suse.de>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Caleb Biggers" <caleb.biggers@intel.com>,
"Weilin Wang" <weilin.wang@intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
"Perry Taylor" <perry.taylor@intel.com>,
"Thomas Falcon" <thomas.falcon@intel.com>
Subject: Re: [PATCH v5 09/16] perf intel-tpebs: Refactor tpebs_results list
Date: Wed, 23 Apr 2025 11:23:15 -0300 [thread overview]
Message-ID: <aAj30xLNXtXhn6IP@x1> (raw)
In-Reply-To: <20250414174134.3095492-10-irogers@google.com>
On Mon, Apr 14, 2025 at 10:41:27AM -0700, Ian Rogers wrote:
> evsel names and metric-ids are used for matching but this can be
> problematic, for example, multiple occurrences of the same retirement
> latency event become a single event for the record. Change the name of
> the record events so they are unique and reflect the evsel of the
> retirement latency event that opens them (the retirement latency
> event's evsel address is embedded within them). This allows an evsel
> based close to close the event when the retirement latency event is
> closed. This is important as perf stat has an evlist and the session
> listen to the record events has an evlist, knowing which event should
> remove the tpebs_retire_lat can't be tied to an evlist list as there
> is more than 1, so closing which evlist should cause the tpebs to
> stop? Using the evsel and the last one out doing the tpebs_stop is
> cleaner.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> Tested-by: Weilin Wang <weilin.wang@intel.com>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/builtin-stat.c | 2 -
> tools/perf/util/evlist.c | 1 -
> tools/perf/util/evsel.c | 2 +-
> tools/perf/util/intel-tpebs.c | 150 +++++++++++++++++++++-------------
> tools/perf/util/intel-tpebs.h | 2 +-
> 5 files changed, 93 insertions(+), 64 deletions(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 68ea7589c143..80e491bd775b 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -681,8 +681,6 @@ static enum counter_recovery stat_handle_error(struct evsel *counter)
> if (child_pid != -1)
> kill(child_pid, SIGTERM);
>
> - tpebs_delete();
> -
> return COUNTER_FATAL;
> }
>
> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
> index c1a04141aed0..0a21da4f990f 100644
> --- a/tools/perf/util/evlist.c
> +++ b/tools/perf/util/evlist.c
> @@ -183,7 +183,6 @@ void evlist__delete(struct evlist *evlist)
> if (evlist == NULL)
> return;
>
> - tpebs_delete();
> evlist__free_stats(evlist);
> evlist__munmap(evlist);
> evlist__close(evlist);
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 121283f2f382..554252ed1aab 100644
> --- a/tools/perf/util/evsel.c
<SNIP>
> static struct tpebs_retire_lat *tpebs_retire_lat__find(struct evsel *evsel)
> {
> struct tpebs_retire_lat *t;
> + uint64_t num;
> + const char *evsel_name;
>
> + /*
> + * Evsels will match for evlist with the retirement latency event. The
> + * name with "tpebs_event_" prefix will be present on events being read
> + * from `perf record`.
> + */
> + if (evsel__is_retire_lat(evsel)) {
> + list_for_each_entry(t, &tpebs_results, nd) {
> + if (t->evsel == evsel)
> + return t;
> + }
> + return NULL;
> + }
> + evsel_name = strstr(evsel->name, "tpebs_event_");
> + if (!evsel_name) {
> + /* Unexpected that the perf record should have other events. */
> + return NULL;
> + }
> + errno = 0;
> + num = strtoull(evsel_name + 12, NULL, 16);
> + if (errno) {
> + pr_err("Bad evsel for tpebs find '%s'\n", evsel->name);
> + return NULL;
> + }
> list_for_each_entry(t, &tpebs_results, nd) {
> - if (t->tpebs_name == evsel->name ||
> - !strcmp(t->tpebs_name, evsel->name) ||
> - (evsel->metric_id && !strcmp(t->tpebs_name, evsel->metric_id)))
> + if ((uint64_t)t->evsel == num)
> return t;
I'm adding the following patch to address building on 32-bit systems:
20 4.97 debian:experimental-x-mips : FAIL gcc version 14.2.0 (Debian 14.2.0-13)
util/intel-tpebs.c: In function 'tpebs_retire_lat__find':
util/intel-tpebs.c:377:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
377 | if ((uint64_t)t->evsel == num)
| ^
cc1: all warnings being treated as errors
- Arnaldo
⬢ [acme@toolbx perf-tools-next]$ git diff
diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c
index a723687e67f6d7b3..b48f3692c798f924 100644
--- a/tools/perf/util/intel-tpebs.c
+++ b/tools/perf/util/intel-tpebs.c
@@ -242,7 +242,7 @@ static void tpebs_retire_lat__delete(struct tpebs_retire_lat *r)
static struct tpebs_retire_lat *tpebs_retire_lat__find(struct evsel *evsel)
{
struct tpebs_retire_lat *t;
- uint64_t num;
+ unsigned long num;
const char *evsel_name;
/*
@@ -269,7 +269,7 @@ static struct tpebs_retire_lat *tpebs_retire_lat__find(struct evsel *evsel)
return NULL;
}
list_for_each_entry(t, &tpebs_results, nd) {
- if ((uint64_t)t->evsel == num)
+ if ((unsigned long)t->evsel == num)
return t;
}
return NULL;
next prev parent reply other threads:[~2025-04-23 14:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 17:41 [PATCH v5 00/16] Intel TPEBS min/max/mean/last support Ian Rogers
2025-04-14 17:41 ` [PATCH v5 01/16] perf intel-tpebs: Cleanup header Ian Rogers
2025-04-14 17:41 ` [PATCH v5 02/16] perf intel-tpebs: Simplify tpebs_cmd Ian Rogers
2025-04-14 17:41 ` [PATCH v5 03/16] perf intel-tpebs: Rename tpebs_start to evsel__tpebs_open Ian Rogers
2025-04-14 17:41 ` [PATCH v5 04/16] perf intel-tpebs: Separate evsel__tpebs_prepare out of evsel__tpebs_open Ian Rogers
2025-04-14 17:41 ` [PATCH v5 05/16] perf intel-tpebs: Move cpumap_buf " Ian Rogers
2025-04-14 17:41 ` [PATCH v5 06/16] perf intel-tpebs: Reduce scope of tpebs_events_size Ian Rogers
2025-04-14 17:41 ` [PATCH v5 07/16] perf intel-tpebs: Inline get_perf_record_args Ian Rogers
2025-04-14 17:41 ` [PATCH v5 08/16] perf intel-tpebs: Ensure events are opened, factor out finding Ian Rogers
2025-04-14 17:41 ` [PATCH v5 09/16] perf intel-tpebs: Refactor tpebs_results list Ian Rogers
2025-04-23 14:23 ` Arnaldo Carvalho de Melo [this message]
2025-04-23 15:04 ` Ian Rogers
2025-04-14 17:41 ` [PATCH v5 10/16] perf intel-tpebs: Add support for updating counts in evsel__tpebs_read Ian Rogers
2025-04-14 17:41 ` [PATCH v5 11/16] perf intel-tpebs: Add mutex for tpebs_results Ian Rogers
2025-04-14 17:41 ` [PATCH v5 12/16] perf intel-tpebs: Don't close record on read Ian Rogers
2025-04-14 17:41 ` [PATCH v5 13/16] perf intel-tpebs: Use stats for retirement latency statistics Ian Rogers
2025-04-14 17:41 ` [PATCH v5 14/16] perf stat: Add mean, min, max and last --tpebs-mode options Ian Rogers
2025-04-23 13:56 ` Arnaldo Carvalho de Melo
2025-04-23 15:03 ` Ian Rogers
2025-04-14 17:41 ` [PATCH v5 15/16] perf pmu-events: Add retirement latency to JSON events inside of perf Ian Rogers
2025-04-14 17:41 ` [PATCH v5 16/16] perf record: Retirement latency cleanup in evsel__config Ian Rogers
2025-04-14 19:08 ` [PATCH v5 00/16] Intel TPEBS min/max/mean/last support Liang, Kan
2025-04-21 18:13 ` Ian Rogers
2025-04-23 13:33 ` Arnaldo Carvalho de Melo
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=aAj30xLNXtXhn6IP@x1 \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=afaerber@suse.de \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=caleb.biggers@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=perry.taylor@intel.com \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=weilin.wang@intel.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).