Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3463012pxf; Mon, 29 Mar 2021 02:58:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBIAJPGXOefGXU+GnCBXjsy5dhmuB1JOoZ9/iv/al96iKg+MShIfFJQ/Qu18DzPGY2JD1C X-Received: by 2002:a17:906:4146:: with SMTP id l6mr28263668ejk.295.1617011926469; Mon, 29 Mar 2021 02:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617011926; cv=none; d=google.com; s=arc-20160816; b=Ca8pR0RBwost/geJfD5HVRgS64uKrG2fBd/L/WlPveHJrIbX2vQypubdFyyQHB+meR CeTbs2Gqiz8vixQe7BpP2bELf5q3MOeo2Ugsu1DLxMmj+2qqsAEGB4oYeFd5/dYMjiK0 MnTHn+r+CYU0N8hJDCXaGl727x+wRJOqaVxYyC+04oRKSpQqowbWDe8ZD7mvbdvnJx0o HgTX+GHeJs5tq73wkh4KqpgMelfEHEpnjxCICJdxKinedNqoDglIr99hHgv/SBl1Dg7L XA2WOz+r8mXNA83R1xMd72gTTQdvUdgnZjE1ORDYsZNshAiZ/wcBGBT0OWn1SKTu7z/U a4fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=xiWJV3ko1190mDpLoLQdBpnnHOr0EFaCU4Guy+26tGU=; b=Q3dzRiPhgTFWsAEMLGNewO0fYbZwKGdB+NiRekVPWXG7SZZjoHQVQpxSoCf3Rt8dHe lnybGByQpxchKLUAu4VRZNmjjsgHWtUBfvzFWGCYxgM1t8N+ML/+MjS2UVkrF3n1VTIl oxqZH2r6xWqDjYFy6ZhF60H9NkvO9kbG6eAXqRmd3qBz8BuVw//PCr0iNxKF3S3cTDBu NsS1+V+avE9ib4gtBAW33TubUTCBzyFNLWqmgYfahWUqZ2SgxOz4gK0cTSvnEb97zkSI SQ6BvBgJMdjqTsJW91mNirp002JX8c7WQCXWO+rkrGfwOgxmfmRWw8zERu2HQZF+wNnq stLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AdWR3App; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si6397235edn.294.2021.03.29.02.58.24; Mon, 29 Mar 2021 02:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AdWR3App; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232102AbhC2J52 (ORCPT + 99 others); Mon, 29 Mar 2021 05:57:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20471 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231651AbhC2J5C (ORCPT ); Mon, 29 Mar 2021 05:57:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617011821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xiWJV3ko1190mDpLoLQdBpnnHOr0EFaCU4Guy+26tGU=; b=AdWR3App76xedyVwMaWtX3fRx5lJ4G9gsjlR3g9YaKWFTBh2EzOxEq8PyvFcYsY3wPvjUb Ug3HRNK5L8rkBLEo8zyTEqgeto4ZyVw1VvQmHhJaTfyXrp9eUfEJTmG2mZDtmh8Qv9HgFd Hjt/RnauqKF5EgT2/WDh8udSPhzKCOo= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-7ylDwRgzMGCKXsgASUNIsQ-1; Mon, 29 Mar 2021 05:56:58 -0400 X-MC-Unique: 7ylDwRgzMGCKXsgASUNIsQ-1 Received: by mail-ed1-f69.google.com with SMTP id a2so8342220edx.0 for ; Mon, 29 Mar 2021 02:56:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=xiWJV3ko1190mDpLoLQdBpnnHOr0EFaCU4Guy+26tGU=; b=EkoXBd8yX5/vZMXx1fadOLFDKlHH0nZWwaegTWhxho/YXegYmYZgbi362ueuDk7a2q HSSg4Yti+w8FpUVmumJwVOQ715yBrKEA0S1XdpKqEWklJdKc/5o2E25umkgmPVULpd/b vLb2cc+olkEv2rkPXyc0bM4zW0ZgWIv0ncnVLZXqnwHQLslGDnroL1q4tpUZJcZhgeom TpylueiVDaa0kDbragCndrJM9sUqax68TtlZE0U9fZfo282B8KwZ6+KpXe9moSc2XTGS /fwNE0KP3f0RGUaMlAgHbcYzJj+FiQDf/vC7nvlcg+n/a8+mjKoy5pCCfuij2NTl9MvF t7rg== X-Gm-Message-State: AOAM530ez5JKF8Yi5RhpQIgmWrxodnpyexNkjRbJ3YtRala7iaWHeqWO ARBJlkP/et0/ndgy1Wvk+wine4FjvX/qCRFDbHWe7dgLOfjPbmxikd2kpUZ243FBWAQnUlftjCf u18Mjcc+QnxH3hhwPy/q3cUWx X-Received: by 2002:a50:ed83:: with SMTP id h3mr28469772edr.140.1617011817510; Mon, 29 Mar 2021 02:56:57 -0700 (PDT) X-Received: by 2002:a50:ed83:: with SMTP id h3mr28469745edr.140.1617011817342; Mon, 29 Mar 2021 02:56:57 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id de17sm7894616ejc.16.2021.03.29.02.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 02:56:56 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 3E766180293; Mon, 29 Mar 2021 11:56:55 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Alexei Starovoitov , Andrii Nakryiko Cc: Kumar Kartikeya Dwivedi , bpf , Jesper Dangaard Brouer , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Peter Zijlstra , open list , Networking , "open list:KERNEL SELFTEST FRAMEWORK" Subject: Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API In-Reply-To: <20210329014044.fkmusoeaqs2hjiek@ast-mbp> References: <20210325120020.236504-1-memxor@gmail.com> <20210325120020.236504-6-memxor@gmail.com> <20210327021534.pjfjctcdczj7facs@ast-mbp> <20210329014044.fkmusoeaqs2hjiek@ast-mbp> X-Clacks-Overhead: GNU Terry Pratchett Date: Mon, 29 Mar 2021 11:56:55 +0200 Message-ID: <87r1jyth94.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexei Starovoitov writes: > On Sat, Mar 27, 2021 at 09:32:58PM -0700, Andrii Nakryiko wrote: >> > I think it's better to start with new library for tc/xdp and have >> > libbpf as a dependency on that new lib. >> > For example we can add it as subdir in tools/lib/bpf/. >> > >> > Similarly I think integerating static linking into libbpf was a mistake. >> > It should be a sub library as well. >> > >> > If we end up with core libbpf and ten sublibs for tc, xdp, af_xdp, linking, >> > whatever else the users would appreciate that we don't shove single libbpf >> > to them with a ton of features that they might never use. >> >> What's the concern exactly? The size of the library? Having 10 >> micro-libraries has its own set of downsides, > > specifically? > >> I'm not convinced that's >> a better situation for end users. And would certainly cause more >> hassle for libbpf developers and packagers. > > For developers and packagers.. yes. > For users.. quite the opposite. > The skel gen and static linking must be split out before the next libbpf release. > Not a single application linked with libbpf is going to use those pieces. I'd tend to agree about the skeleton generation, but I have one use case in mind where having the linker in library form would be handy: dynamically building an XDP program at load time from pre-compiled pieces. Consider xdp-filter[0]: it's a simplistic packet filter that can filter on different bits of the packet header, mostly meant as a demonstration of XDP packet filtering performance. It's also using conditional compilation so that it can be loaded in a mode that skips parsing L4 headers entirely if port-based filtering is not enabled. Right now we do that by pre-compiling five different variants of the XDP program and loading based on the selected feature set, but with linking in libbpf, we could instead have a single BPF program with granular filtering functions and just assemble the final program from those bits at load time. The actual xdp-filter program may be too simplistic to gain any performance for this, but I believe the general approach could be a way to realise the "improved performance through skipping code" promise of an XDP-based data path. Having linking be part of libbpf will make this straight-forward to integrate into applications. [0] https://github.com/xdp-project/xdp-tools/tree/master/xdp-filter > bpftool is one and only that needs them. Hence forcing libbpf users > to increase their .text with a dead code is a selfish call of libbpf > developers and packagers. The user's priorities must come first. > >> And what did you include in "core libbpf"? > > I would take this opportunity to split libbpf into maintainable pieces: > - libsysbpf - sys_bpf wrappers (pretty much tools/lib/bpf/bpf.c) > - libbpfutil - hash, strset > - libbtf - BTF read/write > - libbpfelf - ELF parsing, CORE, ksym, kconfig > - libbpfskel - skeleton gen used by bpftool only > - libbpflink - linker used by bpftool only > - libbpfnet - networking attachment via netlink including TC and XDP > - libbpftrace - perfbuf, ringbuf > - libxdp - Toke's xdp chaining > - libxsk - af_xdp logic Huh? You've got to be joking? How is that going to improve things for users? Just the cognitive load of figuring out which linker flags to use is going to be prohibitive. Not to mention the hassle of keeping multiple library versions in sync etc. If the concern is .text size, surely there are better ways to fix that? LTO is the obvious "automagic" solution, but even without that, just supporting conditional compilation via defines in the existing libbpf ought to achieve the same thing without exposing the gory details to the users? -Toke