bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "David Ahern" <dsahern@gmail.com>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
	"Hangbin Liu" <haliu@redhat.com>,
	"Stephen Hemminger" <stephen@networkplumber.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"David Miller" <davem@davemloft.net>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	"Jiri Benc" <jbenc@redhat.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: Re: [PATCHv3 iproute2-next 0/5] iproute2: add libbpf support
Date: Fri, 6 Nov 2020 13:25:03 -0800	[thread overview]
Message-ID: <CAEf4BzanB7arOamPY7mKf4uxPmcmRYz7dvij_VxewYg9_y+GAg@mail.gmail.com> (raw)
In-Reply-To: <3d7090ab-8bc9-bc68-642f-1e84d7a6ec08@mojatatu.com>

On Fri, Nov 6, 2020 at 7:27 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
>
> On 2020-11-05 4:01 p.m., Andrii Nakryiko wrote:
> > On Thu, Nov 5, 2020 at 6:05 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> >>
> >> On 2020-11-04 10:19 p.m., David Ahern wrote:
> >>
> >> [..]
>
> [..]
>
> >> 2cents feedback from a dabbler in ebpf on user experience:
> >>
> >> What David described above *has held me back*.
> >> Over time it seems things have gotten better with libbpf
> >> (although a few times i find myself copying includes from the
> >> latest iproute into libbpf). I ended up just doing static links.
> >> The idea of upgrading clang/llvm every 2 months i revisit ebpf is
> >> the most painful. At times code that used to compile just fine
> >> earlier doesnt anymore. There's a minor issue of requiring i install
> >
> > Do you have a specific example of something that stopped compiling?
> > I'm not saying that can't happen, but we definitely try hard to avoid
> > any regressions. I might be forgetting something, but I don't recall
> > the situation when something would stop compiling just due to newer
> > libbpf.
> >
>
> Unfortunately the ecosystem is more than libbpf; sometimes it is
> the kernel code that is being exercised by libbpf that is problematic.
> This may sound unfair to libbpf but it is hard to separate the two for
> someone who is dabbling like me.

I get that. Clang is also part of the ecosystem, along the kernel,
pahole, etc. It's a lot of moving parts and we strive to keep them all
working well together. It's not 100% smooth all the time, but that's
at least the goal.

>
> The last issue iirc correctly had to do with one of the tcp notifier
> variants either in samples or selftests(both user space and kernel).
> I can go back and look at the details.
> The fix always more than half the time was need to upgrade
> clang/llvm. At one point i think it required that i had to grab
> the latest and greatest git version. I think the machine i have
> right now has version 11. The first time i found out about these
> clang upgrades was trying to go from 8->9 or maybe it was 9->10.
> Somewhere along there also was discovery that something that
> compiled under earlier version wasnt compiling under newer version.

So with kernel's samples/bpf and selftests/bpf, we do quite often
expect the latest Clang, because it's not just examples, but also a
live set of tests. So to not accumulate too much cruft, we do update
those (sometimes, not all the time) with assumption of latest features
in Clang, libbpf, pahole, and kernel. That's reality and we set those
expectations quite explicitly a while ago. But that's not the
expectation for user applications outside of the kernel tree. Just
wanted to make this clear.

>
> >> kernel headers every time i want to run something in samples, etc
> >> but i am probably lacking knowledge on how to ease the pain in that
> >> regard.
> >>
> >> I find the loader and associated tooling in iproute2/tc to be quiet
> >> stable (not shiny but works everytime).
> >> And for that reason i often find myself sticking to just tc instead
> >> of toying with other areas.
> >
> > That's the part that others on this thread mentioned is bit rotting?
>
> Yes. Reason is i dont have to deal with new discoveries of things
> that require some upgrade or copying etc.
> I should be clear on the "it is the ecosystem": this is not just because
> of user space code but also the simplicity of writing the tc kernel code
> and loading it with tc tooling and then have a separate user tool for
> control.
> Lately i started linking the control tool with static libbpf instead.

