Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6766823rwl; Mon, 9 Jan 2023 12:46:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXsnJoZ5IsxC9UdOSU0zQVfa/CzocZb6LLu1HD4jz7B8kpeorWDqMRGxxlQyBOFXF8/FTU8J X-Received: by 2002:a17:907:3e0c:b0:7c0:f90f:163d with SMTP id hp12-20020a1709073e0c00b007c0f90f163dmr74911571ejc.11.1673297174311; Mon, 09 Jan 2023 12:46:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673297174; cv=none; d=google.com; s=arc-20160816; b=YfOfgoxny7WrE/9LvPbYjYZnWzuVebpCPgXn5g7dTH5Q1geVUHz86kwYoydTLgsxs2 mThc10EqulI8JkEtAlrLqgHCcajGK6f20aPi3hYrRGowQ1hj6A6+x6+wDhvUKVU6IVmq /LyV5y42WsrxSbvujc/d8LSkjNxSiDge8WFQJt18TgsJwldMwVin6CwYwD4ejJ0sEGjo eh+nMyBf5lMXhEEagimcYdtzCKqnuQkNVbtdyBD4WX2LzllBs2PLHfpFL50wXlV8CqTb KyCHQZ9cofym6cTbTkh1i4o+fA0uygxDzT3f9XhZntfRle52iOJGk+X5tNMoeFM+P7+P ficA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MCRW0UkTNlTzkZ4jOzer8zj7ypiKG1rbT29sYMJr0H0=; b=oUHKu7wGqVaCMiiiM/9svmKOO4k//4MjNvev+scjdAJLHFMesBjXdIB6/vtb5aHHTp cwIHoA4jKtCqEeHDi08S34p+lajbCSsP2NQhrpaz1uk3ZdoHf8io19V8j2CtEclM7HMV z2GlVvjVGwpaI5DhYGZibx9FClqngiJwJpQzk1H/KFTOCtatNIGAhnKxSslWwURcwxw0 HAwIOUUmG/RCHZ2/fnQ1/5nhBdJSQ3hZOzKN4S6of2kXvnKHAwrlSuR4/hnX4Fo5+OWi U1w8AXwduyKaZJiXScCnP3ljvcMtG//VmG6bxBpe8XH20J/8eXbRGj0VmD21gXRxYvoR ZXEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SKO4ZX8f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du1-20020a17090772c100b007c0d88f1614si9977451ejc.342.2023.01.09.12.46.00; Mon, 09 Jan 2023 12:46:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SKO4ZX8f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237274AbjAIUku (ORCPT + 55 others); Mon, 9 Jan 2023 15:40:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjAIUkr (ORCPT ); Mon, 9 Jan 2023 15:40:47 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8231634770 for ; Mon, 9 Jan 2023 12:40:45 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id g19-20020a05600c4ed300b003d9eb1dbc0aso5074141wmq.3 for ; Mon, 09 Jan 2023 12:40:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MCRW0UkTNlTzkZ4jOzer8zj7ypiKG1rbT29sYMJr0H0=; b=SKO4ZX8fQPOxTTcMnTbp5MFbMfTEzMDNX7cwrMxkDT51AdOR0mgCK+A8X5hxt6SrEq w4CKxeCPJiZxa/vofF5uHOsRmB6riV3BPAPZuZkIg3PekMR4z9IGHtAl1DQDHEw0eF4i JIGunRDVUq7U+Bhpui8Rcvid0HOehY53Ify5/l6SCIlPmFXUGYBTzuqkUs7jJ45yGsnW rQA3u1EPJy1VdUSMCvy8ZSG9UF63qoNWihdHPMIoKJFGKVrni57DUHimOtV975ev9H+Q m011MLFr6BN52WpZwJRFNyGaYJfSbc5WUIY2pFbD5JrRQaZhHefi1LXaloaC20F484Bn 08hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MCRW0UkTNlTzkZ4jOzer8zj7ypiKG1rbT29sYMJr0H0=; b=DAGNISCGykO1euWjEjq9J3lpms+Ud1BGfDxqpHM3M2j5hoBj1s/gsuJKvr2y4PorH9 TbzdSLvtSDTrV/RNFJbzl6G/YzvXXJTC2gordXpEZ/zWCkUMd5OGVa0qfPSx75ZIH/Mf zv7Vkt2d+jsaglGgtK4wtmgLgL9VmeWmOHEkD8z85ZtTPugdAo8wFHoStZf/X6XutbXy 4eNDNEmIRwUrtuCv5Tt5GWVTfb7n5ZV3hlsJN2jAenPgpn8x+YsmUgCaMN1iBgFeT/mS uVq2U0TCmjkmb33Ot4gGFkJ2JsCExo6Y+pkU6kS3kX94ExfBge/vmkofcfu1sZmSklqH Zi9Q== X-Gm-Message-State: AFqh2kpC/U64XWhhXSOMkqYhzgsQ6ovMysGBUPwrngzwfTZmDSIm6mGK R4Tc4j5P7J9QwGZaYlU17wDMFckAyYWBy52PuW6gew== X-Received: by 2002:a1c:4c04:0:b0:3d9:edae:ed7 with SMTP id z4-20020a1c4c04000000b003d9edae0ed7mr230023wmf.182.1673296843828; Mon, 09 Jan 2023 12:40:43 -0800 (PST) MIME-Version: 1.0 References: <20230106151320.619514-1-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Mon, 9 Jan 2023 12:40:31 -0800 Message-ID: Subject: Re: [PATCH v3 1/2] perf build: Properly guard libbpf includes To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Mike Leach , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 9, 2023 at 11:34 AM Ian Rogers wrote: > > On Mon, Jan 9, 2023 at 11:29 AM Ian Rogers wrote: > > > > On Mon, Jan 9, 2023 at 10:37 AM Ian Rogers wrote: > > > > > > On Mon, Jan 9, 2023 at 10:10 AM Jiri Olsa wrote: > > > > > > > > On Mon, Jan 09, 2023 at 12:12:15PM -0300, Arnaldo Carvalho de Melo wrote: > > > > > Em Fri, Jan 06, 2023 at 11:06:46AM -0800, Ian Rogers escreveu: > > > > > > So trying to get build-test working on my Debian derived distro is a > > > > > > PITA with broken feature detection for options I don't normally use. > > > > > > > > > > Its really difficult to have perf building with so many dependent > > > > > libraries, mowing out some should be in order. > > > > > > > > > > > I'll try to fix this. > > > > > > > > > > Thanks. > > > > > > > > > > > In any case I think I've spotted what is really happening here and it > > > > > > isn't a failure but a feature :-D The build is specifying > > > > > > > > > > I get it. > > > > > > > > > > > LIBBPF_DYNAMIC=1 which means you get the libbpf headers from > > > > > > /usr/include. I think the build is trying to do this on a system with > > > > > > an old libbpf and hence getting the failures above. Previously, even > > > > > > though we wanted the dynamic headers we still had a -I, this time for > > > > > > the install_headers version. Now you really are using the system > > > > > > version and it is broken. This means a few things: > > > > > > - the libbpf feature test should fail if code like above is going to fail, > > > > > > > > > > Agreed. > > > > > > > > > > > - we may want to contemplate supporting older libbpfs (I'd rather not), > > > > > > > > > > I'd rather require everybody to be up to the latest trends, but I really > > > > > don't think that is a reasonable expectation. > > > > > > > > > > > - does build-test have a way to skip known issues like this? > > > > > > > > > > Unsure, Jiri? > > > > > > > > I don't think so it just triggers the build, it's up to the features check > > > > to disable the feature if the library is not compatible with perf code > > > > > > > > could we add that specific libbpf call to the libbpf feature check? > > > > > > Looking at the failure closer, the failing code is code inside a > > > feature check trying to workaround the feature not being present. We > > > need to do something like: > > > > > > ``` > > > diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c > > > index 6e9b06cf06ee..a1c3cc230273 100644 > > > --- a/tools/perf/util/bpf-loader.c > > > +++ b/tools/perf/util/bpf-loader.c > > > @@ -33,17 +33,18 @@ > > > #include > > > > > > #ifndef HAVE_LIBBPF_BPF_PROGRAM__SET_INSNS > > > -int bpf_program__set_insns(struct bpf_program *prog __maybe_unused, > > > - struct bpf_insn *new_insns __maybe_unused, > > > size_t new_insn_cnt __maybe_un > > > used) > > > +static int bpf_program__set_insns(struct bpf_program *prog __maybe_unused, > > > + struct bpf_insn *new_insns __maybe_unused, > > > + size_t new_insn_cnt __maybe_unused) > > > { > > > pr_err("%s: not support, update libbpf\n", __func__); > > > return -ENOTSUP; > > > } > > > > > > -int libbpf_register_prog_handler(const char *sec __maybe_unused, > > > - enum bpf_prog_type prog_type __maybe_unused, > > > - enum bpf_attach_type exp_attach_type > > > __maybe_unused, > > > - const struct > > > libbpf_prog_handler_opts *opts __maybe_unused) > > > +static int libbpf_register_prog_handler(const char *sec __maybe_unused, > > > + enum bpf_prog_type prog_type > > > __maybe_unused, > > > + enum bpf_attach_type > > > exp_attach_type __maybe_unused, > > > + const void *opts __maybe_unused) > > > { > > > pr_err("%s: not support, update libbpf\n", __func__); > > > return -ENOTSUP; > > > ``` > > > > > > There are some other fixes necessary too. I'll try to write the fuller > > > patch but I have no means for testing except for undefining > > > HAVE_LIBBPF_BPF_PROGRAM__SET_INSNS. > > > > > > Thanks, > > > Ian > > > > So libbpf_prog_handler_opts is missing in the failing build, this > > points to a libbpf before 0.8. I'm somewhat concerned that to work > > around these linkage problems we're adding runtime errors - we may > > build but the functionality is totally crippled. Is it worth > > maintaining these broken builds or to just upfront fail the feature > > test? > > > > We can also switch the feature tests for LIBBPF_MAJOR_VERSION and > > LIBBPF_MINOR_VERSION checks. This would have the property of letting > > us tie the error messages to what version of libbpf is assumed. > > > > In this case we could have a feature test for the libbpf version and > > if the version is before libbpf 0.8 fail the feature check. A quick > > way to do this is: > > ``` > > diff --git a/tools/build/feature/test-libbpf.c > > b/tools/build/feature/test-libbpf.c > > index a508756cf4cc..dadd8186b71d 100644 > > --- a/tools/build/feature/test-libbpf.c > > +++ b/tools/build/feature/test-libbpf.c > > @@ -1,6 +1,10 @@ > > // SPDX-License-Identifier: GPL-2.0 > > #include > > > > +#if (LIBBPF_MAJOR_VERSION == 0) && (LIBBPF_MINOR_VERSION < 8) > > +#error At least libbpf 0.8 is assumed for Linux tools. > > +#endif > > + > > int main(void) > > { > > return bpf_object__open("test") ? 0 : -1; > > ``` > > > > Thanks, > > Ian > > Oh, just to note. While failing the feature test is disappointing for > a libbpf that isn't very old, we have the newer libbpf to statically > build in. Developers won't be impacted due to the static route. If you > are a distro maintainer, you should just update your libbpf. So we > could just bump the API assumption to 1.0 as I believe that'd have the > advantage of removing feature tests, workarounds, untested code (like > what broke here), etc. > > What do you think? > > Thanks, > Ian The removal of pre-libbpf 1.0 support is in: https://lore.kernel.org/lkml/20230109203424.1157561-1-irogers@google.com/ So my proposal is that for 6.2 these two patches are sufficient. In perf/core (to be in 6.3) it makes sense to add both sets of patches to fix the build issue reported here. The problem with that is that some build tests will fail for 6.2 if they are testing libbpf dynamic with a libbpf earlier than 1.0. If that is an issue then cherry-picking the first or all of the pre-libbpf 1.0 removal patches should address it. Thanks, Ian > > > > jirka > > > > > > > > > > > > > > But yeah, previous experiences with Andrii were that we can do not too > > > > > costly feature checks, not using .c programs that would fail if some > > > > > required feature wasn't present but instead would just do some grep on a > > > > > header and if some "smell" wasn't scent, just fail the cap query. > > > > > > > > > > - Arnaldo