]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf evsel: Add lazy-initialized probe type detection helpers
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 16 Jun 2026 19:35:43 +0000 (16:35 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 16 Jun 2026 19:35:43 +0000 (16:35 -0300)
commit9212e395c64d80f7b6af314ff6dfc4b526571493
tree0bccaf6c6330212e373ed9f7a68f4f534cc78834
parente22a4228546f7220d0425630abf703fd2ef7c600
perf evsel: Add lazy-initialized probe type detection helpers

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.

Cc: Aaron Tomlin <atomlin@atomlin.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c
tools/perf/util/evsel.h