All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] tools/bpftool: show btf id in program information
@ 2019-04-10  4:56 Prashant Bhole
  2019-04-10 15:39 ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: Prashant Bhole @ 2019-04-10  4:56 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Prashant Bhole, Jakub Kicinski, Quentin Monnet, Martin KaFai Lau,
	Song Liu, Yonghong Song, netdev

Let's add a way to know whether a program has btf context.
Patch adds 'btf_id' in the output of program listing.
When btf_id is present, it means program has btf context.

Sample output:
user@test# bpftool prog list
25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
	loaded_at 2019-04-10T11:44:20+0900  uid 0
	xlated 488B  not jited  memlock 4096B  map_ids 23
	btf_id 1

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
---
 tools/bpf/bpftool/prog.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index d2be5a06c339..81067803189e 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -249,6 +249,9 @@ static void print_prog_json(struct bpf_prog_info *info, int fd)
 	if (info->nr_map_ids)
 		show_prog_maps(fd, info->nr_map_ids);
 
+	if (info->btf_id)
+		jsonw_int_field(json_wtr, "btf_id", info->btf_id);
+
 	if (!hash_empty(prog_table.table)) {
 		struct pinned_obj *obj;
 
@@ -319,6 +322,9 @@ static void print_prog_plain(struct bpf_prog_info *info, int fd)
 		}
 	}
 
+	if (info->btf_id)
+		printf("\n\tbtf_id %d\n", info->btf_id);
+
 	printf("\n");
 }
 
-- 
2.17.2



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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-10  4:56 [PATCH bpf-next] tools/bpftool: show btf id in program information Prashant Bhole
@ 2019-04-10 15:39 ` Jakub Kicinski
  2019-04-11  7:51   ` Daniel Borkmann
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2019-04-10 15:39 UTC (permalink / raw)
  To: Prashant Bhole
  Cc: Alexei Starovoitov, Daniel Borkmann, Quentin Monnet,
	Martin KaFai Lau, Song Liu, Yonghong Song, netdev

On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
> Let's add a way to know whether a program has btf context.
> Patch adds 'btf_id' in the output of program listing.
> When btf_id is present, it means program has btf context.
> 
> Sample output:
> user@test# bpftool prog list
> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
> 	loaded_at 2019-04-10T11:44:20+0900  uid 0
> 	xlated 488B  not jited  memlock 4096B  map_ids 23
> 	btf_id 1
> 
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-10 15:39 ` Jakub Kicinski
@ 2019-04-11  7:51   ` Daniel Borkmann
  2019-04-11 15:37     ` Yonghong Song
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Borkmann @ 2019-04-11  7:51 UTC (permalink / raw)
  To: Jakub Kicinski, Prashant Bhole
  Cc: Alexei Starovoitov, Quentin Monnet, Martin KaFai Lau, Song Liu,
	Yonghong Song, netdev

On 04/10/2019 05:39 PM, Jakub Kicinski wrote:
> On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
>> Let's add a way to know whether a program has btf context.
>> Patch adds 'btf_id' in the output of program listing.
>> When btf_id is present, it means program has btf context.
>>
>> Sample output:
>> user@test# bpftool prog list
>> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
>> 	loaded_at 2019-04-10T11:44:20+0900  uid 0
>> 	xlated 488B  not jited  memlock 4096B  map_ids 23
>> 	btf_id 1
>>
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> 
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied, thanks!

What would be the plan for the maps listing?

I think what we could also potentially have is some way to dump
the BTF type info based on such above id. Perhaps it would make
sense to similarly share the verifier's printer with bpftool?

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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-11  7:51   ` Daniel Borkmann
@ 2019-04-11 15:37     ` Yonghong Song
  2019-04-16  0:54       ` Andrii Nakryiko
  0 siblings, 1 reply; 7+ messages in thread
From: Yonghong Song @ 2019-04-11 15:37 UTC (permalink / raw)
  To: Daniel Borkmann, Jakub Kicinski, Prashant Bhole
  Cc: Alexei Starovoitov, Quentin Monnet, Martin Lau, Song Liu, netdev,
	Andrii Nakryiko


cc Andrii

On 4/11/19 12:51 AM, Daniel Borkmann wrote:
> On 04/10/2019 05:39 PM, Jakub Kicinski wrote:
>> On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
>>> Let's add a way to know whether a program has btf context.
>>> Patch adds 'btf_id' in the output of program listing.
>>> When btf_id is present, it means program has btf context.
>>>
>>> Sample output:
>>> user@test# bpftool prog list
>>> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
>>> 	loaded_at 2019-04-10T11:44:20+0900  uid 0
>>> 	xlated 488B  not jited  memlock 4096B  map_ids 23
>>> 	btf_id 1
>>>
>>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>>
>> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> 
> Applied, thanks!
> 
> What would be the plan for the maps listing?
[...]
> I think what we could also potentially have is some way to dump
> the BTF type info based on such above id. Perhaps it would make
> sense to similarly share the verifier's printer with bpftool?

