Commit d5c16492 authored by Jiri Olsa's avatar Jiri Olsa Committed by Alexei Starovoitov

bpf: Add cookie to perf_event bpf_link_info records

At the moment we don't store cookie for perf_event probes,
while we do that for the rest of the probes.

Adding cookie fields to struct bpf_link_info perf event
probe records:

  perf_event.uprobe
  perf_event.kprobe
  perf_event.tracepoint
  perf_event.perf_event

And the code to store that in bpf_link_info struct.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarSong Liu <song@kernel.org>
Acked-by: default avatarYafang Shao <laoar.shao@gmail.com>
Link: https://lore.kernel.org/r/20240119110505.400573-2-jolsa@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent bbc094b3
...@@ -6582,6 +6582,7 @@ struct bpf_link_info { ...@@ -6582,6 +6582,7 @@ struct bpf_link_info {
__aligned_u64 file_name; /* in/out */ __aligned_u64 file_name; /* in/out */
__u32 name_len; __u32 name_len;
__u32 offset; /* offset from file_name */ __u32 offset; /* offset from file_name */
__u64 cookie;
} uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ } uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */
struct { struct {
__aligned_u64 func_name; /* in/out */ __aligned_u64 func_name; /* in/out */
...@@ -6589,14 +6590,19 @@ struct bpf_link_info { ...@@ -6589,14 +6590,19 @@ struct bpf_link_info {
__u32 offset; /* offset from func_name */ __u32 offset; /* offset from func_name */
__u64 addr; __u64 addr;
__u64 missed; __u64 missed;
__u64 cookie;
} kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ } kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */
struct { struct {
__aligned_u64 tp_name; /* in/out */ __aligned_u64 tp_name; /* in/out */
__u32 name_len; __u32 name_len;
__u32 :32;
__u64 cookie;
} tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */ } tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */
struct { struct {
__u64 config; __u64 config;
__u32 type; __u32 type;
__u32 :32;
__u64 cookie;
} event; /* BPF_PERF_EVENT_EVENT */ } event; /* BPF_PERF_EVENT_EVENT */
}; };
} perf_event; } perf_event;
......
...@@ -3501,6 +3501,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event, ...@@ -3501,6 +3501,7 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event,
if (!kallsyms_show_value(current_cred())) if (!kallsyms_show_value(current_cred()))
addr = 0; addr = 0;
info->perf_event.kprobe.addr = addr; info->perf_event.kprobe.addr = addr;
info->perf_event.kprobe.cookie = event->bpf_cookie;
return 0; return 0;
} }
#endif #endif
...@@ -3526,6 +3527,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event, ...@@ -3526,6 +3527,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event,
else else
info->perf_event.type = BPF_PERF_EVENT_UPROBE; info->perf_event.type = BPF_PERF_EVENT_UPROBE;
info->perf_event.uprobe.offset = offset; info->perf_event.uprobe.offset = offset;
info->perf_event.uprobe.cookie = event->bpf_cookie;
return 0; return 0;
} }
#endif #endif
...@@ -3553,6 +3555,7 @@ static int bpf_perf_link_fill_tracepoint(const struct perf_event *event, ...@@ -3553,6 +3555,7 @@ static int bpf_perf_link_fill_tracepoint(const struct perf_event *event,
uname = u64_to_user_ptr(info->perf_event.tracepoint.tp_name); uname = u64_to_user_ptr(info->perf_event.tracepoint.tp_name);
ulen = info->perf_event.tracepoint.name_len; ulen = info->perf_event.tracepoint.name_len;
info->perf_event.type = BPF_PERF_EVENT_TRACEPOINT; info->perf_event.type = BPF_PERF_EVENT_TRACEPOINT;
info->perf_event.tracepoint.cookie = event->bpf_cookie;
return bpf_perf_link_fill_common(event, uname, ulen, NULL, NULL, NULL, NULL); return bpf_perf_link_fill_common(event, uname, ulen, NULL, NULL, NULL, NULL);
} }
...@@ -3561,6 +3564,7 @@ static int bpf_perf_link_fill_perf_event(const struct perf_event *event, ...@@ -3561,6 +3564,7 @@ static int bpf_perf_link_fill_perf_event(const struct perf_event *event,
{ {
info->perf_event.event.type = event->attr.type; info->perf_event.event.type = event->attr.type;
info->perf_event.event.config = event->attr.config; info->perf_event.event.config = event->attr.config;
info->perf_event.event.cookie = event->bpf_cookie;
info->perf_event.type = BPF_PERF_EVENT_EVENT; info->perf_event.type = BPF_PERF_EVENT_EVENT;
return 0; return 0;
} }
......
...@@ -6582,6 +6582,7 @@ struct bpf_link_info { ...@@ -6582,6 +6582,7 @@ struct bpf_link_info {
__aligned_u64 file_name; /* in/out */ __aligned_u64 file_name; /* in/out */
__u32 name_len; __u32 name_len;
__u32 offset; /* offset from file_name */ __u32 offset; /* offset from file_name */
__u64 cookie;
} uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */ } uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */
struct { struct {
__aligned_u64 func_name; /* in/out */ __aligned_u64 func_name; /* in/out */
...@@ -6589,14 +6590,19 @@ struct bpf_link_info { ...@@ -6589,14 +6590,19 @@ struct bpf_link_info {
__u32 offset; /* offset from func_name */ __u32 offset; /* offset from func_name */
__u64 addr; __u64 addr;
__u64 missed; __u64 missed;
__u64 cookie;
} kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */ } kprobe; /* BPF_PERF_EVENT_KPROBE, BPF_PERF_EVENT_KRETPROBE */
struct { struct {
__aligned_u64 tp_name; /* in/out */ __aligned_u64 tp_name; /* in/out */
__u32 name_len; __u32 name_len;
__u32 :32;
__u64 cookie;
} tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */ } tracepoint; /* BPF_PERF_EVENT_TRACEPOINT */
struct { struct {
__u64 config; __u64 config;
__u32 type; __u32 type;
__u32 :32;
__u64 cookie;
} event; /* BPF_PERF_EVENT_EVENT */ } event; /* BPF_PERF_EVENT_EVENT */
}; };
} perf_event; } perf_event;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment