Re: [PATCH bpf-next 11/15] bpftool: add skeleton codegen command
From: Jakub Kicinski
Date: Fri Dec 13 2019 - 12:47:19 EST
On Thu, 12 Dec 2019 22:48:10 -0800, Andrii Nakryiko wrote:
> > improve and hack on it. Baking it into as system tool is counter
> > productive. Users should be able to grab the skel tool single-file
> > source and adjust for their project's needs. Distributing your own copy
> > of bpftool because you want to adjust skel is a heavy lift.
>
> Skeleton is auto-generated code, it's not supposed to be tweaked or
> "adjusted" by hand.
Obviously not, I said adjusting the codegen tool, not the output.
> Because next time you do tiny change to your BPF
> source code (just swap order of two global variables), skeleton
> changes. If someone is not satisfied with the way skeleton generation
> looks like, they should propose changes and contribute to common
> algorithm. Or, of course, they can just go and re-implement it on
> their own, if struct bpf_object_skeleton suits them still (which is
> what libbpf works with). Then they can do it in Python, Go, Scala,
> Java, Perl, whatnot. But somehow I doubt anyone would want to do that.
>
> > And maybe one day we do have Python/Go/whatever bindings, and we can
> > convert the skel tool to a higher level language with modern templating.
>
> Because high-level implementation is going to be so much simpler and
> shorter, really? Is it that complicated in C right now? What's the
> real benefit of waiting to be able to do it in "higher level" language
> beyond being the contrarian?
I did not say wait, I said do C and convert to something else once easy.
You really gotta read responses more carefully :/
> Apart from \n\ (which is mostly hidden
> from view), I don't think high-level templates are going to be much
> more clean.
>
> > > We cannot and should not adopt kernel-like ABI guarantees to user space
> > > code. It will paralyze the development.
> >
> > Discussion for another time :)
>
> If this "experimental" disclaimer is a real blocker for all of this, I
> don't mind making it a public API right now. bpf_object_skeleton is
> already designed to be backward/forward compatible with size of struct
> itself and all the sub-structs recorded during initialization. I
> didn't mean to create impression like this whole approach is so raw
> and untried that it will most certainly break and we are still unsure
> about it. It's not and it certainly improves set up code for
> real-world applications. We might need to add some extra option here
> and there, but the stuff that's there already will stay as is.
As explained the experimental disclaimer is fairly useless and it gives
people precedent for maybe not caring as hard as they should about
ironing the details out before sending code upstream.
I think we can just add a switch or option for improved generation when
needed. You already check there are not extra trailing arguments so we
should be good.
> Would moving all the skeleton-related stuff into libbpf.h and
> "stabilizing" it make all this more tolerable for you?
I think I'm too tired if this to have an option any more.