Agreed. It does make sense to print the detailed info for a btf id
through bpftool.

Andrii had a btf dumper to dump types as well as BTF elf file .btf.ext
contents in his private branch. Maybe Andrii can comment further
on this subject.

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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-11 15:37     ` Yonghong Song
@ 2019-04-16  0:54       ` Andrii Nakryiko
  2019-04-16  8:02         ` Daniel Borkmann
  2019-04-16  8:57         ` Prashant Bhole
  0 siblings, 2 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2019-04-16  0:54 UTC (permalink / raw)
  To: Yonghong Song
  Cc: Daniel Borkmann, Jakub Kicinski, Prashant Bhole,
	Alexei Starovoitov, Quentin Monnet, Martin Lau, Song Liu, netdev,
	Andrii Nakryiko

On Thu, Apr 11, 2019 at 8:38 AM Yonghong Song <yhs@fb.com> wrote:
>
>
> cc Andrii
>
> On 4/11/19 12:51 AM, Daniel Borkmann wrote:
> > On 04/10/2019 05:39 PM, Jakub Kicinski wrote:
> >> On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
> >>> Let's add a way to know whether a program has btf context.
> >>> Patch adds 'btf_id' in the output of program listing.
> >>> When btf_id is present, it means program has btf context.
> >>>
> >>> Sample output:
> >>> user@test# bpftool prog list
> >>> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
> >>>     loaded_at 2019-04-10T11:44:20+0900  uid 0
> >>>     xlated 488B  not jited  memlock 4096B  map_ids 23
> >>>     btf_id 1
> >>>
> >>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> >>
> >> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> >
> > Applied, thanks!
> >
> > What would be the plan for the maps listing?
> [...]
> > I think what we could also potentially have is some way to dump
> > the BTF type info based on such above id. Perhaps it would make
> > sense to similarly share the verifier's printer with bpftool?
>
> Agreed. It does make sense to print the detailed info for a btf id
> through bpftool.
>
> Andrii had a btf dumper to dump types as well as BTF elf file .btf.ext
> contents in his private branch. Maybe Andrii can comment further
> on this subject.

Yes, absolutely, we should have this as part of bpftool. I'm going to
start porting this logic from my private prototype very soon.

I think we should be able to have both low-level (though still
human-readable) BTF dump as close to underlying BTF data as possible,
as well as an ability to dump struct/union/datasec definitions in
compilable C format. E.g., for struct/union it will be struct/union
definition, as well as all the necessary dependent types, for
datasec/vars it will be a list of global variables declaration w/ all
the necessary types. Thoughts?

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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-16  0:54       ` Andrii Nakryiko
@ 2019-04-16  8:02         ` Daniel Borkmann
  2019-04-16  8:57         ` Prashant Bhole
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2019-04-16  8:02 UTC (permalink / raw)
  To: Andrii Nakryiko, Yonghong Song
  Cc: Jakub Kicinski, Prashant Bhole, Alexei Starovoitov,
	Quentin Monnet, Martin Lau, Song Liu, netdev, Andrii Nakryiko

On 04/16/2019 02:54 AM, Andrii Nakryiko wrote:
> On Thu, Apr 11, 2019 at 8:38 AM Yonghong Song <yhs@fb.com> wrote:
>>
>> cc Andrii
>>
>> On 4/11/19 12:51 AM, Daniel Borkmann wrote:
>>> On 04/10/2019 05:39 PM, Jakub Kicinski wrote:
>>>> On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
>>>>> Let's add a way to know whether a program has btf context.
>>>>> Patch adds 'btf_id' in the output of program listing.
>>>>> When btf_id is present, it means program has btf context.
>>>>>
>>>>> Sample output:
>>>>> user@test# bpftool prog list
>>>>> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
>>>>>     loaded_at 2019-04-10T11:44:20+0900  uid 0
>>>>>     xlated 488B  not jited  memlock 4096B  map_ids 23
>>>>>     btf_id 1
>>>>>
>>>>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>>>>
>>>> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>>>
>>> Applied, thanks!
>>>
>>> What would be the plan for the maps listing?
>> [...]
>>> I think what we could also potentially have is some way to dump
>>> the BTF type info based on such above id. Perhaps it would make
>>> sense to similarly share the verifier's printer with bpftool?
>>
>> Agreed. It does make sense to print the detailed info for a btf id
>> through bpftool.
>>
>> Andrii had a btf dumper to dump types as well as BTF elf file .btf.ext
>> contents in his private branch. Maybe Andrii can comment further
>> on this subject.
> 
> Yes, absolutely, we should have this as part of bpftool. I'm going to
> start porting this logic from my private prototype very soon.
> 
> I think we should be able to have both low-level (though still
> human-readable) BTF dump as close to underlying BTF data as possible,
> as well as an ability to dump struct/union/datasec definitions in
> compilable C format. E.g., for struct/union it will be struct/union
> definition, as well as all the necessary dependent types, for
> datasec/vars it will be a list of global variables declaration w/ all
> the necessary types. Thoughts?

Yes, that sounds great to me! Both is needed. For the latter, it would
also be useful if I could do e.g. a bpftool prog btf dump id xyz and it
will show a pahole like output where I can see offset, padding information
as well as size + cachelines needed for all types used by the loaded BPF
program.

Thanks,
Daniel

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

* Re: [PATCH bpf-next] tools/bpftool: show btf id in program information
  2019-04-16  0:54       ` Andrii Nakryiko
  2019-04-16  8:02         ` Daniel Borkmann
@ 2019-04-16  8:57         ` Prashant Bhole
  1 sibling, 0 replies; 7+ messages in thread
