From: Yafang Shao <laoar.shao@gmail.com>
To: andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
jolsa@kernel.org, edumazet@google.com, dxu@dxuuu.xyz
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [RFC PATCH v2 0/2] libbpf: Add support for dynamic tracepoints
Date: Sun, 12 Jan 2025 14:45:11 +0800 [thread overview]
Message-ID: <20250112064513.883-1-laoar.shao@gmail.com> (raw)
The primary goal of this change is to enable tracing of inlined kernel
functions with BPF programs.
Dynamic tracepoints can be created using tools like perf-probe, debugfs, or
similar utilities. For example:
$ perf probe -a 'tcp_listendrop sk'
$ ls /sys/kernel/debug/tracing/events/probe/tcp_listendrop/
enable filter format hist id trigger
Here, tcp_listendrop() is an example of an inlined kernel function.
While these dynamic tracepoints are functional, they cannot be easily
attached to BPF programs. For instance, attempting to use them with
bpftrace results in the following error:
$ bpftrace -l 'tracepoint:probe:*'
tracepoint:probe:tcp_listendrop
$ bpftrace -e 'tracepoint:probe:tcp_listendrop {print(comm)}'
Attaching 1 probe...
ioctl(PERF_EVENT_IOC_SET_BPF): Invalid argument
ERROR: Error attaching probe: tracepoint:probe:tcp_listendrop
The issue lies in how these dynamic tracepoints are implemented: despite
being exposed as tracepoints, they remain kprobe events internally. As a
result, loading them as a tracepoint program fails. Instead, they must be
loaded as kprobe programs.
This change introduces support for such use cases in libbpf by adding a
new section: SEC("kprobe/SUBSYSTEM/PROBE")
- Future work
Extend support for dynamic tracepoints in bpftrace.
Changes:
v1->v2:
- Use a new SEC("kprobe/SUBSYSTEM/PROBE") instead (Jiri)
v1: https://lore.kernel.org/bpf/20250105124403.991-1-laoar.shao@gmail.com/
Yafang Shao (2):
libbpf: Add support for dynamic tracepoint
selftests/bpf: Add selftest for dynamic tracepoint
tools/lib/bpf/libbpf.c | 29 ++++++++-
.../bpf/prog_tests/test_dynamic_tp.c | 64 +++++++++++++++++++
.../testing/selftests/bpf/progs/dynamic_tp.c | 27 ++++++++
3 files changed, 119 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/test_dynamic_tp.c
create mode 100644 tools/testing/selftests/bpf/progs/dynamic_tp.c
--
2.43.5
next reply other threads:[~2025-01-12 6:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-12 6:45 Yafang Shao [this message]
2025-01-12 6:45 ` [RFC PATCH v2 1/2] libbpf: Add support for dynamic tracepoint Yafang Shao
2025-01-12 6:45 ` [RFC PATCH v2 2/2] selftests/bpf: Add selftest " Yafang Shao
2025-01-14 22:32 ` [RFC PATCH v2 0/2] libbpf: Add support for dynamic tracepoints Andrii Nakryiko
2025-01-15 3:13 ` Yafang Shao
2025-01-16 23:05 ` Andrii Nakryiko
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=20250112064513.883-1-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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