bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Xu <dxu@dxuuu.xyz>
To: bpf@vger.kernel.org, songliubraving@fb.com, yhs@fb.com,
	andriin@fb.com, peterz@infradead.org, mingo@redhat.com,
	acme@kernel.org
Cc: Daniel Xu <dxu@dxuuu.xyz>,
	ast@fb.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com,
	namhyung@kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@fb.com
Subject: [PATCH v3 bpf-next 0/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE
Date: Fri, 16 Aug 2019 15:31:45 -0700	[thread overview]
Message-ID: <20190816223149.5714-1-dxu@dxuuu.xyz> (raw)

It's useful to know [uk]probe's nmissed and nhit stats. 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
retrieve information about FD-based probes.

This patch adds a new ioctl that lets users query nmissed (as well as
nhit for completeness). We currently only add support for [uk]probes
but leave the possibility open for other probes like tracepoint.

v2 -> v3:
- Introduce bpf_link_type and associated getter to track underlying link
  types
- Add back size field in perf_event_query_probe for forward/backwards
  compat
- Remove NULL checks, fix typos

v1 -> v2:
- More descriptive cover letter
- Make API more generic and support uprobes as well
- Use casters/getters for libbpf instead of single getter
- Fix typos
- Remove size field from ioctl struct
- Split out libbpf.h sync to tools dir to separate commit

Daniel Xu (4):
  tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl
  libbpf: Add helpers to extract perf fd from bpf_link
  tracing/probe: Sync perf_event.h to tools
  tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE

 include/linux/trace_events.h                  |  12 ++
 include/uapi/linux/perf_event.h               |  23 ++++
 kernel/events/core.c                          |  20 ++++
 kernel/trace/trace_kprobe.c                   |  24 ++++
 kernel/trace/trace_uprobe.c                   |  24 ++++
 tools/include/uapi/linux/perf_event.h         |  23 ++++
 tools/lib/bpf/libbpf.c                        |  21 ++++
 tools/lib/bpf/libbpf.h                        |  13 +++
 tools/lib/bpf/libbpf.map                      |   4 +
 .../selftests/bpf/prog_tests/attach_probe.c   | 106 ++++++++++++++++++
 10 files changed, 270 insertions(+)

-- 
2.20.1


             reply	other threads:[~2019-08-16 22:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16 22:31 Daniel Xu [this message]
2019-08-16 22:31 ` [PATCH v3 bpf-next 1/4] tracing/probe: Add PERF_EVENT_IOC_QUERY_PROBE ioctl Daniel Xu
2019-08-19 18:22   ` kbuild test robot
2019-08-20  1:26   ` Alexei Starovoitov
2019-08-20  2:34     ` Daniel Xu
2019-08-20  2:52       ` Alexei Starovoitov
2019-08-20  2:04   ` kbuild test robot
2019-08-20 14:45   ` Peter Zijlstra
2019-08-20 17:58     ` Daniel Xu
2019-08-21 11:08       ` Peter Zijlstra
2019-08-21 16:54         ` Yonghong Song
2019-08-21 18:31           ` Peter Zijlstra
2019-08-21 18:43             ` Yonghong Song
2019-08-21 20:04               ` Arnaldo Carvalho de Melo
2019-08-22  7:47               ` Peter Zijlstra
2019-08-22  7:54                 ` Song Liu
2019-08-22  9:05                   ` Peter Zijlstra
2019-08-22 21:08                     ` Daniel Xu
2019-08-21 20:07           ` Arnaldo Carvalho de Melo
2019-08-21 22:10             ` Yonghong Song
2019-08-16 22:31 ` [PATCH v3 bpf-next 2/4] libbpf: Add helpers to extract perf fd from bpf_link Daniel Xu
2019-08-19 17:45   ` Andrii Nakryiko
2019-08-19 21:30     ` Daniel Xu
2019-08-16 22:31 ` [PATCH v3 bpf-next 3/4] tracing/probe: Sync perf_event.h to tools Daniel Xu
2019-08-16 22:31 ` [PATCH v3 bpf-next 4/4] tracing/probe: Add self test for PERF_EVENT_IOC_QUERY_PROBE Daniel Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190816223149.5714-1-dxu@dxuuu.xyz \
    --to=dxu@dxuuu.xyz \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=jolsa@redhat.com \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).