From: Prashant Bhole @ 2019-04-16  8:57 UTC (permalink / raw)
  To: Andrii Nakryiko, Yonghong Song
  Cc: Daniel Borkmann, Jakub Kicinski, Alexei Starovoitov,
	Quentin Monnet, Martin Lau, Song Liu, netdev, Andrii Nakryiko



On 4/16/2019 9:54 AM, Andrii Nakryiko wrote:
> On Thu, Apr 11, 2019 at 8:38 AM Yonghong Song <yhs@fb.com> wrote:
>>
>>
>> cc Andrii
>>
>> On 4/11/19 12:51 AM, Daniel Borkmann wrote:
>>> On 04/10/2019 05:39 PM, Jakub Kicinski wrote:
>>>> On Wed, 10 Apr 2019 13:56:42 +0900, Prashant Bhole wrote:
>>>>> Let's add a way to know whether a program has btf context.
>>>>> Patch adds 'btf_id' in the output of program listing.
>>>>> When btf_id is present, it means program has btf context.
>>>>>
>>>>> Sample output:
>>>>> user@test# bpftool prog list
>>>>> 25: xdp  name xdp_prog1  tag 539ec6ce11b52f98  gpl
>>>>>      loaded_at 2019-04-10T11:44:20+0900  uid 0
>>>>>      xlated 488B  not jited  memlock 4096B  map_ids 23
>>>>>      btf_id 1
>>>>>
>>>>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>>>>
>>>> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>>>
>>> Applied, thanks!
>>>
>>> What would be the plan for the maps listing?
>> [...]
>>> I think what we could also potentially have is some way to dump
>>> the BTF type info based on such above id. Perhaps it would make
>>> sense to similarly share the verifier's printer with bpftool?
>>
>> Agreed. It does make sense to print the detailed info for a btf id
>> through bpftool.
>>
>> Andrii had a btf dumper to dump types as well as BTF elf file .btf.ext
>> contents in his private branch. Maybe Andrii can comment further
>> on this subject.
> 
> Yes, absolutely, we should have this as part of bpftool. I'm going to
> start porting this logic from my private prototype very soon.
> 
> I think we should be able to have both low-level (though still
> human-readable) BTF dump as close to underlying BTF data as possible,
> as well as an ability to dump struct/union/datasec definitions in
> compilable C format. E.g., for struct/union it will be struct/union
> definition, as well as all the necessary dependent types, for
> datasec/vars it will be a list of global variables declaration w/ all
> the necessary types. Thoughts?
> 

It will be nice to have this functionality in bpftool.
Meanwhile I will send a patch to show btf id of map.


- prashant



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

end of thread, other threads:[~2019-04-16  8:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10  4:56 [PATCH bpf-next] tools/bpftool: show btf id in program information Prashant Bhole
2019-04-10 15:39 ` Jakub Kicinski
2019-04-11  7:51   ` Daniel Borkmann
2019-04-11 15:37     ` Yonghong Song
2019-04-16  0:54       ` Andrii Nakryiko
2019-04-16  8:02         ` Daniel Borkmann
2019-04-16  8:57         ` Prashant Bhole

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.