There are also two broad categories of BPF applications: networking
and the rest (tracing, now security, etc). Networking historically
dealt with well-defined data structures (ip headers, tcp headers, etc)
and didn't need much to know about the ever-changing nature of kernel
memory layouts. That used to be, arguably, simpler use case from BPF
standpoint.

Tracing, on the other hand, was always challenging. The only viable
option was BCC's approach of bundling compiler, expecting
kernel-headers, etc. We started changing that with BPF CO-RE to make a
traditional per-compiled model viable. That obviously required changes
in all parts of the ecosystem. So tracing BPF apps went from
impossible, to hard, to constantly evolving, and we are right now in a
somewhat mixed evolving/stabilizing stage. Bleeding edge. As Jiri
said, it's to be expected that there would be rough corners. But the
choice is either to live dangerously or wait for a few years for
things to completely settle. Pick your poison ;)

>
> Bpftool seems improved last time i tried to load something in XDP. I
> like the load-map-then-attach-program approach that bpftool gets
> out of libbpf. I dont think that feature is possible with tc tooling.
>
> However, I am still loading with tc and xdp with ip because of old
> habits and what i consider to be a very simple workflow.
>
> > Doesn't seem like everyone is happy about that, though. Stopping any
> > development definitely makes things stable by definition. BPF and
> > libbpf try to be stable while not stagnating, which is harder than
> > just stopping any development, unfortunately.
> >
>
> I am for moving to libbpf. I think it is a bad idea to have multiple
> loaders for example. Note: I am not a demanding user, but there
> are a few useful features that i feel i need that are missing in
> iproute2 version. e.g, one thing i was playing with about a month
> ago was some TOCTOU issue in the kernel code and getting
> the bpf_lock integrated into the tc code proved challenging.
> I ended rewriting the code to work around the tooling.

Right, bpf_lock relies on BTF, that's probably why.

>
> The challenge - when making changes in the name of progress - is to
> not burden a user like myself with a complex workflow but still give
> me the features i need.

This takes time and work, and can't be done perfectly overnight.
That's all. But the thing is: we are working towards it, non-stop.

>
> >> Slight tangent:
> >> One thing that would help libbpf adoption is to include an examples/
> >> directory. Put a bunch of sample apps for tc, probes, xdp etc.
> >> And have them compile outside of the kernel. Maybe useful Makefiles
> >> that people can cutnpaste from. Every time you add a new feature
> >> put some sample code in the examples.
> >
> > That's what tools/testing/selftests/bpf in kernel source are for. It's
> > not the greatest showcase of examples, but all the new features have a
> > test demonstrating its usage. I do agree about having simple Makefiles
> > and we do have that at [0]. I'm also about to do another sample repo
> > with a lot of things pre-setup, for tinkering and using that as a
> > bootstrap for BPF development with libbpf.
> >
> >    [0] https://github.com/iovisor/bcc/tree/master/libbpf-tools
>
>
> I pull that tree regularly.
> selftests is good for aggregating things developers submit and
> then have the robots test.
> For better usability, it has to be something that is standalone that
> would work out of the box with libbf.

It's not yet ready for wider announcement, but give this a try:

https://github.com/anakryiko/libbpf-bootstrap

Should make it easier to play with libbpf and BPF.

> selftests and samples are not what i would consider for the
> faint-hearted.
> It may look easy to you because you eat this stuff for
> breakfast but consider all those masses you want to be part of this.
> They dont have the skills and people with average skills dont
> have the patience.

I acknowledged from the get-go that selftest/bpf are not the best
source of examples, just that's what we've got. It takes contributions
from lots of people to maintain a decent, nice and clean, easy to use
set of realistic examples. It's unrealistic, IMO, to expect a bunch of
core BPF developers to both develop core technology actively, and
provide great educational resources (however unfortunate that is).

>
> This again comes back to "the ecosystem" - just getting libbpf to get
> things stable for userland is not enough. Maybe have part of the libbpf
> testing also to copy things from selftests.
>
> cheers,
> jamal

  reply	other threads:[~2020-11-06 21:25 UTC|newest]

