Skip to content

Commit 8231533

Browse files
olsajirianakryiko
authored andcommitted
bpf: Add support to retrieve ref_ctr_offset for uprobe perf link
Adding support to retrieve ref_ctr_offset for uprobe perf link, which got somehow omitted from the initial uprobe link info changes. Signed-off-by: Jiri Olsa <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Yafang Shao <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent cb4a119 commit 8231533

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

include/uapi/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6724,6 +6724,7 @@ struct bpf_link_info {
67246724
__u32 name_len;
67256725
__u32 offset; /* offset from file_name */
67266726
__u64 cookie;
6727+
__u64 ref_ctr_offset;
67276728
} uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */
67286729
struct {
67296730
__aligned_u64 func_name; /* in/out */

kernel/bpf/syscall.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,14 +3800,14 @@ static int bpf_perf_link_fill_kprobe(const struct perf_event *event,
38003800
static int bpf_perf_link_fill_uprobe(const struct perf_event *event,
38013801
struct bpf_link_info *info)
38023802
{
3803+
u64 ref_ctr_offset, offset;
38033804
char __user *uname;
3804-
u64 addr, offset;
38053805
u32 ulen, type;
38063806
int err;
38073807

38083808
uname = u64_to_user_ptr(info->perf_event.uprobe.file_name);
38093809
ulen = info->perf_event.uprobe.name_len;
3810-
err = bpf_perf_link_fill_common(event, uname, &ulen, &offset, &addr,
3810+
err = bpf_perf_link_fill_common(event, uname, &ulen, &offset, &ref_ctr_offset,
38113811
&type, NULL);
38123812
if (err)
38133813
return err;
@@ -3819,6 +3819,7 @@ static int bpf_perf_link_fill_uprobe(const struct perf_event *event,
38193819
info->perf_event.uprobe.name_len = ulen;
38203820
info->perf_event.uprobe.offset = offset;
38213821
info->perf_event.uprobe.cookie = event->bpf_cookie;
3822+
info->perf_event.uprobe.ref_ctr_offset = ref_ctr_offset;
38223823
return 0;
38233824
}
38243825
#endif

kernel/trace/trace_uprobe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
14891489
: BPF_FD_TYPE_UPROBE;
14901490
*filename = tu->filename;
14911491
*probe_offset = tu->offset;
1492-
*probe_addr = 0;
1492+
*probe_addr = tu->ref_ctr_offset;
14931493
return 0;
14941494
}
14951495
#endif /* CONFIG_PERF_EVENTS */

tools/include/uapi/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6724,6 +6724,7 @@ struct bpf_link_info {
67246724
__u32 name_len;
67256725
__u32 offset; /* offset from file_name */
67266726
__u64 cookie;
6727+
__u64 ref_ctr_offset;
67276728
} uprobe; /* BPF_PERF_EVENT_UPROBE, BPF_PERF_EVENT_URETPROBE */
67286729
struct {
67296730
__aligned_u64 func_name; /* in/out */

0 commit comments

Comments
 (0)