[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180321185448.2806324-1-ast@fb.com>
Date: Wed, 21 Mar 2018 11:54:40 -0700
From: Alexei Starovoitov <ast@...com>
To: <davem@...emloft.net>
CC: <daniel@...earbox.net>, <torvalds@...ux-foundation.org>,
<peterz@...radead.org>, <rostedt@...dmis.org>,
<netdev@...r.kernel.org>, <kernel-team@...com>,
<linux-api@...r.kernel.org>
Subject: [PATCH v2 bpf-next 0/8] bpf, tracing: introduce bpf raw tracepoints
From: Alexei Starovoitov <ast@...nel.org>
v1->v2:
- simplified api by combing bpf_raw_tp_open(name) + bpf_attach(prog_fd) into
bpf_raw_tp_open(name, prog_fd) as suggested by Daniel.
That simplifies bpf_detach as well which is now simple close() of fd.
- fixed memory leak in error path which was spotted by Daniel.
- fixed bpf_get_stackid(), bpf_perf_event_output() called from raw tracepoints
- added more tests
- fixed allyesconfig build caught by buildbot
v1:
This patch set is a different way to address the pressing need to access
task_struct pointers in sched tracepoints from bpf programs.
The first approach simply added these pointers to sched tracepoints:
https://lkml.org/lkml/2017/12/14/753
which Peter nacked.
Few options were discussed and eventually the discussion converged on
doing bpf specific tracepoint_probe_register() probe functions.
Details here:
https://lkml.org/lkml/2017/12/20/929
Patch 1 is kernel wide cleanup of pass-struct-by-value into
pass-struct-by-reference into tracepoints.
Patches 2 and 3 are minor cleanups to address allyesconfig build
Patch 4 minor prep work to expose number of arguments passed
into tracepoints.
Patch 5 introduces BPF_RAW_TRACEPOINT api.
the auto-cleanup and multiple concurrent users are must have
features of tracing api. For bpf raw tracepoints it looks like:
// load bpf prog with BPF_PROG_TYPE_RAW_TRACEPOINT type
prog_fd = bpf_prog_load(...);
// receive anon_inode fd for given bpf_raw_tracepoint
// and attach bpf program to it
raw_tp_fd = bpf_raw_tracepoint_open("xdp_exception", prog_fd);
Ctrl-C of tracing daemon or cmdline tool will automatically
detach bpf program, unload it and unregister tracepoint probe.
More details in patch 5.
Patch 6 - trivial support in libbpf
Patches 7, 8 - user space tests
samples/bpf/test_overhead performance on 1 cpu:
tracepoint base kprobe+bpf tracepoint+bpf raw_tracepoint+bpf
task_rename 1.1M 769K 947K 1.0M
urandom_read 789K 697K 750K 755K
Alexei Starovoitov (8):
treewide: remove struct-pass-by-value from tracepoints arguments
net/mediatek: disambiguate mt76 vs mt7601u trace events
net/mac802154: disambiguate mac80215 vs mac802154 trace events
tracepoint: compute num_args at build time
bpf: introduce BPF_RAW_TRACEPOINT
libbpf: add bpf_raw_tracepoint_open helper
samples/bpf: raw tracepoint test
selftests/bpf: test for bpf_get_stackid() from raw tracepoints
arch/x86/xen/mmu_pv.c | 16 +-
drivers/gpu/drm/i915/i915_trace.h | 13 +-
drivers/infiniband/hw/hfi1/file_ops.c | 2 +-
drivers/infiniband/hw/hfi1/trace_ctxts.h | 12 +-
drivers/net/wireless/mediatek/mt7601u/trace.h | 6 +-
drivers/s390/cio/ioasm.c | 18 +-
drivers/s390/cio/trace.h | 50 ++---
fs/dax.c | 2 +-
include/linux/bpf_types.h | 1 +
include/linux/trace_events.h | 57 ++++++
include/linux/tracepoint-defs.h | 1 +
include/linux/tracepoint.h | 32 ++-
include/trace/bpf_probe.h | 87 ++++++++
include/trace/define_trace.h | 15 +-
include/trace/events/f2fs.h | 2 +-
include/trace/events/fs_dax.h | 6 +-
include/trace/events/rcu.h | 4 +-
include/trace/events/xen.h | 32 +--
include/uapi/linux/bpf.h | 11 +
kernel/bpf/syscall.c | 87 ++++++++
kernel/rcu/tree.c | 10 +-
kernel/trace/bpf_trace.c | 283 ++++++++++++++++++++++++++
kernel/tracepoint.c | 27 ++-
net/mac802154/trace.h | 8 +-
net/wireless/trace.h | 2 +-
samples/bpf/Makefile | 1 +
samples/bpf/bpf_load.c | 14 ++
samples/bpf/test_overhead_raw_tp_kern.c | 17 ++
samples/bpf/test_overhead_user.c | 12 ++
sound/firewire/amdtp-stream-trace.h | 2 +-
tools/include/uapi/linux/bpf.h | 11 +
tools/lib/bpf/bpf.c | 11 +
tools/lib/bpf/bpf.h | 1 +
tools/testing/selftests/bpf/test_progs.c | 91 +++++++--
34 files changed, 807 insertions(+), 137 deletions(-)
create mode 100644 include/trace/bpf_probe.h
create mode 100644 samples/bpf/test_overhead_raw_tp_kern.c
--
2.9.5
Powered by blists - more mailing lists