Thread overview: 167+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  3:38 [PATCH iproute2-next 0/5] iproute2: add libbpf support Hangbin Liu
2020-10-23  3:38 ` [PATCH iproute2-next 1/5] configure: add check_libbpf() for later " Hangbin Liu
2020-10-23  3:38 ` [PATCH iproute2-next 2/5] lib: rename bpf.c to bpf_legacy.c Hangbin Liu
2020-10-23  3:38 ` [PATCH iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-10-23 14:34   ` David Ahern
2020-10-25 15:13     ` Toke Høiland-Jørgensen
2020-10-25 22:12       ` David Ahern
2020-10-26  8:56         ` Hangbin Liu
2020-10-26 15:15           ` David Ahern
2020-10-27  2:58             ` Hangbin Liu
2020-10-24  0:21   ` Andrii Nakryiko
2020-10-25 15:11     ` Toke Høiland-Jørgensen
2020-10-26  8:10     ` Hangbin Liu
2020-10-23  3:38 ` [PATCH iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-10-23  3:38 ` [PATCH iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-10-28 13:25 ` [PATCHv2 iproute2-next 0/5] iproute2: add libbpf support Hangbin Liu
2020-10-28 13:25   ` [PATCHv2 iproute2-next 1/5] configure: add check_libbpf() for later " Hangbin Liu
2020-10-28 13:25   ` [PATCHv2 iproute2-next 2/5] lib: rename bpf.c to bpf_legacy.c Hangbin Liu
2020-10-28 13:25   ` [PATCHv2 iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-10-28 13:25   ` [PATCHv2 iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-10-28 13:25   ` [PATCHv2 iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-10-28 21:17   ` [PATCHv2 iproute2-next 0/5] iproute2: add libbpf support Alexei Starovoitov
2020-10-28 23:02   ` David Ahern
2020-10-29  2:06     ` Hangbin Liu
2020-10-29  2:20       ` David Ahern
2020-10-29  2:45         ` Hangbin Liu
2020-10-29  3:00           ` David Ahern
2020-10-29  3:17             ` Hangbin Liu
2020-10-29 10:26             ` Hangbin Liu
2020-10-29 10:51               ` Toke Høiland-Jørgensen
2020-10-29  2:27       ` Andrii Nakryiko
2020-10-29  2:33         ` David Ahern
2020-10-29  2:46           ` Andrii Nakryiko
2020-10-29  2:34         ` Stephen Hemminger
2020-10-29  2:50           ` Andrii Nakryiko
2020-10-29 11:38             ` Jesper Dangaard Brouer
2020-10-29 20:30               ` Andrii Nakryiko
2020-10-29  2:33       ` Stephen Hemminger
2020-10-29 15:11   ` [PATCHv3 " Hangbin Liu
2020-10-29 15:11     ` [PATCHv3 iproute2-next 1/5] configure: add check_libbpf() for later " Hangbin Liu
2020-10-29 15:26       ` Toke Høiland-Jørgensen
2020-11-02 15:37       ` David Ahern
2020-11-03  5:54         ` Hangbin Liu
2020-11-03 17:32           ` David Ahern
2020-11-04  8:51             ` Hangbin Liu
2020-11-04 11:09               ` Toke Høiland-Jørgensen
2020-11-04 11:40                 ` Hangbin Liu
2020-10-29 15:11     ` [PATCHv3 iproute2-next 2/5] lib: rename bpf.c to bpf_legacy.c Hangbin Liu
2020-10-29 15:11     ` [PATCHv3 iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-11-02 15:41       ` David Ahern
2020-11-03  5:48         ` Hangbin Liu
2020-11-03 17:19           ` David Ahern
2020-11-04  8:22         ` Hangbin Liu
2020-11-05  2:33           ` David Ahern
2020-11-05  7:51             ` Hangbin Liu
2020-11-05 15:25               ` David Ahern
2020-11-05 15:57                 ` Toke Høiland-Jørgensen
2020-11-05 16:02                   ` David Ahern
2020-11-06  0:56                     ` Hangbin Liu
2020-11-06  0:41                 ` Hangbin Liu
2020-10-29 15:11     ` [PATCHv3 iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-10-29 15:11     ` [PATCHv3 iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-11-02 15:47     ` [PATCHv3 iproute2-next 0/5] iproute2: add libbpf support David Ahern
2020-11-03  6:58       ` Andrii Nakryiko
2020-11-03  8:42         ` Jiri Benc
2020-11-03 17:45           ` David Ahern
2020-11-03 17:48           ` Alexei Starovoitov
2020-11-03  8:46         ` Daniel Borkmann
2020-11-03 17:35           ` David Ahern
2020-11-03 17:47             ` Alexei Starovoitov
2020-11-03 18:23               ` Stephen Hemminger
2020-11-03 22:32               ` David Ahern
2020-11-03 22:55                 ` Alexei Starovoitov
2020-11-04  1:40                   ` David Ahern
2020-11-04  2:45                     ` Alexei Starovoitov
2020-11-04  9:28                       ` Jiri Benc
2020-11-05  2:39                         ` David Ahern
2020-11-04  2:17                   ` Hangbin Liu
2020-11-04  3:11                     ` Alexei Starovoitov
2020-11-04 10:01                       ` Jiri Benc
2020-11-04 10:21                       ` Daniel Borkmann
2020-11-04 11:20                         ` Toke Høiland-Jørgensen
2020-11-04 13:12                           ` Daniel Borkmann
2020-11-04 19:17                             ` Jakub Kicinski
2020-11-04 20:43                               ` Andrii Nakryiko
2020-11-04 22:24                                 ` Toke Høiland-Jørgensen
2020-11-05 20:14                                   ` Andrii Nakryiko
2020-11-05  3:48                                 ` David Ahern
2020-11-05 20:53                                   ` Andrii Nakryiko
2020-11-05  3:19                         ` David Ahern
2020-11-05 14:05                           ` Jamal Hadi Salim
2020-11-05 21:01                             ` Andrii Nakryiko
2020-11-06 15:27                               ` Jamal Hadi Salim
2020-11-06 21:25                                 ` Andrii Nakryiko [this message]
2020-11-10 12:47                             ` Edward Cree
2020-11-11  0:53                               ` Alexei Starovoitov
2020-11-11 11:31                                 ` Edward Cree
2020-11-11 18:08                                   ` Alexei Starovoitov
2020-11-05 20:45                           ` Andrii Nakryiko
2020-11-06  9:00                             ` Jiri Benc
2020-11-06 21:07                               ` Andrii Nakryiko
2020-11-04 21:15                       ` Edward Cree
2020-11-04 22:10                         ` Alexei Starovoitov
2020-11-04 22:35                           ` Toke Høiland-Jørgensen
2020-11-04 23:05                           ` Edward Cree
2020-11-05 20:19                             ` Andrii Nakryiko
2020-11-06  8:44                               ` Jiri Benc
2020-11-06 20:57                                 ` Andrii Nakryiko
2020-11-06 21:04                                   ` Alexei Starovoitov
2020-11-06 23:25                                     ` Stephen Hemminger
2020-11-06 23:30                                       ` Andrii Nakryiko
2020-11-07  0:41                                         ` Stephen Hemminger
2020-11-07  1:07                                           ` Andrii Nakryiko
2020-11-06 23:38                                       ` David Ahern
2020-11-09  1:45                                         ` Alexei Starovoitov
2020-11-10  4:09                                           ` David Ahern
2020-11-11  0:47                                             ` Alexei Starovoitov
2020-11-11 11:02                                               ` Toke Høiland-Jørgensen
2020-11-11 15:06                                                 ` Daniel Borkmann
2020-11-11 16:33                                                   ` David Ahern
2020-11-12 22:36                                                   ` Toke Høiland-Jørgensen
2020-11-12 23:20                                                     ` Daniel Borkmann
2020-11-13  0:04                                                       ` Stephen Hemminger
2020-11-13  0:40                                                         ` Alexei Starovoitov
2020-11-13  3:55                                                       ` David Ahern
2020-11-09  7:07     ` [PATCHv4 " Hangbin Liu
2020-11-09  7:07       ` [PATCHv4 iproute2-next 1/5] configure: add check_libbpf() for later " Hangbin Liu
2020-11-14  3:26         ` David Ahern
2020-11-16  4:30           ` Hangbin Liu
2020-11-16  4:33             ` David Ahern
2020-11-09  7:07       ` [PATCHv4 iproute2-next 2/5] lib: rename bpf.c to bpf_legacy.c Hangbin Liu
2020-11-14  3:24         ` David Ahern
2020-11-16  3:55           ` Hangbin Liu
2020-11-09  7:08       ` [PATCHv4 iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-11-09  7:08       ` [PATCHv4 iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-11-09  7:08       ` [PATCHv4 iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-11-16  6:53       ` [PATCHv5 iproute2-next 0/5] iproute2: add libbpf support Hangbin Liu
2020-11-16  6:53         ` [PATCHv5 iproute2-next 1/5] configure: add check_libbpf() for later " Hangbin Liu
2020-11-16  6:53         ` [PATCHv5 iproute2-next 2/5] lib: rename bpf.c to bpf_legacy.c Hangbin Liu
2020-11-16  6:53         ` [PATCHv5 iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-11-16  6:53         ` [PATCHv5 iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-11-16  6:53         ` [PATCHv5 iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-11-16  7:19         ` [PATCHv5 iproute2-next 0/5] iproute2: add libbpf support Alexei Starovoitov
2020-11-16 14:54           ` Jesper Dangaard Brouer
2020-11-16 23:29             ` Toke Høiland-Jørgensen
2020-11-17  2:37             ` Alexei Starovoitov
2020-11-17  3:19               ` Hangbin Liu
2020-11-17 18:27                 ` Alexei Starovoitov
2020-11-17 11:56               ` Edward Cree
2020-11-17  3:38             ` David Ahern
2020-11-17 18:19               ` Alexei Starovoitov
2020-11-16 16:45           ` Stephen Hemminger
2020-11-23 13:11         ` [PATCHv6 " Hangbin Liu
2020-11-23 13:11           ` [PATCHv6 iproute2-next 1/5] iproute2: add check_libbpf() and get_libbpf_version() Hangbin Liu
2020-11-23 13:11           ` [PATCHv6 iproute2-next 2/5] lib: make ipvrf able to use libbpf and fix function name conflicts Hangbin Liu
2020-11-23 13:11           ` [PATCHv6 iproute2-next 3/5] lib: add libbpf support Hangbin Liu
2020-11-23 13:12           ` [PATCHv6 iproute2-next 4/5] examples/bpf: move struct bpf_elf_map defined maps to legacy folder Hangbin Liu
2020-11-23 13:12           ` [PATCHv6 iproute2-next 5/5] examples/bpf: add bpf examples with BTF defined maps Hangbin Liu
2020-11-25  5:28           ` [PATCHv6 iproute2-next 0/5] iproute2: add libbpf support David Ahern
2020-11-25  5:30           ` patchwork-bot+netdevbpf
2020-11-29  6:16 ` [PATCH " Stephen Hemminger
2020-11-29  6:22   ` Greg KH
2020-11-30 11:39     ` Michal Kubecek
2020-11-29 17:33   ` Alexei Starovoitov
2020-11-29 19:41   ` David Ahern
2020-11-30 11:04     ` Toke Høiland-Jørgensen
2020-12-01 14:22     ` Jesper Dangaard Brouer

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=CAEf4BzanB7arOamPY7mKf4uxPmcmRYz7dvij_VxewYg9_y+GAg@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=haliu@redhat.com \
    --cc=jbenc@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=stephen@networkplumber.org \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /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).