Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11907928rwd; Thu, 22 Jun 2023 21:40:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6jYj9eXpdaPDpa8FV1/W1v87tbjjYREml/BDaxaDjxjnjdijWrfWwDz0p3OmwcSFUnFmOp X-Received: by 2002:a05:6a20:728e:b0:122:4a16:dfa4 with SMTP id o14-20020a056a20728e00b001224a16dfa4mr12409806pzk.10.1687495234843; Thu, 22 Jun 2023 21:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687495234; cv=none; d=google.com; s=arc-20160816; b=AeakzAe5h4F/MMAMTrSuR9k8Y2U7AdtBA8UDeidy6kOU756WgkAmuA1JCr+OVdDA0f Bu0ITzdogy2tZUA/Cj4/E3zhfkY4FRocM1hRtDR3bKDGW69uG7oHCA4xmSlf24ROmNqR SRV/edi4GXgYbTG22fQZILcldCOikI/6pj5xuIKyTrEQhAH0yHikcnZWs5WKgNi4zPFi /mhrhq9dnQMT071nD0pIFCrkjKeS+nLG/mQC7p9kxTADAvGvf/kqQ/YcpCEdVTpbAUxe owCrisLktjcxaJJJsgB2sM66slrF1ZW6f7XUe4Iu4V2TjLy0rKsEpOwZgRimAKJd0k2W 4n7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=8ai2lt5OXlbg2xibr5qc+Wf7Z0ZxmmScMUvbx2hwx4o=; b=XEQmr93YvSWbrNh2kSd8skIKU184W12d/Mot+k2+9+t5l7+TUtPzZosD7i3iBmnW2N NNg32qEKVD6MbcfwoziOCexqbe07pEoZvtwM31C7kz7lvhDUN8UD+CJb8Lp6eqvTwgEI 6i6gbr6fcaqRyPAcZWkQo5+z4qz4qFI2i/v3Yd5j1cS+Qf/RRO/Offhhj0864RNaWnfY rXSB+hY1fLj5VM86KVIMnCOt0l7sRtQj5yJ2bL/NlRVTwXCCrmkXkI/3FciRfK66v3GU CgBW6OF6fhIcHs7DRqwqxDSDi4zLIByiEvN9uRU1gAqUjadiIUnItp2LKY/riJMAYK1W U2mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=i6JMRQKJ; 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 x18-20020a170902ec9200b001b6ba60780fsi1966735plg.258.2023.06.22.21.40.21; Thu, 22 Jun 2023 21:40:34 -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=i6JMRQKJ; 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 S231422AbjFWEPA (ORCPT + 99 others); Fri, 23 Jun 2023 00:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231383AbjFWEOb (ORCPT ); Fri, 23 Jun 2023 00:14:31 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143E926A9 for ; Thu, 22 Jun 2023 21:14:23 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bfec07e5eb0so363060276.2 for ; Thu, 22 Jun 2023 21:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687493662; x=1690085662; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=8ai2lt5OXlbg2xibr5qc+Wf7Z0ZxmmScMUvbx2hwx4o=; b=i6JMRQKJse9xdriW6sN1y3oU7Pmdm0X/tfZLFVuGr7Qy5Xvv6Bk2LiBt6lGdWaN2m5 WkOHxDeZ5GFOwfdEyr8yKNo6xUAr0SKyujoJ2vYt0MUH50G524NCf+IU6TWfk3LbfE7F m1qOHpsF6yNlWremKE+D63U+q84y57TzPt0Y9djKgU80NXuNlflx3+DmEZ50zz3G1Y3q 6qZEnyKYtMyjy2Ly46Cnv79i5ZSNFGLmqTCYo/7K1Zlz9oo2pMmmukJ0zWVUzJzM7Vq6 6o3yon9f3xJIMgIyY120p/xIbAf84PMc9cvDW/ics5umym/bom1SzjhELttNr7xzasjI n/9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687493662; x=1690085662; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8ai2lt5OXlbg2xibr5qc+Wf7Z0ZxmmScMUvbx2hwx4o=; b=i2jsjRMw5dW3xbbnHhI1JYEawfurjmF31pVLj4ZlpoOzMi8I6+weereOFnwcsG5XhZ lMetFhITnNKcZs4N0mXto+fII/t2zaeiI+SqL8fn41pryuEr5rc9II+L8Hy70r54GDUT 4npz8RryBymSlium/r80UXcMFB5PnlC0uyo8yjIKObys7xhSqJ/D7PJolvVFJvgaD9rq DIqvV3aS0W72QmULfW45RjlvBox6fOR8wyDCtMqvGEAKFFe2w/u1GAse4pCgVoTEpPVF 5Be+JNvga5j4/L3uivZBiB+t8LvRnWgO7kw9Zbvb4UPfGOPVuAQ630UKypzxYydPZQHV TJtQ== X-Gm-Message-State: AC+VfDyWlYZ5UVs5Wbv6+XeRjNWp/y+KbG4zaXHvfEfKVKL6SKqfye3u kAOMdxDHLUwLo0Te/wFGFakTx6aVISkL X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:6559:8968:cdfe:35b6]) (user=irogers job=sendgmr) by 2002:a25:8046:0:b0:bd7:545e:ab35 with SMTP id a6-20020a258046000000b00bd7545eab35mr8897557ybn.10.1687493662218; Thu, 22 Jun 2023 21:14:22 -0700 (PDT) Date: Thu, 22 Jun 2023 21:14:05 -0700 In-Reply-To: <20230623041405.4039475-1-irogers@google.com> Message-Id: <20230623041405.4039475-5-irogers@google.com> Mime-Version: 1.0 References: <20230623041405.4039475-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v4 4/4] perf build: Filter out BTF sources without a .BTF section From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , 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" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 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 Acked-by: Namhyung Kim Acked-by: Jiri Olsa --- tools/perf/Makefile.perf | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 80d772cc5fcb..8f442419a895 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -197,6 +197,7 @@ FLEX ?= flex BISON ?= bison STRIP = strip AWK = awk +READELF ?= readelf # include Makefile.config by default and rule out # non-config cases @@ -1084,12 +1085,34 @@ $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ OUTPUT=$(SKEL_TMP_OUT)/ bootstrap -VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ +# Paths to search for a kernel to generate vmlinux.h from. +VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \ $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ ../../vmlinux \ - /sys/kernel/btf/vmlinux \ /boot/vmlinux-$(shell uname -r) -VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))) + +# Paths to BTF information. +VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux + +# Filter out kernels that don't exist or without a BTF section. +VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS))) +VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \ + do \ + if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \ + then \ + echo "$$file"; \ + fi; \ + done) \ + $(wildcard $(VMLINUX_BTF_BTF_PATHS)) + +# Select the first as the source of vmlinux.h. +VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS)) + +ifeq ($(VMLINUX_H),) + ifeq ($(VMLINUX_BTF),) + $(error Missing bpftool input for generating vmlinux.h) + endif +endif $(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) ifeq ($(VMLINUX_H),) -- 2.41.0.162.gfafddb0af9-goog