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@xxxxxxxxx> --- 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