Message ID | 20201110011932.3201430-6-andrii@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | BPF |
Headers | show |
Series | Integrate kernel module BTF support | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | fail | Errors and warnings before: 4 this patch: 4 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | fail | Link |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
> On Nov 9, 2020, at 5:19 PM, Andrii Nakryiko <andrii@kernel.org> wrote: [...] > ... > > Tested-by: Alan Maguire <alan.maguire@oracle.com> > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> With one nit: > --- > tools/bpf/bpftool/btf.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > index c96b56e8e3a4..ed5e97157241 100644 > --- a/tools/bpf/bpftool/btf.c > +++ b/tools/bpf/bpftool/btf.c > @@ -742,9 +742,14 @@ show_btf_plain(struct bpf_btf_info *info, int fd, > struct btf_attach_table *btf_map_table) > { > struct btf_attach_point *obj; > + const char *name = u64_to_ptr(info->name); > int n; > > printf("%u: ", info->id); > + if (info->kernel_btf) > + printf("name [%s] ", name); > + else if (name && name[0]) > + printf("name %s ", name); Maybe explicitly say "name <anonymous>" for btf without a name? I think it will benefit plain output. > printf("size %uB", info->btf_size); > > n = 0; [...]
On Tue, Nov 10, 2020 at 5:15 PM Song Liu <songliubraving@fb.com> wrote: > > > > > On Nov 9, 2020, at 5:19 PM, Andrii Nakryiko <andrii@kernel.org> wrote: > > [...] > > > ... > > > > Tested-by: Alan Maguire <alan.maguire@oracle.com> > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> > > Acked-by: Song Liu <songliubraving@fb.com> > > With one nit: > > > --- > > tools/bpf/bpftool/btf.c | 28 +++++++++++++++++++++++++++- > > 1 file changed, 27 insertions(+), 1 deletion(-) > > > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > > index c96b56e8e3a4..ed5e97157241 100644 > > --- a/tools/bpf/bpftool/btf.c > > +++ b/tools/bpf/bpftool/btf.c > > @@ -742,9 +742,14 @@ show_btf_plain(struct bpf_btf_info *info, int fd, > > struct btf_attach_table *btf_map_table) > > { > > struct btf_attach_point *obj; > > + const char *name = u64_to_ptr(info->name); > > int n; > > > > printf("%u: ", info->id); > > + if (info->kernel_btf) > > + printf("name [%s] ", name); > > + else if (name && name[0]) > > + printf("name %s ", name); > > Maybe explicitly say "name <anonymous>" for btf without a name? I think > it will benefit plain output. This patch set is already landed. But I can do a follow-up patch to add this. > > > printf("size %uB", info->btf_size); > > > > n = 0; > > [...]
> On Nov 10, 2020, at 8:19 PM, Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote: > > On Tue, Nov 10, 2020 at 5:15 PM Song Liu <songliubraving@fb.com> wrote: >> >> >> >>> On Nov 9, 2020, at 5:19 PM, Andrii Nakryiko <andrii@kernel.org> wrote: >> >> [...] >> >>> ... >>> >>> Tested-by: Alan Maguire <alan.maguire@oracle.com> >>> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> >> >> Acked-by: Song Liu <songliubraving@fb.com> >> >> With one nit: >> >>> --- >>> tools/bpf/bpftool/btf.c | 28 +++++++++++++++++++++++++++- >>> 1 file changed, 27 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c >>> index c96b56e8e3a4..ed5e97157241 100644 >>> --- a/tools/bpf/bpftool/btf.c >>> +++ b/tools/bpf/bpftool/btf.c >>> @@ -742,9 +742,14 @@ show_btf_plain(struct bpf_btf_info *info, int fd, >>> struct btf_attach_table *btf_map_table) >>> { >>> struct btf_attach_point *obj; >>> + const char *name = u64_to_ptr(info->name); >>> int n; >>> >>> printf("%u: ", info->id); >>> + if (info->kernel_btf) >>> + printf("name [%s] ", name); >>> + else if (name && name[0]) >>> + printf("name %s ", name); >> >> Maybe explicitly say "name <anonymous>" for btf without a name? I think >> it will benefit plain output. > > This patch set is already landed. But I can do a follow-up patch to add this. I realized this was applied soon after sending this. Yeah, a follow-up patch would be great. Thanks, Song
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index c96b56e8e3a4..ed5e97157241 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -742,9 +742,14 @@ show_btf_plain(struct bpf_btf_info *info, int fd, struct btf_attach_table *btf_map_table) { struct btf_attach_point *obj; + const char *name = u64_to_ptr(info->name); int n; printf("%u: ", info->id); + if (info->kernel_btf) + printf("name [%s] ", name); + else if (name && name[0]) + printf("name %s ", name); printf("size %uB", info->btf_size); n = 0; @@ -771,6 +776,7 @@ show_btf_json(struct bpf_btf_info *info, int fd, struct btf_attach_table *btf_map_table) { struct btf_attach_point *obj; + const char *name = u64_to_ptr(info->name); jsonw_start_object(json_wtr); /* btf object */ jsonw_uint_field(json_wtr, "id", info->id); @@ -796,6 +802,11 @@ show_btf_json(struct bpf_btf_info *info, int fd, emit_obj_refs_json(&refs_table, info->id, json_wtr); /* pids */ + jsonw_bool_field(json_wtr, "kernel", info->kernel_btf); + + if (name && name[0]) + jsonw_string_field(json_wtr, "name", name); + jsonw_end_object(json_wtr); /* btf object */ } @@ -803,15 +814,30 @@ static int show_btf(int fd, struct btf_attach_table *btf_prog_table, struct btf_attach_table *btf_map_table) { - struct bpf_btf_info info = {}; + struct bpf_btf_info info; __u32 len = sizeof(info); + char name[64]; int err; + memset(&info, 0, sizeof(info)); err = bpf_obj_get_info_by_fd(fd, &info, &len); if (err) { p_err("can't get BTF object info: %s", strerror(errno)); return -1; } + /* if kernel support emitting BTF object name, pass name pointer */ + if (info.name_len) { + memset(&info, 0, sizeof(info)); + info.name_len = sizeof(name); + info.name = ptr_to_u64(name); + len = sizeof(info); + + err = bpf_obj_get_info_by_fd(fd, &info, &len); + if (err) { + p_err("can't get BTF object info: %s", strerror(errno)); + return -1; + } + } if (json_output) show_btf_json(&info, fd, btf_prog_table, btf_map_table);