perf tools: Add cached probe type detection for evsel
Arnaldo Carvalho de Melo
maintainerv3 cover perf tools: Add cached probe type detection for evsel
Hi,
Checking whether an evsel is a kprobe or uprobe currently requires walking the PMU list via evsel__find_pmu() on every call. This is wasteful when the same evsel is checked repeatedly in hot paths like trace__fprintf_tp_fields().
Patch 1 adds evsel__is_kprobe(), evsel__is_uprobe(), and evsel__is_probe() helpers that resolve the probe type on first call and cache the result in a 3-bit field that fits in existing struct padding.
Detection covers both PMU-based probes (kprobe/uprobe PMU, detected by PMU name) and ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs, which report as PMU "tracepoint"). Ftrace probes are detected by the __probe_ip field that the kernel adds to all dynamic probe formats — this is authoritative regardless of the group/system name the user chose.
Patch 2 is the first user: it guards the __probe_ip field name comparison in perf trace with evsel__is_probe(), so the strcmp is skipped entirely for the common case of non-probe tracepoint events.
Patch 3 adds inline stubs for evsel__field() and evsel__common_field() when libtraceevent is absent. These were previously declared unconditionally but defined only inside #ifdef HAVE_LIBTRACEEVENT, which was harmless until patch 1 added a call from always-compiled code in evsel.c.
Build-tested with gcc and clang.
Changes in v3:
- Add patch 3: no-libtraceevent stubs for evsel__field() and evsel__common_field(). Without this, NO_LIBTRACEEVENT=1 builds fail to link because evsel__resolve_probe_type() calls evsel__field() unconditionally (sashiko-bot).
Changes in v2 (patch 1 only):
- Detect ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs) that report PMU "tracepoint" instead of "kprobe"/ "uprobe". Check for the __probe_ip field presence in the tracepoint format. Without this, evsel__is_probe() returned false for ftrace probes, breaking __probe_ip suppression in perf trace for probes created via 'perf probe' (sashiko-bot).
- Widen probe_type bitfield from 2 to 3 bits for PROBE__FTRACE.
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()
tools/perf/builtin-trace.c | 2 +- tools/perf/util/evsel.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 19 +++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-)
Developed with AI assistance (Claude/sashiko), tagged in commits.
Arnaldo Carvalho de Melo
maintainerPATCH v3 1/2 perf evsel: Add lazy-initialized probe type detection helpers
From: Arnaldo Carvalho de Melo <[email protected]>
Several places in perf need to check whether an evsel is a kprobe or uprobe, which requires looking up the PMU by name via evsel__find_pmu(). This lookup walks the PMU list each time, which is wasteful when the same evsel is checked repeatedly.
Add evsel__is_kprobe(), evsel__is_uprobe(), and evsel__is_probe() that resolve the probe type on first call via evsel__pmu_name() and cache the result in a 3-bit field (probe_type) in struct evsel. The field fits in existing padding after the bool fields, so struct size does not grow.
The enum uses PROBE__UNKNOWN (0) as the uninitialized sentinel — explicitly set in evsel__init() — so the lookup happens on first use. PROBE__NOPE (1) caches "not a probe" to avoid repeated negative lookups.
PMU-based probes (kprobe/uprobe PMU) are detected by PMU name. Ftrace-based dynamic probes (created via tracefs, reported as PMU "tracepoint") are detected by the __probe_ip field that the kernel adds to all dynamic probe formats. This covers kprobes, uprobes, and fprobes regardless of their group/system name.
--- tools/perf/util/evsel.c | 53 +++++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 19 +++++++++++++++ 2 files changed, 72 insertions(+)
tools/perf/util/evsel.c +53 -0
@@ -254,6 +254,58 @@ const char *evsel__pmu_name(const struct evsel *evsel)return event_type (evsel->core.attr.type); } +enum evsel_probe_type { +PROBE__UNKNOWN =0 , +PROBE__NOPE =1 , +PROBE__KPROBE =2 , +PROBE__UPROBE =3 , +/* +* Ftrace-based dynamic probes (kprobes/uprobes/fprobes created via +* tracefs) report PMU "tracepoint", not "kprobe"/"uprobe". Detect +* them by the __probe_ip field that the kernel adds to all dynamic +* probe formats. +*/ +PROBE__FTRACE =4 , +}; + +static void evsel__resolve_probe_type (struct evsel *evsel) +{ +const char *name =evsel__pmu_name (evsel); + +if (!strcmp (name,"kprobe" )) + evsel->probe_type =PROBE__KPROBE ; +else if (!strcmp (name,"uprobe" )) + evsel->probe_type =PROBE__UPROBE ; +else if (!strcmp (name,"tracepoint" ) &&evsel__field (evsel,"__probe_ip" )) + evsel->probe_type =PROBE__FTRACE ; +else + evsel->probe_type =PROBE__NOPE ; +} + +bool evsel__is_probe (struct evsel *evsel) +{ +if (evsel->probe_type ==PROBE__UNKNOWN ) +evsel__resolve_probe_type (evsel); + +return evsel->probe_type >PROBE__NOPE ; +} + +bool evsel__is_kprobe (struct evsel *evsel) +{ +if (evsel->probe_type ==PROBE__UNKNOWN ) +evsel__resolve_probe_type (evsel); + +return evsel->probe_type ==PROBE__KPROBE ; +} + +bool evsel__is_uprobe (struct evsel *evsel) +{ +if (evsel->probe_type ==PROBE__UNKNOWN ) +evsel__resolve_probe_type (evsel); + +return evsel->probe_type ==PROBE__UPROBE ; +} +#define FD (e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))int __evsel__sample_size (u64 sample_type)
@@ -413,6 +465,7 @@ void evsel__init(struct evsel *evsel, evsel->supported = true; evsel->alternate_hw_config =PERF_COUNT_HW_MAX ; evsel->script_output_type =-1 ;// FIXME: OUTPUT_TYPE_UNSET, see builtin-script.c + evsel->probe_type =PROBE__UNKNOWN ; }struct evsel *evsel__new_idx (struct perf_event_attr *attr,int idx)
tools/perf/util/evsel.h +19 -0
@@ -126,6 +126,7 @@ struct evsel {bool needs_uniquify;bool fallenback_eacces;bool fallenback_eopnotsupp; + u8 probe_type:3;struct hashmap *per_pkg_mask;int err;int script_output_type;
@@ -259,6 +260,10 @@ struct perf_pmu *evsel__find_pmu(const struct evsel *evsel);const char *evsel__pmu_name (const struct evsel *evsel);bool evsel__is_aux_event (const struct evsel *evsel); +bool evsel__is_probe (struct evsel *evsel); +bool evsel__is_kprobe (struct evsel *evsel); +bool evsel__is_uprobe (struct evsel *evsel); +struct evsel *evsel__new_idx (struct perf_event_attr *attr,int idx);static inline struct evsel *evsel__new (struct perf_event_attr *attr)
@@ -397,8 +402,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);
Signature · 1 line
2.54.0
Arnaldo Carvalho de Melo
maintainerPATCH v3 2/2 perf trace: Guard __probe_ip suppression with evsel__is_probe()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
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.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -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 ;
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH 1/2] perf evsel: Add lazy-initialized probe type detection helpers
In reply to Arnaldo Carvalho de MeloThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Ftrace-based return probes (kretprobe, uretprobe, fexit) are incorrectly classified as…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Ftrace-based return probes (kretprobe, uretprobe, fexit) are incorrectly classified as PROBE__NOPE because they lack the __probe_ip field. --
commit fc58c48524e7c99a712f8fb111c94abfbbeb4b6d
Author: Arnaldo Carvalho de Melo <[email protected]>
perf evsel: Add lazy-initialized probe type detection helpers
This commit introduces lazy-initialized probe type detection helpers for perf evsel. It caches the probe type lookup in a 3-bit field within struct evsel to avoid repeated PMU list walks via evsel__find_pmu().
Quoted 4 lines
tools/perf/util/evsel.c +0
-0
[ ... ]
Quoted 17 lines
tools/perf/util/evsel.c +13
-0@@ -254,6 +254,58 @@ const char *evsel__pmu_name(const struct evsel *evsel)return event_type (evsel->core.attr.type); } +enum evsel_probe_type { +PROBE__UNKNOWN =0 , +PROBE__NOPE =1 , +PROBE__KPROBE =2 , +PROBE__UPROBE =3 , +/* +* Ftrace-based dynamic probes (kprobes/uprobes/fprobes created via +* tracefs) report PMU "tracepoint", not "kprobe"/"uprobe". Detect +* them by the __probe_ip field that the kernel adds to all dynamic +* probe formats. +*/ +PROBE__FTRACE =4 , +};
tools/perf/util/evsel.c const char *evsel__pmu_name(const struct evsel *evsel) · line 279
Quoted 10 lines
tools/perf/util/evsel.c +10
-0+ +static void evsel__resolve_probe_type (struct evsel *evsel) +{ +const char *name =evsel__pmu_name (evsel); + +if (!strcmp (name,"kprobe" )) + evsel->probe_type =PROBE__KPROBE ; +else if (!strcmp (name,"uprobe" )) + evsel->probe_type =PROBE__UPROBE ; +else if (!strcmp (name,"tracepoint" ) &&evsel__field (evsel,"__probe_ip" ))
[Severity: Medium]
The commit message mentions this covers kprobes, uprobes, and fprobes regardless of their group or system name by checking the __probe_ip field. Will this successfully detect ftrace-based return probes?
It looks like return probes like kretprobe, uretprobe, and fexit do not contain a __probe_ip field, but instead define __probe_func and __probe_ret_ip.
If evsel__field() returns NULL for return probes, won't they incorrectly fall through to the else branch and be classified as PROBE__NOPE?
Quoted 4 lines
tools/perf/util/evsel.c +4
-0+ evsel->probe_type =PROBE__FTRACE ; + else + evsel->probe_type = PROBE__NOPE; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 1/2] perf evsel: Add lazy-initialized probe type detection helpers
Quoted 53 lines · On Tue, Jun 16, 2026 at 06:40:05PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Ftrace-based return probes (kretprobe, uretprobe, fexit) are incorrectly classified asPROBE__NOPEbecause they lack the__probe_ipfield. --commit
fc58c48524e7c99a712f8fb111c94abfbbeb4b6d
Author: Arnaldo Carvalho de Melo <[email protected]>perf evsel: Add lazy-initialized probe type detection helpers
This commit introduces lazy-initialized probe type detection helpers for perf evsel. It caches the probe type lookup in a 3-bit field within struct evsel to avoid repeated PMU list walks via
evsel__find_pmu().Quoted 4 lines
tools/perf/util/evsel.c +0
-0[ ... ]
Quoted 17 lines
tools/perf/util/evsel.c +13
-0@@ -254,6 +254,58 @@ const char *evsel__pmu_name(const struct evsel *evsel)return event_type (evsel->core.attr.type); } +enum evsel_probe_type { +PROBE__UNKNOWN =0 , +PROBE__NOPE =1 , +PROBE__KPROBE =2 , +PROBE__UPROBE =3 , +/* +* Ftrace-based dynamic probes (kprobes/uprobes/fprobes created via +* tracefs) report PMU "tracepoint", not "kprobe"/"uprobe". Detect +* them by the __probe_ip field that the kernel adds to all dynamic +* probe formats. +*/ +PROBE__FTRACE =4 , +};tools/perf/util/evsel.c const char *evsel__pmu_name(const struct evsel *evsel) · line 279
Quoted 10 lines
tools/perf/util/evsel.c +10
-0+ +static void evsel__resolve_probe_type (struct evsel *evsel) +{ +const char *name =evsel__pmu_name (evsel); + +if (!strcmp (name,"kprobe" )) + evsel->probe_type =PROBE__KPROBE ; +else if (!strcmp (name,"uprobe" )) + evsel->probe_type =PROBE__UPROBE ; +else if (!strcmp (name,"tracepoint" ) &&evsel__field (evsel,"__probe_ip" ))[Severity: Medium]
The commit message mentions this covers kprobes, uprobes, and fprobes regardless of their group or system name by checking the__probe_ipfield. Will this successfully detect ftrace-based return probes?
Quoted 6 lines
It looks like return probes like kretprobe, uretprobe, and fexit do not contain a
__probe_ipfield, but instead define__probe_funcand__probe_ret_ip.If
evsel__field()returns NULL for return probes, won't they incorrectly fall through to the else branch and be classified asPROBE__NOPE?
Sure, and this is an interesting observation, we need to cover __probe_ret_ip in the same fashion as __probe_ip, probably __probe_func as well, but this should be done in an upcoming patch series.
I'll make sure to save this in a TODO file for later work.
- Arnaldo
Quoted 7 lines
Quoted 4 lines
tools/perf/util/evsel.c +4
-0+ evsel->probe_type =PROBE__FTRACE ; + else + evsel->probe_type = PROBE__NOPE; +}Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Namhyung Kim
maintainerQuoted 46 lines · Arnaldo Carvalho de Melo
Hi,
Checking whether an evsel is a kprobe or uprobe currently requires walking the PMU list via
evsel__find_pmu()on every call. This is wasteful when the same evsel is checked repeatedly in hot paths liketrace__fprintf_tp_fields().Patch 1 adds
evsel__is_kprobe(),evsel__is_uprobe(), andevsel__is_probe()helpers that resolve the probe type on first call and cache the result in a 3-bit field that fits in existing struct padding.Detection covers both PMU-based probes (kprobe/uprobe PMU, detected by PMU name) and ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs, which report as PMU "tracepoint"). Ftrace probes are detected by the
__probe_ipfield that the kernel adds to all dynamic probe formats — this is authoritative regardless of the group/system name the user chose.Patch 2 is the first user: it guards the
__probe_ipfield name comparison in perf trace withevsel__is_probe(), so the strcmp is skipped entirely for the common case of non-probe tracepoint events.Patch 3 adds inline stubs for
evsel__field()andevsel__common_field()when libtraceevent is absent. These were previously declared unconditionally but defined only inside #ifdefHAVE_LIBTRACEEVENT, which was harmless until patch 1 added a call from always-compiled code inevsel.c.Build-tested with gcc and clang.
Changes in v3:
- Add patch 3: no-libtraceevent stubs forevsel__field()andevsel__common_field(). Without this, NO_LIBTRACEEVENT=1 builds fail to link becauseevsel__resolve_probe_type()callsevsel__field()unconditionally (sashiko-bot).Changes in v2 (patch 1 only):
- Detect ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs) that report PMU "tracepoint" instead of "kprobe"/ "uprobe". Check for the__probe_ipfield presence in the tracepoint format. Without this,evsel__is_probe()returned false for ftrace probes, breaking__probe_ipsuppression in perf trace for probes created via 'perf probe' (sashiko-bot).
- Widenprobe_typebitfield from 2 to 3 bits forPROBE__FTRACE.
Quoted 4 lines
Arnaldo Carvalho de Melo (3):
perf evsel: Add lazy-initialized probe type detection helpers
perf trace: Guard__probe_ipsuppression withevsel__is_probe()
perf evsel: Add no-libtraceevent stubs forevsel__field()andevsel__common_field()
It seems you squashed patch 3 into 1. :)
Thanks,
Namhyung
Quoted 11 lines
tools/perf/builtin-trace.c | 2 +- tools/perf/util/evsel.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 19 +++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-)Cc Aaron Tomlin <[email protected]>Cc Ian Rogers <[email protected]>Cc Namhyung Kim <[email protected]>Developed with AI assistance (Claude/sashiko), tagged in commits.
Quoted 47 lines · Namhyung Kim
Quoted 46 lines · Arnaldo Carvalho de Melo
Hi,
Checking whether an evsel is a kprobe or uprobe currently requires walking the PMU list via
evsel__find_pmu()on every call. This is wasteful when the same evsel is checked repeatedly in hot paths liketrace__fprintf_tp_fields().Patch 1 adds
evsel__is_kprobe(),evsel__is_uprobe(), andevsel__is_probe()helpers that resolve the probe type on first call and cache the result in a 3-bit field that fits in existing struct padding.Detection covers both PMU-based probes (kprobe/uprobe PMU, detected by PMU name) and ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs, which report as PMU "tracepoint"). Ftrace probes are detected by the
__probe_ipfield that the kernel adds to all dynamic probe formats — this is authoritative regardless of the group/system name the user chose.Patch 2 is the first user: it guards the
__probe_ipfield name comparison in perf trace withevsel__is_probe(), so the strcmp is skipped entirely for the common case of non-probe tracepoint events.Patch 3 adds inline stubs for
evsel__field()andevsel__common_field()when libtraceevent is absent. These were previously declared unconditionally but defined only inside #ifdefHAVE_LIBTRACEEVENT, which was harmless until patch 1 added a call from always-compiled code inevsel.c.Build-tested with gcc and clang.
Changes in v3:
- Add patch 3: no-libtraceevent stubs forevsel__field()andevsel__common_field(). Without this, NO_LIBTRACEEVENT=1 builds fail to link becauseevsel__resolve_probe_type()callsevsel__field()unconditionally (sashiko-bot).Changes in v2 (patch 1 only):
- Detect ftrace-based dynamic probes (kprobes/uprobes/fprobes created via tracefs) that report PMU "tracepoint" instead of "kprobe"/ "uprobe". Check for the__probe_ipfield presence in the tracepoint format. Without this,evsel__is_probe()returned false for ftrace probes, breaking__probe_ipsuppression in perf trace for probes created via 'perf probe' (sashiko-bot).
- Widenprobe_typebitfield from 2 to 3 bits forPROBE__FTRACE.
Quoted 6 lines
Quoted 4 lines
Arnaldo Carvalho de Melo (3):
perf evsel: Add lazy-initialized probe type detection helpers
perf trace: Guard__probe_ipsuppression withevsel__is_probe()
perf evsel: Add no-libtraceevent stubs forevsel__field()andevsel__common_field()It seems you squashed patch 3 into 1. :)
I noticed it but accepted it at the end, I guess part of the process of using AI to speed up the process :-/
- Arnaldo
Quoted 15 lines
Thanks,
NamhyungQuoted 11 lines
tools/perf/builtin-trace.c | 2 +- tools/perf/util/evsel.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 19 +++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-)Cc Aaron Tomlin <[email protected]>Cc Ian Rogers <[email protected]>Cc Namhyung Kim <[email protected]>Developed with AI assistance (Claude/sashiko), tagged in commits.
- Arnaldo
Quoted 8 lines · Namhyung Kim
Quoted 5 lines · Arnaldo Carvalho de Melo
Arnaldo Carvalho de Melo (3):
perf evsel: Add lazy-initialized probe type detection helpers
perf trace: Guard__probe_ipsuppression withevsel__is_probe()
perf evsel: Add no-libtraceevent stubs forevsel__field()andevsel__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 <[email protected]> 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.
tools/perf/util/evsel.h +14 -0
@@ -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 <[email protected]> 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.
tools/perf/builtin-trace.c +1 -1
@@ -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$
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 8 lines · Namhyung Kim
Quoted 5 lines · Arnaldo Carvalho de Melo
Arnaldo Carvalho de Melo (3):
perf evsel: Add lazy-initialized probe type detection helpers
perf trace: Guard__probe_ipsuppression withevsel__is_probe()
perf evsel: Add no-libtraceevent stubs forevsel__field()andevsel__common_field()It seems you squashed patch 3 into 1. :)
Quoted 7 lines
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$
Thanks, looks good to me. For the series,
Thanks,
Namhyung
Quoted 80 lines
acme@x1:~/git/perf-tools-next$ git show 27dc372c83d90ccb commit 27dc372c83d90ccbb19107a2acffe01d6a076a53 Author: Arnaldo Carvalho de Melo <[email protected]> Date: Tue Jun 16 16:37:09 2026 -0300perf evsel: Add no-libtraceevent stubs for
evsel__field()andevsel__common_field()When building without libtraceevent (NO_LIBTRACEEVENT=1),
evsel__field()andevsel__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_LIBTRACEEVENTis not defined, matching the pattern used by other evsel accessor functions.Cc Aaron Tomlin <[email protected]>Assisted-by Claude:claude-opus-4.6Signed-off-by Arnaldo Carvalho de Melo <[email protected]>tools/perf/util/evsel.h +14
-0@@ -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 <[email protected]> Date: Mon Jun 15 22:17:41 2026 -0300perf trace: Guard
__probe_ipsuppression withevsel__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 <[email protected]>Assisted-by Claude:claude-opus-4.6Signed-off-by Arnaldo Carvalho de Melo <[email protected]>tools/perf/builtin-trace.c +1
-1@@ -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$