[PATCH bpf-next 0/5] Add PERF_FORMAT_LOST read_format

From: Daniel Xu
Date: Tue Sep 17 2019 - 09:31:34 EST


It's useful to know kprobe's nmissed count. For example with tracing
tools, it's important to know when events may have been lost. debugfs
currently exposes a control file to get this information, but it is not
compatible with probes registered with the perf API.

While bpf programs may be able to manually count nhit, there is no way
to gather nmissed. In other words, it is currently not possible to this
retrieve information about FD-based probes.

This patch adds a new field to perf's read_format that lets users query
misses. Misses include both misses from the underlying kprobe
infrastructure and misses from ringbuffer infrastructure.

I studied the code various code paths for perf software events and perf
tracepoints and it does not look like anything can "miss" in the same
way kprobes can. They can all, however, suffer from ringbuffer misses.
It's possible I missed something while reading the code so please let
me know if I am mistaken.

Daniel Xu (5):
perf/core: Add PERF_FORMAT_LOST read_format
perf/core: Sync perf_event.h to tools
libbpf: Add helpers to extract perf fd from bpf_link
libbpf: Set read_format PERF_FORMAT_LOST on kprobe perf fds
libbpf: Add selftest for PERF_FORMAT_LOST perf read_format

include/linux/trace_events.h | 1 +
include/uapi/linux/perf_event.h | 5 ++-
kernel/events/core.c | 39 +++++++++++++++++--
kernel/trace/trace_kprobe.c | 8 ++++
tools/include/uapi/linux/perf_event.h | 5 ++-
tools/lib/bpf/libbpf.c | 30 ++++++++++++--
tools/lib/bpf/libbpf.h | 13 +++++++
tools/lib/bpf/libbpf.map | 3 ++
.../selftests/bpf/prog_tests/attach_probe.c | 32 ++++++++++++++-
9 files changed, 127 insertions(+), 9 deletions(-)

--
2.21.0