On Tue, May 16, 2023 at 5:39 AM Yafang Shao <laoar.shao@xxxxxxxxx> wrote: > > The target_btf_id can help us understand which kernel function is > linked by a tracing prog. The target_btf_id and target_obj_id have > already been exposed to userspace, so we just need to show them. > > The result as follows, > > $ cat /proc/10673/fdinfo/10 > pos: 0 > flags: 02000000 > mnt_id: 15 > ino: 2094 > link_type: tracing > link_id: 2 > prog_tag: a04f5eef06a7f555 > prog_id: 13 > attach_type: 24 > target_obj_id: 1 > target_btf_id: 13964 > > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> > Acked-by: Song Liu <song@xxxxxxxxxx> > --- > kernel/bpf/syscall.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 909c112..870395a 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -2968,10 +2968,18 @@ static void bpf_tracing_link_show_fdinfo(const struct bpf_link *link, > { > struct bpf_tracing_link *tr_link = > container_of(link, struct bpf_tracing_link, link.link); > + u32 target_btf_id; > + u32 target_obj_id; nit: combine on a single line? > > + bpf_trampoline_unpack_key(tr_link->trampoline->key, > + &target_obj_id, &target_btf_id); formatting seems odd?... > seq_printf(seq, > - "attach_type:\t%d\n", > - tr_link->attach_type); > + "attach_type:\t%d\n" > + "target_obj_id:\t%u\n" > + "target_btf_id:\t%u\n", > + tr_link->attach_type, > + target_obj_id, > + target_btf_id); > } > > static int bpf_tracing_link_fill_link_info(const struct bpf_link *link, > -- > 1.8.3.1 >