bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: Show target_{obj,btf}_id for tracing link
@ 2023-05-16 12:39 Yafang Shao
  2023-05-16 12:39 ` [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo Yafang Shao
  2023-05-16 12:39 ` [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info Yafang Shao
  0 siblings, 2 replies; 9+ messages in thread
From: Yafang Shao @ 2023-05-16 12:39 UTC (permalink / raw)
  To: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa
  Cc: bpf, Yafang Shao

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.

For some other link types like perf_event and kprobe_multi, it is not
easy to find which functions are attached either. We may support
->fill_link_info for them in the future.

Yafang Shao (2):
  bpf: Show target_{obj,btf}_id in tracing link fdinfo
  bpftool: Show target_{obj,btf}_id in tracing link info

 kernel/bpf/syscall.c     | 12 ++++++++++--
 tools/bpf/bpftool/link.c |  4 ++++
 2 files changed, 14 insertions(+), 2 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo
  2023-05-16 12:39 [PATCH bpf-next 0/2] bpf: Show target_{obj,btf}_id for tracing link Yafang Shao
@ 2023-05-16 12:39 ` Yafang Shao
  2023-05-16 22:27   ` Andrii Nakryiko
  2023-05-16 12:39 ` [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info Yafang Shao
  1 sibling, 1 reply; 9+ messages in thread
From: Yafang Shao @ 2023-05-16 12:39 UTC (permalink / raw)
  To: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa
  Cc: bpf, Yafang Shao

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@gmail.com>
Acked-by: Song Liu <song@kernel.org>
---
 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;
 
+	bpf_trampoline_unpack_key(tr_link->trampoline->key,
+							  &target_obj_id, &target_btf_id);
 	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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info
  2023-05-16 12:39 [PATCH bpf-next 0/2] bpf: Show target_{obj,btf}_id for tracing link Yafang Shao
  2023-05-16 12:39 ` [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo Yafang Shao
@ 2023-05-16 12:39 ` Yafang Shao
  2023-05-16 13:01   ` Quentin Monnet
  1 sibling, 1 reply; 9+ messages in thread
From: Yafang Shao @ 2023-05-16 12:39 UTC (permalink / raw)
  To: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa
  Cc: bpf, Yafang Shao

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,

$ tools/bpf/bpftool/bpftool link show
2: tracing  prog 13
        prog_type tracing  attach_type trace_fentry
        target_obj_id 1  target_btf_id 13964
        pids trace(10673)

$ tools/bpf/bpftool/bpftool link show -j
[{"id":2,"type":"tracing","prog_id":13,"prog_type":"tracing","attach_type":"trace_fentry","target_obj_id":1,"target_btf_id":13964,"pids":[{"pid":10673,"comm":"trace"}]}]

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Acked-by: Song Liu <song@kernel.org>
---
 tools/bpf/bpftool/link.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
index 243b74e..cfe896f 100644
--- a/tools/bpf/bpftool/link.c
+++ b/tools/bpf/bpftool/link.c
@@ -195,6 +195,8 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
 
 		show_link_attach_type_json(info->tracing.attach_type,
 					   json_wtr);
+		jsonw_uint_field(json_wtr, "target_obj_id", info->tracing.target_obj_id);
+		jsonw_uint_field(json_wtr, "target_btf_id", info->tracing.target_btf_id);
 		break;
 	case BPF_LINK_TYPE_CGROUP:
 		jsonw_lluint_field(json_wtr, "cgroup_id",
@@ -375,6 +377,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
 			printf("\n\tprog_type %u  ", prog_info.type);
 
 		show_link_attach_type_plain(info->tracing.attach_type);
+		printf("\n\ttarget_obj_id %u  target_btf_id %u  ",
+			   info->tracing.target_obj_id, info->tracing.target_btf_id);
 		break;
 	case BPF_LINK_TYPE_CGROUP:
 		printf("\n\tcgroup_id %zu  ", (size_t)info->cgroup.cgroup_id);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info
  2023-05-16 12:39 ` [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info Yafang Shao
@ 2023-05-16 13:01   ` Quentin Monnet
  2023-05-16 13:09     ` Yafang Shao
  0 siblings, 1 reply; 9+ messages in thread
From: Quentin Monnet @ 2023-05-16 13:01 UTC (permalink / raw)
  To: Yafang Shao, song, ast, daniel, andrii, kafai, yhs,
	john.fastabend, kpsingh, sdf, haoluo, jolsa
  Cc: bpf

2023-05-16 12:39 UTC+0000 ~ Yafang Shao <laoar.shao@gmail.com>
> 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,
> 
> $ tools/bpf/bpftool/bpftool link show
> 2: tracing  prog 13
>         prog_type tracing  attach_type trace_fentry
>         target_obj_id 1  target_btf_id 13964
>         pids trace(10673)
> 
> $ tools/bpf/bpftool/bpftool link show -j
> [{"id":2,"type":"tracing","prog_id":13,"prog_type":"tracing","attach_type":"trace_fentry","target_obj_id":1,"target_btf_id":13964,"pids":[{"pid":10673,"comm":"trace"}]}]
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Acked-by: Song Liu <song@kernel.org>
> ---
>  tools/bpf/bpftool/link.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> index 243b74e..cfe896f 100644
> --- a/tools/bpf/bpftool/link.c
> +++ b/tools/bpf/bpftool/link.c
> @@ -195,6 +195,8 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
>  
>  		show_link_attach_type_json(info->tracing.attach_type,
>  					   json_wtr);
> +		jsonw_uint_field(json_wtr, "target_obj_id", info->tracing.target_obj_id);
> +		jsonw_uint_field(json_wtr, "target_btf_id", info->tracing.target_btf_id);
>  		break;
>  	case BPF_LINK_TYPE_CGROUP:
>  		jsonw_lluint_field(json_wtr, "cgroup_id",
> @@ -375,6 +377,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
>  			printf("\n\tprog_type %u  ", prog_info.type);
>  
>  		show_link_attach_type_plain(info->tracing.attach_type);
> +		printf("\n\ttarget_obj_id %u  target_btf_id %u  ",
> +			   info->tracing.target_obj_id, info->tracing.target_btf_id);

Older kernels won't share this info, so maybe we can skip this printf()
in plain output if the target object and BTF ids are 0?

>  		break;
>  	case BPF_LINK_TYPE_CGROUP:
>  		printf("\n\tcgroup_id %zu  ", (size_t)info->cgroup.cgroup_id);


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info
  2023-05-16 13:01   ` Quentin Monnet
@ 2023-05-16 13:09     ` Yafang Shao
  2023-05-16 13:19       ` Quentin Monnet
  0 siblings, 1 reply; 9+ messages in thread
From: Yafang Shao @ 2023-05-16 13:09 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, bpf

On Tue, May 16, 2023 at 9:01 PM Quentin Monnet <quentin@isovalent.com> wrote:
>
> 2023-05-16 12:39 UTC+0000 ~ Yafang Shao <laoar.shao@gmail.com>
> > 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,
> >
> > $ tools/bpf/bpftool/bpftool link show
> > 2: tracing  prog 13
> >         prog_type tracing  attach_type trace_fentry
> >         target_obj_id 1  target_btf_id 13964
> >         pids trace(10673)
> >
> > $ tools/bpf/bpftool/bpftool link show -j
> > [{"id":2,"type":"tracing","prog_id":13,"prog_type":"tracing","attach_type":"trace_fentry","target_obj_id":1,"target_btf_id":13964,"pids":[{"pid":10673,"comm":"trace"}]}]
> >
> > Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> > Acked-by: Song Liu <song@kernel.org>
> > ---
> >  tools/bpf/bpftool/link.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> > index 243b74e..cfe896f 100644
> > --- a/tools/bpf/bpftool/link.c
> > +++ b/tools/bpf/bpftool/link.c
> > @@ -195,6 +195,8 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
> >
> >               show_link_attach_type_json(info->tracing.attach_type,
> >                                          json_wtr);
> > +             jsonw_uint_field(json_wtr, "target_obj_id", info->tracing.target_obj_id);
> > +             jsonw_uint_field(json_wtr, "target_btf_id", info->tracing.target_btf_id);
> >               break;
> >       case BPF_LINK_TYPE_CGROUP:
> >               jsonw_lluint_field(json_wtr, "cgroup_id",
> > @@ -375,6 +377,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
> >                       printf("\n\tprog_type %u  ", prog_info.type);
> >
> >               show_link_attach_type_plain(info->tracing.attach_type);
> > +             printf("\n\ttarget_obj_id %u  target_btf_id %u  ",
> > +                        info->tracing.target_obj_id, info->tracing.target_btf_id);
>
> Older kernels won't share this info, so maybe we can skip this printf()
> in plain output if the target object and BTF ids are 0?
>

Good suggestion. Will change it in the next version.
BTW, shouldn't we skip it in the json output as well ?

-- 
Regards
Yafang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info
  2023-05-16 13:09     ` Yafang Shao
@ 2023-05-16 13:19       ` Quentin Monnet
  2023-05-16 13:20         ` Yafang Shao
  0 siblings, 1 reply; 9+ messages in thread
From: Quentin Monnet @ 2023-05-16 13:19 UTC (permalink / raw)
  To: Yafang Shao
  Cc: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, bpf

2023-05-16 21:09 UTC+0800 ~ Yafang Shao <laoar.shao@gmail.com>
> On Tue, May 16, 2023 at 9:01 PM Quentin Monnet <quentin@isovalent.com> wrote:
>>
>> 2023-05-16 12:39 UTC+0000 ~ Yafang Shao <laoar.shao@gmail.com>
>>> 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,
>>>
>>> $ tools/bpf/bpftool/bpftool link show
>>> 2: tracing  prog 13
>>>         prog_type tracing  attach_type trace_fentry
>>>         target_obj_id 1  target_btf_id 13964
>>>         pids trace(10673)
>>>
>>> $ tools/bpf/bpftool/bpftool link show -j
>>> [{"id":2,"type":"tracing","prog_id":13,"prog_type":"tracing","attach_type":"trace_fentry","target_obj_id":1,"target_btf_id":13964,"pids":[{"pid":10673,"comm":"trace"}]}]
>>>
>>> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>>> Acked-by: Song Liu <song@kernel.org>
>>> ---
>>>  tools/bpf/bpftool/link.c | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
>>> index 243b74e..cfe896f 100644
>>> --- a/tools/bpf/bpftool/link.c
>>> +++ b/tools/bpf/bpftool/link.c
>>> @@ -195,6 +195,8 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
>>>
>>>               show_link_attach_type_json(info->tracing.attach_type,
>>>                                          json_wtr);
>>> +             jsonw_uint_field(json_wtr, "target_obj_id", info->tracing.target_obj_id);
>>> +             jsonw_uint_field(json_wtr, "target_btf_id", info->tracing.target_btf_id);
>>>               break;
>>>       case BPF_LINK_TYPE_CGROUP:
>>>               jsonw_lluint_field(json_wtr, "cgroup_id",
>>> @@ -375,6 +377,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
>>>                       printf("\n\tprog_type %u  ", prog_info.type);
>>>
>>>               show_link_attach_type_plain(info->tracing.attach_type);
>>> +             printf("\n\ttarget_obj_id %u  target_btf_id %u  ",
>>> +                        info->tracing.target_obj_id, info->tracing.target_btf_id);
>>
>> Older kernels won't share this info, so maybe we can skip this printf()
>> in plain output if the target object and BTF ids are 0?
>>
> 
> Good suggestion. Will change it in the next version.
> BTW, shouldn't we skip it in the json output as well ?

I'd keep it in JSON. Plain output is for reading in the console, we want
to make it easy for users to find the relevant info. JSON is for machine
consumption, it's OK to be more exhaustive and to leave it to the
consuming program to decide what's relevant and what's not.

Quentin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info
  2023-05-16 13:19       ` Quentin Monnet
@ 2023-05-16 13:20         ` Yafang Shao
  0 siblings, 0 replies; 9+ messages in thread
From: Yafang Shao @ 2023-05-16 13:20 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, bpf

On Tue, May 16, 2023 at 9:19 PM Quentin Monnet <quentin@isovalent.com> wrote:
>
> 2023-05-16 21:09 UTC+0800 ~ Yafang Shao <laoar.shao@gmail.com>
> > On Tue, May 16, 2023 at 9:01 PM Quentin Monnet <quentin@isovalent.com> wrote:
> >>
> >> 2023-05-16 12:39 UTC+0000 ~ Yafang Shao <laoar.shao@gmail.com>
> >>> 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,
> >>>
> >>> $ tools/bpf/bpftool/bpftool link show
> >>> 2: tracing  prog 13
> >>>         prog_type tracing  attach_type trace_fentry
> >>>         target_obj_id 1  target_btf_id 13964
> >>>         pids trace(10673)
> >>>
> >>> $ tools/bpf/bpftool/bpftool link show -j
> >>> [{"id":2,"type":"tracing","prog_id":13,"prog_type":"tracing","attach_type":"trace_fentry","target_obj_id":1,"target_btf_id":13964,"pids":[{"pid":10673,"comm":"trace"}]}]
> >>>
> >>> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> >>> Acked-by: Song Liu <song@kernel.org>
> >>> ---
> >>>  tools/bpf/bpftool/link.c | 4 ++++
> >>>  1 file changed, 4 insertions(+)
> >>>
> >>> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
> >>> index 243b74e..cfe896f 100644
> >>> --- a/tools/bpf/bpftool/link.c
> >>> +++ b/tools/bpf/bpftool/link.c
> >>> @@ -195,6 +195,8 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
> >>>
> >>>               show_link_attach_type_json(info->tracing.attach_type,
> >>>                                          json_wtr);
> >>> +             jsonw_uint_field(json_wtr, "target_obj_id", info->tracing.target_obj_id);
> >>> +             jsonw_uint_field(json_wtr, "target_btf_id", info->tracing.target_btf_id);
> >>>               break;
> >>>       case BPF_LINK_TYPE_CGROUP:
> >>>               jsonw_lluint_field(json_wtr, "cgroup_id",
> >>> @@ -375,6 +377,8 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
> >>>                       printf("\n\tprog_type %u  ", prog_info.type);
> >>>
> >>>               show_link_attach_type_plain(info->tracing.attach_type);
> >>> +             printf("\n\ttarget_obj_id %u  target_btf_id %u  ",
> >>> +                        info->tracing.target_obj_id, info->tracing.target_btf_id);
> >>
> >> Older kernels won't share this info, so maybe we can skip this printf()
> >> in plain output if the target object and BTF ids are 0?
> >>
> >
> > Good suggestion. Will change it in the next version.
> > BTW, shouldn't we skip it in the json output as well ?
>
> I'd keep it in JSON. Plain output is for reading in the console, we want
> to make it easy for users to find the relevant info. JSON is for machine
> consumption, it's OK to be more exhaustive and to leave it to the
> consuming program to decide what's relevant and what's not.
>

Got it. Thanks for the explanation.


-- 
Regards
Yafang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo
  2023-05-16 12:39 ` [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo Yafang Shao
@ 2023-05-16 22:27   ` Andrii Nakryiko
  2023-05-17  3:00     ` Yafang Shao
  0 siblings, 1 reply; 9+ messages in thread
From: Andrii Nakryiko @ 2023-05-16 22:27 UTC (permalink / raw)
  To: Yafang Shao
  Cc: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, bpf

On Tue, May 16, 2023 at 5:39 AM Yafang Shao <laoar.shao@gmail.com> 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@gmail.com>
> Acked-by: Song Liu <song@kernel.org>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo
  2023-05-16 22:27   ` Andrii Nakryiko
@ 2023-05-17  3:00     ` Yafang Shao
  0 siblings, 0 replies; 9+ messages in thread
From: Yafang Shao @ 2023-05-17  3:00 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: song, ast, daniel, andrii, kafai, yhs, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, bpf

On Wed, May 17, 2023 at 6:28 AM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Tue, May 16, 2023 at 5:39 AM Yafang Shao <laoar.shao@gmail.com> 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@gmail.com>
> > Acked-by: Song Liu <song@kernel.org>
> > ---
> >  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?
>

Will change it.

> >
> > +       bpf_trampoline_unpack_key(tr_link->trampoline->key,
> > +                                                         &target_obj_id, &target_btf_id);
>
> formatting seems odd?...
>

It is because the vim table size on my current dev server is 4. Will
correct it.

-- 
Regards
Yafang

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-17  3:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 12:39 [PATCH bpf-next 0/2] bpf: Show target_{obj,btf}_id for tracing link Yafang Shao
2023-05-16 12:39 ` [PATCH bpf-next 1/2] bpf: Show target_{obj,btf}_id in tracing link fdinfo Yafang Shao
2023-05-16 22:27   ` Andrii Nakryiko
2023-05-17  3:00     ` Yafang Shao
2023-05-16 12:39 ` [PATCH bpf-next 2/2] bpftool: Show target_{obj,btf}_id in tracing link info Yafang Shao
2023-05-16 13:01   ` Quentin Monnet
2023-05-16 13:09     ` Yafang Shao
2023-05-16 13:19       ` Quentin Monnet
2023-05-16 13:20         ` Yafang Shao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).