Message ID | 20210907230111.1959279-1-yhs@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: add support for new btf kind BTF_KIND_TAG | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | success | PR summary |
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/cc_maintainers | warning | 8 maintainers not CCed: thunder.leizhen@huawei.com kpsingh@kernel.org john.fastabend@gmail.com iii@linux.ibm.com songliubraving@fb.com quentin@isovalent.com netdev@vger.kernel.org kafai@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | CHECK: Please don't use multiple blank lines WARNING: line length of 81 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
bpf/vmtest-bpf-next | success | VM_Test |
On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@fb.com> wrote: > > added bpftool support to dump BTF_KIND_TAG information. > The new bpftool will be used in later patches to dump > btf in the test bpf program object file. > > Signed-off-by: Yonghong Song <yhs@fb.com> > --- > tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > index f7e5ff3586c9..89c17ea62d8e 100644 > --- a/tools/bpf/bpftool/btf.c > +++ b/tools/bpf/bpftool/btf.c > @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { > [BTF_KIND_VAR] = "VAR", > [BTF_KIND_DATASEC] = "DATASEC", > [BTF_KIND_FLOAT] = "FLOAT", > + [BTF_KIND_TAG] = "TAG", > }; > > struct btf_attach_table { > @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, > printf(" size=%u", t->size); > break; > } > + case BTF_KIND_TAG: { > + const struct btf_tag *tag = (const void *)(t + 1); > + > + extra empty line? > + if (json_output) { > + jsonw_uint_field(w, "type_id", t->type); > + if (btf_kflag(t)) > + jsonw_int_field(w, "comp_id", -1); > + else > + jsonw_uint_field(w, "comp_id", tag->comp_id); > + } else if (btf_kflag(t)) { > + printf(" type_id=%u, comp_id=-1", t->type); > + } else { > + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); > + } here not using kflag would be more natural as well ;) > + break; > + } > default: > break; > } > -- > 2.30.2 >
On Wed, Sep 8, 2021 at 10:28 PM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote: > > On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@fb.com> wrote: > > > > added bpftool support to dump BTF_KIND_TAG information. > > The new bpftool will be used in later patches to dump > > btf in the test bpf program object file. > > What should be done for `bpftool btf dump file <path> format c` if BTF contains btf_tag? Should it ignore it silently? Should it error out? Or should we corrupt output (as will be the case right now, I think)? > > Signed-off-by: Yonghong Song <yhs@fb.com> > > --- > > tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > > index f7e5ff3586c9..89c17ea62d8e 100644 > > --- a/tools/bpf/bpftool/btf.c > > +++ b/tools/bpf/bpftool/btf.c > > @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { > > [BTF_KIND_VAR] = "VAR", > > [BTF_KIND_DATASEC] = "DATASEC", > > [BTF_KIND_FLOAT] = "FLOAT", > > + [BTF_KIND_TAG] = "TAG", > > }; > > > > struct btf_attach_table { > > @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, > > printf(" size=%u", t->size); > > break; > > } > > + case BTF_KIND_TAG: { > > + const struct btf_tag *tag = (const void *)(t + 1); > > + > > + > > extra empty line? > > > + if (json_output) { > > + jsonw_uint_field(w, "type_id", t->type); > > + if (btf_kflag(t)) > > + jsonw_int_field(w, "comp_id", -1); > > + else > > + jsonw_uint_field(w, "comp_id", tag->comp_id); > > + } else if (btf_kflag(t)) { > > + printf(" type_id=%u, comp_id=-1", t->type); > > + } else { > > + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); > > + } > > here not using kflag would be more natural as well ;) > > > + break; > > + } > > default: > > break; > > } > > -- > > 2.30.2 > >
On 9/8/21 10:28 PM, Andrii Nakryiko wrote: > On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@fb.com> wrote: >> >> added bpftool support to dump BTF_KIND_TAG information. >> The new bpftool will be used in later patches to dump >> btf in the test bpf program object file. >> >> Signed-off-by: Yonghong Song <yhs@fb.com> >> --- >> tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ >> 1 file changed, 18 insertions(+) >> >> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c >> index f7e5ff3586c9..89c17ea62d8e 100644 >> --- a/tools/bpf/bpftool/btf.c >> +++ b/tools/bpf/bpftool/btf.c >> @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { >> [BTF_KIND_VAR] = "VAR", >> [BTF_KIND_DATASEC] = "DATASEC", >> [BTF_KIND_FLOAT] = "FLOAT", >> + [BTF_KIND_TAG] = "TAG", >> }; >> >> struct btf_attach_table { >> @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, >> printf(" size=%u", t->size); >> break; >> } >> + case BTF_KIND_TAG: { >> + const struct btf_tag *tag = (const void *)(t + 1); >> + >> + > > extra empty line? ack. > >> + if (json_output) { >> + jsonw_uint_field(w, "type_id", t->type); >> + if (btf_kflag(t)) >> + jsonw_int_field(w, "comp_id", -1); >> + else >> + jsonw_uint_field(w, "comp_id", tag->comp_id); >> + } else if (btf_kflag(t)) { >> + printf(" type_id=%u, comp_id=-1", t->type); >> + } else { >> + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); >> + } > > here not using kflag would be more natural as well ;) definitely. > >> + break; >> + } >> default: >> break; >> } >> -- >> 2.30.2 >>
On 9/8/21 10:33 PM, Andrii Nakryiko wrote: > On Wed, Sep 8, 2021 at 10:28 PM Andrii Nakryiko > <andrii.nakryiko@gmail.com> wrote: >> >> On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@fb.com> wrote: >>> >>> added bpftool support to dump BTF_KIND_TAG information. >>> The new bpftool will be used in later patches to dump >>> btf in the test bpf program object file. >>> > > What should be done for `bpftool btf dump file <path> format c` if BTF > contains btf_tag? Should it ignore it silently? Should it error out? > Or should we corrupt output (as will be the case right now, I think)? Currently it is silently ignored. The attribute information is mostly used in the kernel by verification purpose and the kernel uses its own btf to check. Adding such attributes to vmlinux.h, bpf program BTF will contain these attributes but they may not be used by the kernel verifier at least for now. So I think we can delay this as a followup if there is a real need. > >>> Signed-off-by: Yonghong Song <yhs@fb.com> >>> --- >>> tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ >>> 1 file changed, 18 insertions(+) >>> >>> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c >>> index f7e5ff3586c9..89c17ea62d8e 100644 >>> --- a/tools/bpf/bpftool/btf.c >>> +++ b/tools/bpf/bpftool/btf.c >>> @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { >>> [BTF_KIND_VAR] = "VAR", >>> [BTF_KIND_DATASEC] = "DATASEC", >>> [BTF_KIND_FLOAT] = "FLOAT", >>> + [BTF_KIND_TAG] = "TAG", >>> }; >>> >>> struct btf_attach_table { >>> @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, >>> printf(" size=%u", t->size); >>> break; >>> } >>> + case BTF_KIND_TAG: { >>> + const struct btf_tag *tag = (const void *)(t + 1); >>> + >>> + >> >> extra empty line? >> >>> + if (json_output) { >>> + jsonw_uint_field(w, "type_id", t->type); >>> + if (btf_kflag(t)) >>> + jsonw_int_field(w, "comp_id", -1); >>> + else >>> + jsonw_uint_field(w, "comp_id", tag->comp_id); >>> + } else if (btf_kflag(t)) { >>> + printf(" type_id=%u, comp_id=-1", t->type); >>> + } else { >>> + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); >>> + } >> >> here not using kflag would be more natural as well ;) >> >>> + break; >>> + } >>> default: >>> break; >>> } >>> -- >>> 2.30.2 >>>
On Fri, Sep 10, 2021 at 9:39 AM Yonghong Song <yhs@fb.com> wrote: > > > > On 9/8/21 10:33 PM, Andrii Nakryiko wrote: > > On Wed, Sep 8, 2021 at 10:28 PM Andrii Nakryiko > > <andrii.nakryiko@gmail.com> wrote: > >> > >> On Tue, Sep 7, 2021 at 4:01 PM Yonghong Song <yhs@fb.com> wrote: > >>> > >>> added bpftool support to dump BTF_KIND_TAG information. > >>> The new bpftool will be used in later patches to dump > >>> btf in the test bpf program object file. > >>> > > > > What should be done for `bpftool btf dump file <path> format c` if BTF > > contains btf_tag? Should it ignore it silently? Should it error out? > > Or should we corrupt output (as will be the case right now, I think)? > > Currently it is silently ignored. The attribute information is mostly > used in the kernel by verification purpose and the kernel uses its own > btf to check. > > Adding such attributes to vmlinux.h, bpf program BTF will contain these > attributes but they may not be used by the kernel verifier at least > for now. > > So I think we can delay this as a followup if there is a real need. Sounds good. Just wanted to confirm that we won't get some libbpf warning emitted inside vmlinux.h, making it non-compilable. > > > > >>> Signed-off-by: Yonghong Song <yhs@fb.com> > >>> --- > >>> tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ > >>> 1 file changed, 18 insertions(+) > >>> > >>> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > >>> index f7e5ff3586c9..89c17ea62d8e 100644 > >>> --- a/tools/bpf/bpftool/btf.c > >>> +++ b/tools/bpf/bpftool/btf.c > >>> @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { > >>> [BTF_KIND_VAR] = "VAR", > >>> [BTF_KIND_DATASEC] = "DATASEC", > >>> [BTF_KIND_FLOAT] = "FLOAT", > >>> + [BTF_KIND_TAG] = "TAG", > >>> }; > >>> > >>> struct btf_attach_table { > >>> @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, > >>> printf(" size=%u", t->size); > >>> break; > >>> } > >>> + case BTF_KIND_TAG: { > >>> + const struct btf_tag *tag = (const void *)(t + 1); > >>> + > >>> + > >> > >> extra empty line? > >> > >>> + if (json_output) { > >>> + jsonw_uint_field(w, "type_id", t->type); > >>> + if (btf_kflag(t)) > >>> + jsonw_int_field(w, "comp_id", -1); > >>> + else > >>> + jsonw_uint_field(w, "comp_id", tag->comp_id); > >>> + } else if (btf_kflag(t)) { > >>> + printf(" type_id=%u, comp_id=-1", t->type); > >>> + } else { > >>> + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); > >>> + } > >> > >> here not using kflag would be more natural as well ;) > >> > >>> + break; > >>> + } > >>> default: > >>> break; > >>> } > >>> -- > >>> 2.30.2 > >>>
diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index f7e5ff3586c9..89c17ea62d8e 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -37,6 +37,7 @@ static const char * const btf_kind_str[NR_BTF_KINDS] = { [BTF_KIND_VAR] = "VAR", [BTF_KIND_DATASEC] = "DATASEC", [BTF_KIND_FLOAT] = "FLOAT", + [BTF_KIND_TAG] = "TAG", }; struct btf_attach_table { @@ -347,6 +348,23 @@ static int dump_btf_type(const struct btf *btf, __u32 id, printf(" size=%u", t->size); break; } + case BTF_KIND_TAG: { + const struct btf_tag *tag = (const void *)(t + 1); + + + if (json_output) { + jsonw_uint_field(w, "type_id", t->type); + if (btf_kflag(t)) + jsonw_int_field(w, "comp_id", -1); + else + jsonw_uint_field(w, "comp_id", tag->comp_id); + } else if (btf_kflag(t)) { + printf(" type_id=%u, comp_id=-1", t->type); + } else { + printf(" type_id=%u, comp_id=%u", t->type, tag->comp_id); + } + break; + } default: break; }
added bpftool support to dump BTF_KIND_TAG information. The new bpftool will be used in later patches to dump btf in the test bpf program object file. Signed-off-by: Yonghong Song <yhs@fb.com> --- tools/bpf/bpftool/btf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)