Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1722784rdh; Sat, 28 Oct 2023 05:01:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2Q89woC4npwOAvPYUZsHlLhBX10Sf13DgraUiRtXANb3uQ9bCdXi1xTcMD06nqxpIg6c+ X-Received: by 2002:a17:90b:789:b0:27c:f2e5:a82 with SMTP id l9-20020a17090b078900b0027cf2e50a82mr4615621pjz.15.1698494469269; Sat, 28 Oct 2023 05:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698494469; cv=none; d=google.com; s=arc-20160816; b=a97Gak7KGwakN5WW7A2AAwwzjZdlqFQ8NkaE7Ijvytl7mevedubDM+HFh5yi3loS9k M47VaB4lYKIGIJVZBQpmLT+mqoEpRNOJ0LgLXqFKREzN6DweqJrnc4viHP/xoLc8rXJn YExBM58JBFi/tFWj1yWaa+7fYypLBKqYhUZdoQiP+B4W3wwiFe0jvfHGoRWn0iJKzjZz N8xl7LHVrjZqMoK5LP1aZitvUn15LuRCIF6rFbEx+AhLSJzMf9e4MzDDFZUVipYIt89l WvD+QiDcB92E3KH5rPrGpawUsS9W4SiF/jHucG8EkXFLGk0V8T2ThcGJ0ebpTPwycEcp ePig== 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=XXMtI1Q34bDLWILj6ScrGHtnpjNXjfUoKYE8p+Fc48g=; fh=E1r7MPr3tkb2zNFRft5u8RJQBd6tDrPQQAXR+nCnzfs=; b=CnT8E+cNATWksj0Vd5Ef0VL0lagYyAMHPsQ3kCOc7hntbc3v7o4RH6RemAaOCjWCFp TXyk7fs6MajzyRAr0q+xD791g+gzq36QK7b/j2yvAsVteh/pid3UKFuIUXnc6dLqcmV9 hV+z6ng2L4F4H2bigm7QAV83a91damhz1YI9XuClw/b7YPtqJ6+BOFSXPD5gM7ldZ1p/ fv5arOEx0Vu58oKkViDU76SCM1jMlZZ6x12tdmGm/G71raGBbxOyg77liV411b8VsyYU EV9w9nkKpsTIlFNISgYoVRr04/l9DrP7Z1Bo8SN0PC0I5FyV4uPh4tjtuiDRRVRbbbqa 3VVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rxlCZaOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l17-20020a17090ac59100b0027d28735890si411170pjt.1.2023.10.28.05.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 05:01:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rxlCZaOm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 40752801C93F; Sat, 28 Oct 2023 05:01:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbjJ1MAw (ORCPT + 99 others); Sat, 28 Oct 2023 08:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjJ1MAu (ORCPT ); Sat, 28 Oct 2023 08:00:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 817DAEB; Sat, 28 Oct 2023 05:00:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C1DCC433C7; Sat, 28 Oct 2023 12:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698494448; bh=NDYeMPRVIZz698JsT+R8LnMI83Zt/EWY2nxoFqm580c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rxlCZaOmJmY70MKRHjymf2B7cedbaw9IX9qFJSPtCk0aoWz8Ty5+APG/TH07kSU9z VliVCxfQjJDI2O1M2j5uhx+vNxAU3X04lEfokPRhT2s2i+BAZ8QWDYMB8rSVzgHoUp aK6XKdGYQp+ybnxwJAweKUifflgcODEEjaxPgsmvrU4ZTKhFKgttDPPi8SV6BjTvXB gVHh+jswdeYnm5+89yA4yMIpZaL7udwJGsf0ZmNmiEagnXsfTygUTk2DJi0WuwcAHl AFmLDjbqe3ZXkfrh5zVIih1O17/nkXNP+Dzia74MbBg1c0Vq1PNoksgo9kzhd5s9BE Cd4v9LiVjIfOw== Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-581ed744114so1580543eaf.0; Sat, 28 Oct 2023 05:00:48 -0700 (PDT) X-Gm-Message-State: AOJu0YzoGjSiKwZnok3TdMir2S1wksCS11C758VXVC5/9um3OUS/qEsu TbbarzSRk/rQc1KkN53aJ/XDkSCkZri9Ij7o8/Q= X-Received: by 2002:a05:6871:8198:b0:1e9:858e:ff23 with SMTP id so24-20020a056871819800b001e9858eff23mr4354359oab.55.1698494447492; Sat, 28 Oct 2023 05:00:47 -0700 (PDT) MIME-Version: 1.0 References: <20231018151950.205265-1-masahiroy@kernel.org> <20231018151950.205265-4-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Sat, 28 Oct 2023 21:00:11 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [bpf-next PATCH v2 4/4] kbuild: refactor module BTF rule To: Andrii Nakryiko Cc: Jiri Olsa , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 28 Oct 2023 05:01:04 -0700 (PDT) On Mon, Oct 23, 2023 at 12:19=E2=80=AFPM Andrii Nakryiko wrote: > > On Sun, Oct 22, 2023 at 1:24=E2=80=AFPM Masahiro Yamada wrote: > > > > On Sun, Oct 22, 2023 at 4:33=E2=80=AFAM Andrii Nakryiko > > wrote: > > > > > > On Sat, Oct 21, 2023 at 4:38=E2=80=AFAM Masahiro Yamada wrote: > > > > > > > > On Sat, Oct 21, 2023 at 5:52=E2=80=AFAM Andrii Nakryiko > > > > wrote: > > > > > > > > > > On Fri, Oct 20, 2023 at 12:03=E2=80=AFAM Masahiro Yamada wrote: > > > > > > > > > > > > On Fri, Oct 20, 2023 at 7:55=E2=80=AFAM Andrii Nakryiko > > > > > > wrote: > > > > > > > > > > > > > > On Thu, Oct 19, 2023 at 1:15=E2=80=AFAM Jiri Olsa wrote: > > > > > > > > > > > > > > > > On Thu, Oct 19, 2023 at 12:19:50AM +0900, Masahiro Yamada w= rote: > > > > > > > > > newer_prereqs_except and if_changed_except are ugly hacks= of the > > > > > > > > > newer-prereqs and if_changed in scripts/Kbuild.include. > > > > > > > > > > > > > > > > > > Remove. > > > > > > > > > > > > > > > > > > Signed-off-by: Masahiro Yamada > > > > > > > > > --- > > > > > > > > > > > > > > > > > > Changes in v2: > > > > > > > > > - Fix if_changed_except to if_changed > > > > > > > > > > > > > > > > > > scripts/Makefile.modfinal | 25 ++++++------------------- > > > > > > > > > 1 file changed, 6 insertions(+), 19 deletions(-) > > > > > > > > > > > > > > > > > > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile= .modfinal > > > > > > > > > index 9fd7a26e4fe9..fc07854bb7b9 100644 > > > > > > > > > --- a/scripts/Makefile.modfinal > > > > > > > > > +++ b/scripts/Makefile.modfinal > > > > > > > > > @@ -19,6 +19,9 @@ vmlinux :=3D > > > > > > > > > ifdef CONFIG_DEBUG_INFO_BTF_MODULES > > > > > > > > > ifneq ($(wildcard vmlinux),) > > > > > > > > > vmlinux :=3D vmlinux > > > > > > > > > +cmd_btf =3D ; \ > > > > > > > > > + LLVM_OBJCOPY=3D"$(OBJCOPY)" $(PAHOLE) -J $(PAHOLE_F= LAGS) --btf_base vmlinux $@; \ > > > > > > > > > + $(RESOLVE_BTFIDS) -b vmlinux $@ > > > > > > > > > else > > > > > > > > > $(warning Skipping BTF generation due to unavailability = of vmlinux) > > > > > > > > > endif > > > > > > > > > @@ -41,27 +44,11 @@ quiet_cmd_ld_ko_o =3D LD [M] $@ > > > > > > > > > cmd_ld_ko_o +=3D = \ > > > > > > > > > $(LD) -r $(KBUILD_LDFLAGS) = \ > > > > > > > > > $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) = \ > > > > > > > > > - -T scripts/module.lds -o $@ $(filter %.o, $= ^) > > > > > > > > > + -T scripts/module.lds -o $@ $(filter %.o, $= ^) \ > > > > > > > > > + $(cmd_btf) > > > > > > > > > > > > > > > > > > -quiet_cmd_btf_ko =3D BTF [M] $@ > > > > > > > > > > > > > > > > nit not sure it's intentional but we no longer display 'BTF= [M] ...ko' lines, > > > > > > > > I don't mind not displaying that, but we should mention tha= t in changelog > > > > > > > > > > > > > > > > > > > > > > Thanks for spotting this! I think those messages are useful a= nd > > > > > > > important to keep. Masahiro, is it possible to preserve them? > > > > > > > > > > > > > > > > > > > > > > > > No, I do not think so. > > > > > > > > > > > > > > > > That's too bad, I think it's a useful one. > > > > > > > > > > > > > > > > I prioritize that the code is correct. > > > > > > > > > > Could you please also prioritize not regressing informativeness of a > > > build log? With your changes it's not clear now if BTF was generated > > > or not for a kernel module, while previously it was obvious and was > > > easy to spot if for some reason BTF was not generated. I'd like to > > > preserve this > > > property, thank you. > > > > > > E.g, can we still have BTF generation as a separate command and do a > > > separate $(call if_changed,btf_ko)? Or something along those lines. > > > Would that work? > > > > If we have an intermediate file (say, *.no-btf.ko), > > it would make sense to have separate > > $(call if_changed,ld_ko_o) and $(call if_changed,btf_ko). > > Currently we don't generate intermediate files, but we do rewrite > original .ko file as a post-processing step. > > And that rewriting step might not happen depending on Kconfig and > toolchain (e.g., too old pahole makes it impossible to generate kernel > module BTF). And that's why having a separate BTF [M] message in the > build log is important. > > > > > > > LD RESOLVE_BTFIDS > > *.mod.o ------> *.no-btf.ko ------------> *.ko > > > > > > When vmlinux is changed, only the second step would > > be re-run, but that would require extra file copy. > > Today we rewrite .ko with a new .ko ELF file which gains a new ELF > section (.BTF), so we already pay this price when BTF is enabled (if > that's your concern). > > > > > Is this what you want to see? > > I don't have strong preferences for exact implementation, but what you > propose will work, I think. What I'd like to avoid is unnecessarily > relinking .ko files if all we need to do is regenerate BTF. Is there any way to make pahole/resolve_btfids take separate input and output files instead of in-place modification? Otherwise, explicit "cp *.no-btf.ko *.ko" would be needed. -- Best Regards Masahiro Yamada