mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:24:45 +01:00
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 <chen.dylane@linux.dev> Link: https://lore.kernel.org/r/20250702153958.639852-2-chen.dylane@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
803f0700a3
commit
b4dfe26fbf
1 changed files with 44 additions and 0 deletions
|
|
@ -3152,10 +3152,54 @@ static int bpf_uprobe_multi_link_fill_link_info(const struct bpf_link *link,
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static void bpf_uprobe_multi_show_fdinfo(const struct bpf_link *link,
|
||||
struct seq_file *seq)
|
||||
{
|
||||
struct bpf_uprobe_multi_link *umulti_link;
|
||||
char *p, *buf;
|
||||
pid_t pid;
|
||||
|
||||
umulti_link = container_of(link, struct bpf_uprobe_multi_link, link);
|
||||
|
||||
buf = kmalloc(PATH_MAX, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
p = d_path(&umulti_link->path, buf, PATH_MAX);
|
||||
if (IS_ERR(p)) {
|
||||
kfree(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
pid = umulti_link->task ?
|
||||
task_pid_nr_ns(umulti_link->task, task_active_pid_ns(current)) : 0;
|
||||
seq_printf(seq,
|
||||
"uprobe_cnt:\t%u\n"
|
||||
"pid:\t%u\n"
|
||||
"path:\t%s\n",
|
||||
umulti_link->cnt, pid, p);
|
||||
|
||||
seq_printf(seq, "%s\t %s\t %s\n", "cookie", "offset", "ref_ctr_offset");
|
||||
for (int i = 0; i < umulti_link->cnt; i++) {
|
||||
seq_printf(seq,
|
||||
"%llu\t %#llx\t %#lx\n",
|
||||
umulti_link->uprobes[i].cookie,
|
||||
umulti_link->uprobes[i].offset,
|
||||
umulti_link->uprobes[i].ref_ctr_offset);
|
||||
}
|
||||
|
||||
kfree(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct bpf_link_ops bpf_uprobe_multi_link_lops = {
|
||||
.release = bpf_uprobe_multi_link_release,
|
||||
.dealloc_deferred = bpf_uprobe_multi_link_dealloc,
|
||||
.fill_link_info = bpf_uprobe_multi_link_fill_link_info,
|
||||
#ifdef CONFIG_PROC_FS
|
||||
.show_fdinfo = bpf_uprobe_multi_show_fdinfo,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int uprobe_prog_run(struct bpf_uprobe *uprobe,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue