Re: [PATCHES v3 0/2] perf tools: Add cached probe type detection for evsel

From: Arnaldo Carvalho de Melo

Date: Thu Jun 18 2026 - 09:33:10 EST


On Wed, Jun 17, 2026 at 03:48:15PM -0700, Namhyung Kim wrote:
> On Tue, Jun 16, 2026 at 03:25:44PM -0300, Arnaldo Carvalho de Melo wrote:
> >
> > Arnaldo Carvalho de Melo (3):
> > perf evsel: Add lazy-initialized probe type detection helpers
> > perf trace: Guard __probe_ip suppression with evsel__is_probe()
> > perf evsel: Add no-libtraceevent stubs for evsel__field() and evsel__common_field()
>
> It seems you squashed patch 3 into 1. :)

Yeah, I noticed and fixed it up before pushing publicly:

acme@x1:~/git/perf-tools-next$ git log --oneline 27dc372c83d90ccbb19107a2acffe01d6a076a53^.. | tail -3
846f367ff02226e7 perf trace: Guard __probe_ip suppression with evsel__is_probe()
fbb5e6e3ca28a325 perf evsel: Add lazy-initialized probe type detection helpers
27dc372c83d90ccb perf evsel: Add no-libtraceevent stubs for evsel__field() and evsel__common_field()
acme@x1:~/git/perf-tools-next$

- Arnaldo

acme@x1:~/git/perf-tools-next$ git show 27dc372c83d90ccb
commit 27dc372c83d90ccbb19107a2acffe01d6a076a53
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Date: Tue Jun 16 16:37:09 2026 -0300

perf evsel: Add no-libtraceevent stubs for evsel__field() and evsel__common_field()

When building without libtraceevent (NO_LIBTRACEEVENT=1), evsel__field()
and evsel__common_field() are declared but never defined, causing link
errors in any code path that references them.

Add inline stubs that return NULL when HAVE_LIBTRACEEVENT is not defined,
matching the pattern used by other evsel accessor functions.

Cc: Aaron Tomlin <atomlin@xxxxxxxxxxx>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8009be22cc3f1055..b959d4797b14035d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -397,8 +397,22 @@ struct tep_format_field;

u64 format_field__intval(struct tep_format_field *field, struct perf_sample *sample, bool needs_swap);

+#ifdef HAVE_LIBTRACEEVENT
struct tep_format_field *evsel__field(struct evsel *evsel, const char *name);
struct tep_format_field *evsel__common_field(struct evsel *evsel, const char *name);
+#else
+static inline struct tep_format_field *
+evsel__field(struct evsel *evsel __maybe_unused, const char *name __maybe_unused)
+{
+ return NULL;
+}
+
+static inline struct tep_format_field *
+evsel__common_field(struct evsel *evsel __maybe_unused, const char *name __maybe_unused)
+{
+ return NULL;
+}
+#endif

bool __evsel__match(const struct evsel *evsel, u32 type, u64 config);

acme@x1:~/git/perf-tools-next$

acme@x1:~/git/perf-tools-next$ git show 846f367ff02226e7
commit 846f367ff02226e7089181d2adae45a6cca4a3e6 (number/perf/evsel-probe-type)
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Date: Mon Jun 15 22:17:41 2026 -0300

perf trace: Guard __probe_ip suppression with evsel__is_probe()

trace__fprintf_tp_fields() compares every field name against
"__probe_ip" for all tracepoint events, but this field is only
implicitly added by the Ftrace subsystem to bare dynamic probes.

Add an evsel__is_probe() check before the strcmp so the string
comparison is skipped entirely for non-probe events.

Reviewed-by: Aaron Tomlin <atomlin@xxxxxxxxxxx>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a8492da23a9cc178..57f3f14c5d435805 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3267,7 +3267,7 @@ static size_t trace__fprintf_tp_fields(struct trace *trace, struct perf_sample *
* If verbose mode is enabled, ensure it is formatted as a
* hexadecimal memory address rather than a signed integer.
*/
- if (!strcmp(field->name, "__probe_ip")) {
+ if (evsel__is_probe(evsel) && !strcmp(field->name, "__probe_ip")) {
if (!verbose)
continue;

acme@x1:~/git/perf-tools-next$