perf tools: Add cached probe type detection for evsel
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 5 repliesIn review
- v22 patches 0 repliesSuperseded
- v12 patches 1 replySuperseded
Changes in v3 from the cover letter
- 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).
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | perf evsel: Add lazy-initialized probe type detection helperstools/ tools/ | +72 | 1 reply | |
| 2/2 | perf trace: Guard __probe_ip suppression with evsel__is_probe()tools/ | +1 | 0 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Aaron Tomlin | Namhyung Kim |
|---|---|---|
| Series | R-b | A-b |
| 1/2 | ||
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCHES v3 0/2] 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.