Skip to content

Commit b4dfe26

Browse files
Tao ChenAlexei Starovoitov
authored andcommitted
bpf: Add show_fdinfo for uprobe_multi
Show uprobe_multi link info with fdinfo, the info as follows: link_type: uprobe_multi link_id: 9 prog_tag: e729f789e34a8eca prog_id: 39 uprobe_cnt: 3 pid: 0 path: /home/dylane/bpf/tools/testing/selftests/bpf/test_progs cookie offset ref_ctr_offset 3 0xa69f13 0x0 1 0xa69f1e 0x0 2 0xa69f29 0x0 Signed-off-by: Tao Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 803f070 commit b4dfe26

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

kernel/trace/bpf_trace.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,10 +3152,54 @@ static int bpf_uprobe_multi_link_fill_link_info(const struct bpf_link *link,
31523152
return err;
31533153
}
31543154

3155+
#ifdef CONFIG_PROC_FS
3156+
static void bpf_uprobe_multi_show_fdinfo(const struct bpf_link *link,
3157+
struct seq_file *seq)
3158+
{
3159+
struct bpf_uprobe_multi_link *umulti_link;
3160+
char *p, *buf;
3161+
pid_t pid;
3162+
3163+
umulti_link = container_of(link, struct bpf_uprobe_multi_link, link);
3164+
3165+
buf = kmalloc(PATH_MAX, GFP_KERNEL);
3166+
if (!buf)
3167+
return;
3168+
3169+
p = d_path(&umulti_link->path, buf, PATH_MAX);
3170+
if (IS_ERR(p)) {
3171+
kfree(buf);
3172+
return;
3173+
}
3174+
3175+
pid = umulti_link->task ?
3176+
task_pid_nr_ns(umulti_link->task, task_active_pid_ns(current)) : 0;
3177+
seq_printf(seq,
3178+
"uprobe_cnt:\t%u\n"
3179+
"pid:\t%u\n"
3180+
"path:\t%s\n",
3181+
umulti_link->cnt, pid, p);
3182+
3183+
seq_printf(seq, "%s\t %s\t %s\n", "cookie", "offset", "ref_ctr_offset");
3184+
for (int i = 0; i < umulti_link->cnt; i++) {
3185+
seq_printf(seq,
3186+
"%llu\t %#llx\t %#lx\n",
3187+
umulti_link->uprobes[i].cookie,
3188+
umulti_link->uprobes[i].offset,
3189+
umulti_link->uprobes[i].ref_ctr_offset);
3190+
}
3191+
3192+
kfree(buf);
3193+
}
3194+
#endif
3195+
31553196
static const struct bpf_link_ops bpf_uprobe_multi_link_lops = {
31563197
.release = bpf_uprobe_multi_link_release,
31573198
.dealloc_deferred = bpf_uprobe_multi_link_dealloc,
31583199
.fill_link_info = bpf_uprobe_multi_link_fill_link_info,
3200+
#ifdef CONFIG_PROC_FS
3201+
.show_fdinfo = bpf_uprobe_multi_show_fdinfo,
3202+
#endif
31593203
};
31603204

31613205
static int uprobe_prog_run(struct bpf_uprobe *uprobe,

0 commit comments

Comments
 (0)