Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp363086rwd; Wed, 7 Jun 2023 00:37:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IH1dmO9mAba7LBBOTSAV5EnfV26KW30IJ4YAgWx9wwnPDgHpb6xkJ/oDR0i04O3sc/dsZ X-Received: by 2002:a05:6902:45:b0:ba6:b486:84ed with SMTP id m5-20020a056902004500b00ba6b48684edmr5642919ybh.20.1686123422648; Wed, 07 Jun 2023 00:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686123422; cv=none; d=google.com; s=arc-20160816; b=LpkmqLpJXXc5HljDKfGRVznw9RShP54BuLE1aMFMO0qPrW30fjYrFL0SjlhSZZby4a BIIg+aVevBFO+55Q1+043K70v2FJNxRWTZAnqKCTjen47gemkq6uoZOnInYkpZLlFJXd yqfY7LNqdDHnssl3sq26rYyb2U/mJ39g/8jehVCrsHaIZqubVoSwW+BvdqfKPD+OlIOq wpBBnD886wPw9IWChRqIroJVFdsdDIRydePg/Ip1HcGoLcfXo5W61wpmgyDGeEtGBmhy LYM6q0UmrEMi7X3VziS2M3G5IU6/xtjh0vZ6R+CZeT2BmEMrlnmBDIBJpbvgjJycXeSI kYZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PGUTPYhgHVq7tjYGlPQBicKEoIBr6v5/fU5n0hbGTrI=; b=EilowjCpSgPn1eZ4F/CcE2lmORDRR06fR0GpMY+694AnmJSsJwFQzFP/vb334Gm6uJ cpWM8H496Sdsp+YpEBDn74+x4kPyKZmeLNb97HkRsaXs15Yq08/c2YZiYfUfNUEdmu0o WhqO36eWyuSczHC5cwErMR/tLzbBZ0WuP93Ec67Ar/ih22cux1VqB/Li2voeiw9g11VH aAuR3SrxMHWWmdNs+82mnk8iP4whQ6leB5rv42UJG/DRme7Ov/D64Sr34u2mk2yIz16G a0DF8T46csKdmizmRz8iBpPwdO8vtf4hD1I0xP2jYx77+HkHJ7fObBQ9FieKzdYTVZxk Yq3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=OvXHLUmN; 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 jx18-20020a17090b46d200b0025337db9e19si722615pjb.156.2023.06.07.00.36.50; Wed, 07 Jun 2023 00:37:02 -0700 (PDT) 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=20221208 header.b=OvXHLUmN; 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 S238798AbjFGHLl (ORCPT + 99 others); Wed, 7 Jun 2023 03:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238810AbjFGHLd (ORCPT ); Wed, 7 Jun 2023 03:11:33 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CBB1BE8 for ; Wed, 7 Jun 2023 00:11:29 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-33bf12b5fb5so62615ab.1 for ; Wed, 07 Jun 2023 00:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686121889; x=1688713889; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=PGUTPYhgHVq7tjYGlPQBicKEoIBr6v5/fU5n0hbGTrI=; b=OvXHLUmNzM4BI0TQ7LDb6i5kkuRVUOSUhd4VMwgVF4fy/BUvxgd1CPNFfT8ZIjTl05 32kZUrjfGpw8qkUWloq5scwiSkvTRE06xJXmlO5d7J5VTzHUXLGgQ192HglJaYLVLPwZ 6l9y4crsmvcA7tLYoIwwfjeiv7KW5AxNG8MzALmyunp8omXcMly1vinxkuNBiifMhYMK ywVHFFuLdPwqSfHCs4PjZUS23EGN5Hd4t1sa1di7snzkarxYZjrSjL3IUAqskAKAwNSX yXPMr626M6jSs2PWUfT6ZX+WSPDH7k3Xy4YrA+U0KzeSWW9h7chVOPbCkki3sFSw1Fsn 46fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686121889; x=1688713889; h=content-transfer-encoding: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=PGUTPYhgHVq7tjYGlPQBicKEoIBr6v5/fU5n0hbGTrI=; b=CUmTuUGi56kFBfECvZ5gtjkDhSJ9uunBkfPlKGUu1k/qwzyU0NnRfNnNVPO17FH2xH GOVuTD5AeMSIzm5K3go/fgqREyt3tUlqrru1D8xrbAld3v3sjMvx7rOT+VySvZsughIQ j9r0wetDeGvgQX2nULC6biicX8bu2jtCp4wqgjVfk34uLGWYc3OW/Xsvk0ELO8cgGIwe M6H2YfKqgX/heCjNSMx0VXQAo2UJNu6Bkti8/OhYalV8gCq7krsR8qPk0sqzHDcILJG/ 4se5C/KDZrlPDAA0ORy1U6KUbDSwAJdRANQcg4xENM2hZlg3MSKqk0PUUQ2JKj1oSm7/ XPDg== X-Gm-Message-State: AC+VfDzLffqzsaEafPfxA/LeNjJrpXJWNjw+ySD5NqlfvpLzsd72mT5l e5gxq/6kVpDKCgrNU64Za8zjuqcXFlUrXki6q0bbKQ== X-Received: by 2002:a05:6e02:170d:b0:32f:7715:4482 with SMTP id u13-20020a056e02170d00b0032f77154482mr188090ill.4.1686121888943; Wed, 07 Jun 2023 00:11:28 -0700 (PDT) MIME-Version: 1.0 References: <20230605202712.1690876-1-irogers@google.com> <20230605202712.1690876-5-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 7 Jun 2023 00:11:17 -0700 Message-ID: Subject: Re: [PATCH v2 4/4] perf build: Filter out BTF sources without a .BTF section To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , James Clark , Tiezhu Yang , Yang Jihong , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, T_SCC_BODY_TEXT_LINE,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, Jun 5, 2023 at 4:35=E2=80=AFPM Namhyung Kim w= rote: > > Hi Ian, > > On Mon, Jun 5, 2023 at 1:28=E2=80=AFPM Ian Rogers wr= ote: > > > > If generating vmlinux.h, make the code to generate it more tolerant by > > filtering out paths to kernels that lack a .BTF section. > > > > Signed-off-by: Ian Rogers > > --- > > tools/perf/Makefile.perf | 23 ++++++++++++++++++++--- > > 1 file changed, 20 insertions(+), 3 deletions(-) > > > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > > index f1840af195c0..c3bb27a912b0 100644 > > --- a/tools/perf/Makefile.perf > > +++ b/tools/perf/Makefile.perf > > @@ -193,6 +193,7 @@ FLEX ?=3D flex > > BISON ?=3D bison > > STRIP =3D strip > > AWK =3D awk > > +READELF ?=3D readelf > > > > # include Makefile.config by default and rule out > > # non-config cases > > @@ -1080,12 +1081,28 @@ $(BPFTOOL): | $(SKEL_TMP_OUT) > > $(Q)CFLAGS=3D $(MAKE) -C ../bpf/bpftool \ > > OUTPUT=3D$(SKEL_TMP_OUT)/ bootstrap > > > > -VMLINUX_BTF_PATHS ?=3D $(if $(O),$(O)/vmlinux) = \ > > +# Paths to search for a kernel to generate vmlinux.h from. > > +VMLINUX_BTF_ELF_PATHS ?=3D $(if $(O),$(O)/vmlinux) = \ > > $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) = \ > > ../../vmlinux = \ > > - /sys/kernel/btf/vmlinux = \ > > /boot/vmlinux-$(shell uname -r) > > -VMLINUX_BTF ?=3D $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)= ))) > > + > > +# Paths to BTF information. > > +VMLINUX_BTF_BTF_PATHS ?=3D /sys/kernel/btf/vmlinux > > + > > +# Filter out kernels that don't exist or without a BTF section. > > +VMLINUX_BTF_ELF_ABSPATHS ?=3D $(abspath $(wildcard $(VMLINUX_BTF_ELF_P= ATHS))) > > +VMLINUX_BTF_PATHS ?=3D $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS)= ; \ > > + do \ > > + if [ -f $$file ] && ($(READELF) -t "$$f= ile" | grep .BTF); \ > > Wouldn't it be `readelf -S` instead? Also I think grep needs -q to > suppress output. Makes sense, I can change it in v3. > > + then \ > > + echo "$$file"; \ > > + fi; \ > > + done) \ > > + $(wildcard $(VMLINUX_BTF_BTF_PATHS)) > > This changes the order of processing the sysfs file. > But I'm not sure it matters much as both /boot/vmlinux and sysfs > should refer to the running kernel. Agreed. readelf fails for /sys/kernel/btf/vmlinux as it isn't an elf file and I'm not sure it is worth worrying too much about the order here. Thanks, Ian > Thanks, > Namhyung > > > > + > > +# Select the first as the source of vmlinux.h. > > +VMLINUX_BTF ?=3D $(firstword $(VMLINUX_BTF_PATHS)) > > > > $(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) > > ifeq ($(VMLINUX_H),) > > -- > > 2.41.0.rc0.172.g3f132b7071-goog > >