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
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [RFC PATCH bpf-next 1/2] libbpf: Add support for dynamic tracepoint
Date: Sun, 5 Jan 2025 20:44:02 +0800 [thread overview]
Message-ID: <20250105124403.991-2-laoar.shao@gmail.com> (raw)
In-Reply-To: <20250105124403.991-1-laoar.shao@gmail.com>
Dynamic tracepoints can be created using debugfs. For example:
echo 'p:myprobe kernel_clone args' >> /sys/kernel/debug/tracing/kprobe_events
This command creates a new tracepoint under debugfs:
$ ls /sys/kernel/debug/tracing/events/kprobes/myprobe/
enable filter format hist id trigger
Although this dynamic tracepoint appears as a tracepoint, it is internally
implemented as a kprobe. However, it must be attached as a tracepoint to
function correctly in certain contexts.
This update adds support in libbpf for handling such tracepoints,
simplifying their usage and integration in BPF workflows.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
tools/lib/bpf/libbpf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 66173ddb5a2d..077bec761ebf 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9504,6 +9504,7 @@ static const struct bpf_sec_def section_defs[] = {
SEC_DEF("struct_ops.s+", STRUCT_OPS, 0, SEC_SLEEPABLE),
SEC_DEF("sk_lookup", SK_LOOKUP, BPF_SK_LOOKUP, SEC_ATTACHABLE),
SEC_DEF("netfilter", NETFILTER, BPF_NETFILTER, SEC_NONE),
+ SEC_DEF("dynamic_tp+", KPROBE, 0, SEC_NONE, attach_tp),
};
int libbpf_register_prog_handler(const char *sec,
@@ -12500,6 +12501,8 @@ static int attach_tp(const struct bpf_program *prog, long cookie, struct bpf_lin
/* extract "tp/<category>/<name>" or "tracepoint/<category>/<name>" */
if (str_has_pfx(prog->sec_name, "tp/"))
tp_cat = sec_name + sizeof("tp/") - 1;
+ else if (str_has_pfx(prog->sec_name, "dynamic_tp/"))
+ tp_cat = sec_name + sizeof("dynamic_tp/") - 1;
else
tp_cat = sec_name + sizeof("tracepoint/") - 1;
tp_name = strchr(tp_cat, '/');
--
2.43.5
next prev parent reply other threads:[~2025-01-05 12:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-05 12:44 [RFC PATCH bpf-next 0/2] libbpf: Add support for dynamic tracepoint Yafang Shao
2025-01-05 12:44 ` Yafang Shao [this message]
2025-01-06 0:16 ` [RFC PATCH bpf-next 1/2] " Alexei Starovoitov
2025-01-06 2:32 ` Yafang Shao
2025-01-06 22:33 ` Alexei Starovoitov
2025-01-07 2:41 ` Yafang Shao
2025-01-07 18:32 ` Daniel Xu
2025-01-07 12:16 ` Jiri Olsa
2025-01-07 13:32 ` Yafang Shao
2025-01-07 18:16 ` Daniel Xu
2025-01-05 12:44 ` [RFC PATCH bpf-next 2/2] selftests/bpf: Add selftest " Yafang Shao
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=20250105124403.991-2-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=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