Re: [PATCH bpf-next v4 3/8] bpftool: Add gen btf command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 21, 2022 at 12:40 PM Mauricio Vásquez Bernal
<mauricio@xxxxxxxxxx> wrote:
>
> On Wed, Jan 12, 2022 at 1:08 PM Quentin Monnet <quentin@xxxxxxxxxxxxx> wrote:
> >
> > 2022-01-12 09:27 UTC-0500 ~ Mauricio Vásquez <mauricio@xxxxxxxxxx>
> > > This command is implemented under the "gen" command in bpftool and the
> > > syntax is the following:
> > >
> > > $ bpftool gen btf INPUT OUTPUT OBJECT(S)
> >
> > Thanks a lot for this work!
> >
> > Please update the relevant manual page under Documentation, to let users
> > know how to use the feature. You may also consider adding an example at
> > the end of that document.
> >
>
> We're working on it, and will be part of the next spin.
>
> > The bash completion script should also be updated with the new "btf"
> > subcommand for "gen". Given that all the arguments are directories and
> > files, it should not be hard.
> >
>
> Will do.
>
> > Have you considered adding tests for the feature? There are a few
> > bpftool-related selftests under tools/testing/selftests/bpf/.
> >
>
> Yes, we have but it seems not that trivial. One idea I have is to
> include a couple of BTF source files from
> https://github.com/aquasecurity/btfhub-archive/ and create a test
> program that generates some field, type and enum relocations. Then we
> could check if the generated BTF file has the expected types, fields
> and so on by parsing it and using the BTF API from libbpf. One concern
> about it is the size of those two source BTF files (~5MB each),
> perhaps we should not include a full file but something that is
> already "trimmed"? Another possibility is to use
> "/sys/kernel/btf/vmlinux" but it'll limit the test to machines with
> CONFIG_DEBUG_INFO_BTF.
>
> Do you have any ideas / feedback on this one? Should the tests be
> included in this series or can we push them later on?

See how we test CO-RE relocations and how we use C files to get custom
BTFs. See progs/btf_* and prog_tests/core_reloc.c selftests. You don't
have to use real vmlinux BTF to test this functionality.


>
> > >
> > > INPUT can be either a single BTF file or a folder containing BTF files,
> > > when it's a folder, a BTF file is generated for each BTF file contained
> > > in this folder. OUTPUT is the file (or folder) where generated files are
> > > stored and OBJECT(S) is the list of bpf objects we want to generate the
> > > BTF file(s) for (each generated BTF file contains all the types needed
> > > by all the objects).
> > >
> > > Signed-off-by: Mauricio Vásquez <mauricio@xxxxxxxxxx>
> > > Signed-off-by: Rafael David Tinoco <rafael.tinoco@xxxxxxxxxxx>
> > > Signed-off-by: Lorenzo Fontana <lorenzo.fontana@xxxxxxxxxx>
> > > Signed-off-by: Leonardo Di Donato <leonardo.didonato@xxxxxxxxxx>
> > > ---
> > >  tools/bpf/bpftool/gen.c | 117 ++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 117 insertions(+)
> > >

[...]




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux