bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 3/3] selftests/bpf: allow compiling BPF objects without BTF
Date: Mon, 22 Mar 2021 10:54:43 -0700	[thread overview]
Message-ID: <20210322175443.zflwaf7dstpg4y2b@ast-mbp> (raw)
In-Reply-To: <CAEf4BzbdgPnw81+diwcvAokv+S6osqvAAzSQYt_BoYbga9t-qQ@mail.gmail.com>

On Mon, Mar 22, 2021 at 09:56:19AM -0700, Andrii Nakryiko wrote:
> On Sun, Mar 21, 2021 at 6:07 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Sat, Mar 20, 2021 at 10:00:57AM -0700, Andrii Nakryiko wrote:
> > > On Fri, Mar 19, 2021 at 7:22 PM Alexei Starovoitov
> > > <alexei.starovoitov@gmail.com> wrote:
> > > >
> > > > On Fri, Mar 19, 2021 at 01:59:09PM -0700, Andrii Nakryiko wrote:
> > > > > Add ability to skip BTF generation for some BPF object files. This is done
> > > > > through using a convention of .nobtf.c file name suffix.
> > > > >
> > > > > Also add third statically linked file to static_linked selftest. This file has
> > > > > no BTF, causing resulting object file to have only some of DATASEC BTF types.
> > > > > It also is using (from BPF code) global variables. This tests both libbpf's
> > > > > static linking logic and bpftool's skeleton generation logic.
> > > >
> > > > I don't like the long term direction of patch 1 and 3.
> > > > BTF is mandatory for the most bpf kernel features added in the last couple years.
> > > > Making user space do quirks for object files without BTF is not something
> > > > we should support or maintain. If there is no BTF the linker and skeleton
> > > > generation shouldn't crash, of course, but they should reject such object.
> > >
> > > I don't think tools need to enforce any policies like that. They are
> > > tools and should be unassuming about the way they are going to be used
> > > to the extent possible.
> >
> > Right and bpftool/skeleton was used with BTF since day one.
> > Without BTF the skeleton core ideas are lost. The skeleton api
> > gives no benefit. So what's the point of adding support for skeleton without BTF?
> > Is there a user that would benefit? If so, what will they gain from
> > such BTF-less skeleton?
> 
> The only part of skeleton API that's not available is convenient
> user-space access to global variables. If you don't use global
> variables you don't use BTF at all with skeleton. So all features but
> one work without BTF just fine: compile-time maps and progs (and
> links) references, embedding object file in .skel.h, and even
> automatic memory-mapping of .data/.rodata/.bss (just unknown struct
> layout).
> 
> Compile-time maps and progs and separately object file embedding in C
> header are useful in their own rights, even individually. There is no
> single "core idea" of the BPF skeleton in my mind. What is it for you?
> 
> So given none of the fixes are horrible hacks and won't incur
> additional maintenance costs, what's the problem with accepting them?

Because they double the maintenance cost now and double the support forever.
We never needed to worry about skeleton without BTF and now it would be
a thing ? So all tests realistically need to be doubled: with and without BTF.
Even more so for static linking. If one .o has BTF and another doesn't
what linker suppose to do? Keep it, but the linked BTF will sort of cover
both .o-s, but line info in some funcs will be missing.
All these weird combinations would need to be tested.
The sensible thing to do would be to reject skel generation without BTF
and reject linking without BTF. The user most likely forgot -g during
compilation of bpf prog. The bpftool should give the helpful message
in such case. Whether it's generating skel or linking. Silently proceeding
and generating half-featured skeleton is not what user wanted.

  reply	other threads:[~2021-03-22 17:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 20:59 [PATCH bpf-next 0/3] Handle no-BTF object files better Andrii Nakryiko
2021-03-19 20:59 ` [PATCH bpf-next 1/3] bpftool: improve skeleton generation for objects without BTF Andrii Nakryiko
2021-03-19 20:59 ` [PATCH bpf-next 2/3] libbpf: skip BTF fixup if object file has no BTF Andrii Nakryiko
2021-03-19 21:25   ` Jiri Olsa
2021-03-19 20:59 ` [PATCH bpf-next 3/3] selftests/bpf: allow compiling BPF objects without BTF Andrii Nakryiko
2021-03-20  2:21   ` Alexei Starovoitov
2021-03-20 17:00     ` Andrii Nakryiko
2021-03-22  1:07       ` Alexei Starovoitov
2021-03-22 16:56         ` Andrii Nakryiko
2021-03-22 17:54           ` Alexei Starovoitov [this message]
2021-03-26 16:44             ` Andrii Nakryiko
2021-03-29  1:16               ` Alexei Starovoitov
2021-03-29  6:09                 ` Andrii Nakryiko
2021-03-29 18:55                   ` Alexei Starovoitov
2021-03-30 18:00                     ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210322175443.zflwaf7dstpg4y2b@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).