Skip to content

Commit da7e9c0

Browse files
Tao ChenAlexei Starovoitov
authored andcommitted
bpf: Add show_fdinfo for kprobe_multi
Show kprobe_multi link info with fdinfo, the info as follows: link_type: kprobe_multi link_id: 1 prog_tag: a69740b9746f7da8 prog_id: 21 kprobe_cnt: 8 missed: 0 cookie func 1 bpf_fentry_test1+0x0/0x20 7 bpf_fentry_test2+0x0/0x20 2 bpf_fentry_test3+0x0/0x20 3 bpf_fentry_test4+0x0/0x20 4 bpf_fentry_test5+0x0/0x20 5 bpf_fentry_test6+0x0/0x20 6 bpf_fentry_test7+0x0/0x20 8 bpf_fentry_test8+0x0/0x10 Signed-off-by: Tao Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent b4dfe26 commit da7e9c0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

kernel/trace/bpf_trace.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,10 +2619,37 @@ static int bpf_kprobe_multi_link_fill_link_info(const struct bpf_link *link,
26192619
return err;
26202620
}
26212621

2622+
#ifdef CONFIG_PROC_FS
2623+
static void bpf_kprobe_multi_show_fdinfo(const struct bpf_link *link,
2624+
struct seq_file *seq)
2625+
{
2626+
struct bpf_kprobe_multi_link *kmulti_link;
2627+
2628+
kmulti_link = container_of(link, struct bpf_kprobe_multi_link, link);
2629+
2630+
seq_printf(seq,
2631+
"kprobe_cnt:\t%u\n"
2632+
"missed:\t%lu\n",
2633+
kmulti_link->cnt,
2634+
kmulti_link->fp.nmissed);
2635+
2636+
seq_printf(seq, "%s\t %s\n", "cookie", "func");
2637+
for (int i = 0; i < kmulti_link->cnt; i++) {
2638+
seq_printf(seq,
2639+
"%llu\t %pS\n",
2640+
kmulti_link->cookies[i],
2641+
(void *)kmulti_link->addrs[i]);
2642+
}
2643+
}
2644+
#endif
2645+
26222646
static const struct bpf_link_ops bpf_kprobe_multi_link_lops = {
26232647
.release = bpf_kprobe_multi_link_release,
26242648
.dealloc_deferred = bpf_kprobe_multi_link_dealloc,
26252649
.fill_link_info = bpf_kprobe_multi_link_fill_link_info,
2650+
#ifdef CONFIG_PROC_FS
2651+
.show_fdinfo = bpf_kprobe_multi_show_fdinfo,
2652+
#endif
26262653
};
26272654

26282655
static void bpf_kprobe_multi_cookie_swap(void *a, void *b, int size, const void *priv)

0 commit comments

Comments
 (0)