linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 1/3] bpf: Add cookie to raw_tp bpf_link_info
@ 2025-06-03 15:43 Tao Chen
  2025-06-03 15:43 ` [PATCH bpf-next v3 2/3] selftests/bpf: Add cookies check for raw_tp fill_link_info test Tao Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tao Chen @ 2025-06-03 15:43 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, qmo, jolsa
  Cc: bpf, linux-kernel, Tao Chen

After commit 68ca5d4eebb8 ("bpf: support BPF cookie in raw tracepoint
(raw_tp, tp_btf) programs"), we can show the cookie in bpf_link_info
like kprobe etc.

Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Tao Chen <chen.dylane@linux.dev>
---
 include/uapi/linux/bpf.h       | 2 ++
 kernel/bpf/syscall.c           | 1 +
 tools/include/uapi/linux/bpf.h | 2 ++
 3 files changed, 5 insertions(+)

Change list:
- v2 -> v3:
    - use '__u32 :32' to fill the hole.(Yonghong)
    - add double space for plain output.(Quentin)
    - patch1-2 Acked-by Jiri
- v2:
    https://lore.kernel.org/bpf/20250603022610.3005963-1-chen.dylane@linux.dev

- v1 -> v2:
    - fill the hole in bpf_link_info.(Jiri)
- v1:
    https://lore.kernel.org/bpf/20250529165759.2536245-1-chen.dylane@linux.dev

diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 07ee73cdf9..9bd2a5b64b 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -6644,6 +6644,8 @@ struct bpf_link_info {
 		struct {
 			__aligned_u64 tp_name; /* in/out: tp_name buffer ptr */
 			__u32 tp_name_len;     /* in/out: tp_name buffer len */
+			__u32 :32;
+			__u64 cookie;
 		} raw_tracepoint;
 		struct {
 			__u32 attach_type;
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 9794446bc8..1c3dbe44ac 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3687,6 +3687,7 @@ static int bpf_raw_tp_link_fill_link_info(const struct bpf_link *link,
 		return -EINVAL;
 
 	info->raw_tracepoint.tp_name_len = tp_len + 1;
+	info->raw_tracepoint.cookie = raw_tp_link->cookie;
 
 	if (!ubuf)
 		return 0;
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 07ee73cdf9..9bd2a5b64b 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -6644,6 +6644,8 @@ struct bpf_link_info {
 		struct {
 			__aligned_u64 tp_name; /* in/out: tp_name buffer ptr */
 			__u32 tp_name_len;     /* in/out: tp_name buffer len */
+			__u32 :32;
+			__u64 cookie;
 		} raw_tracepoint;
 		struct {
 			__u32 attach_type;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-05 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 15:43 [PATCH bpf-next v3 1/3] bpf: Add cookie to raw_tp bpf_link_info Tao Chen
2025-06-03 15:43 ` [PATCH bpf-next v3 2/3] selftests/bpf: Add cookies check for raw_tp fill_link_info test Tao Chen
2025-06-03 15:43 ` [PATCH bpf-next v3 3/3] bpftool: Display cookie for raw_tp link probe Tao Chen
2025-06-03 16:21   ` Quentin Monnet
2025-06-05 18:50 ` [PATCH bpf-next v3 1/3] bpf: Add cookie to raw_tp bpf_link_info patchwork-bot+netdevbpf

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).