Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1993155rdb; Sun, 19 Nov 2023 20:46:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVDQbz4dKWDfGbGxhamTLFxkFmSFIpGhV3eOAduDEn97EsY8yjzm39RNjkkNfTvp3bsJWH X-Received: by 2002:a17:902:fac4:b0:1cc:4b3d:1a8d with SMTP id ld4-20020a170902fac400b001cc4b3d1a8dmr14918261plb.17.1700455604230; Sun, 19 Nov 2023 20:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700455604; cv=none; d=google.com; s=arc-20160816; b=KLtJ+ffD/QSB0Gum0/pXURvAaXfmSXTkZtsS4qpfMWtdtBnBZ//Yd5IgaZiC46hU3G UIE404gckk0IB/u4ehQbgwJbwXRgeXHn5RS5KI4quSSP7CPsAFqaFKSo1BNV55oemzcP /xVg7TwqTOKPYQQlq2dC2G/iNX11BdJJ9ZNRhZ3ekvzzSub1qAgkqKBPzs+/vQsHs4yL RmvTMGBp1XaiwRQayM0AWUDsMG1h38ALBAjeQ9o6shE1lD0s231sPCvZsGZAYtKqaTY+ pUlGICa9fSg0pNIBgS/cL/LkR2XqmTa2+Z2ho8o3nQ6Ct9Ei1cTh0g/KUxapNXbuujxU 5Ugw== 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=DZK/VK6NgfIn3iYXAJ3BDsCXe2kdS6x5eLbfpNFeKhE=; fh=mwwYN66g/67jzy79kTl4d2IF09Yn4SWtnUi7nW/jSv8=; b=sNuFtDp1IPtUL4/GDRvfMgV8MU3bv0eQWXtEyA/bT1bBVwVaN8R7EX2Rqq+a5jp2Im YCJ/Cym7q4aoGz0ft8Bq/lv7d/9wmgEw0f9KJsTcooRL3uHPo+5Yi121cQsC0IviVq5H QpTbGzpDWXgAc7wZwad+bs4a6/GlxViMiCVFJQxjxE6+NNfFosPNx9Cnb7jNiN80cpbI o45u2yNwuGjh21Z/vWZrUUHKXhIWnS/fdAcNNHE9+MKlriAz1ZuthA59Mrefd6DVj/s6 iI6i+Jt495jRPTE3qcJV4xlekUF7eY7q7iMnlz1xv0toQzdx5gwaeqmJ9b3rMUkefhid VKEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SnFL+sj6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 17-20020a170902ee5100b001c9fe071f2csi6969877plo.105.2023.11.19.20.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 20:46:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SnFL+sj6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id C0A5E807C867; Sun, 19 Nov 2023 20:45:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbjKTEpn (ORCPT + 99 others); Sun, 19 Nov 2023 23:45:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjKTEpm (ORCPT ); Sun, 19 Nov 2023 23:45:42 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5EE39F for ; Sun, 19 Nov 2023 20:45:38 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BAEDC433C8; Mon, 20 Nov 2023 04:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700455538; bh=2ORYR1fAsPIpzl2loAbE5pAuaPxD6cGbpqol8Q2B9Gs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SnFL+sj6nIIeRZ6I0L67pNEO43BJAgi+2rTyLqD7JAdIzm7vCFWjyac7/IrM58s4L kenELyD0oQTFsCmRSTZnLOyo9oUYkIOvrS8EVzLpUukfrggU4dzgAKgcIKc9+0t9gL HjAPLt2HHx9GARVHx3SOsbNcjYjZuNKcjyb1drPkk3+rjSHTiT7ZGaxigHJhkOmvct 68dIGgps4VWaiUnrJaRY2klxmT0n9b3WNfd+pMoHNulvBk14Dy96yZpvt8BzQ785we oC1Oni1gZjti1ThpP/HdMR/e3DSgIKv2236E05+fRFBehBimUy9EIu0tT1/urM4fhd tvZXcXpbYBjEA== Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1f5d34235dbso722818fac.0; Sun, 19 Nov 2023 20:45:38 -0800 (PST) X-Gm-Message-State: AOJu0YyrFSWD7rL/zm9eOu3JDOBq7ioo+mgK+qvd+buxV1J3qEHEMtMi UUas8l5LCez9kW5io76TNtEQVPjRL1A5RH9MgpM= X-Received: by 2002:a05:6870:1d12:b0:1f5:c70c:aa78 with SMTP id pa18-20020a0568701d1200b001f5c70caa78mr3410814oab.24.1700455537421; Sun, 19 Nov 2023 20:45:37 -0800 (PST) MIME-Version: 1.0 References: <20231119053448.2367725-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Mon, 20 Nov 2023 13:45:01 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] loongarch: add dependency between vmlinuz.efi and vmlinux.efi To: Huacai Chen Cc: WANG Xuerui , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Ard Biesheuvel , Simon Glass 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 20:45:53 -0800 (PST) On Mon, Nov 20, 2023 at 10:33=E2=80=AFAM Huacai Chen wrote: > > Hi, Masahiro, > > On Sun, Nov 19, 2023 at 10:25=E2=80=AFPM Masahiro Yamada wrote: > > > > On Sun, Nov 19, 2023 at 8:59=E2=80=AFPM Huacai Chen wrote: > > > > > > Hi, Masahiro, > > > > > > On Sun, Nov 19, 2023 at 1:35=E2=80=AFPM Masahiro Yamada wrote: > > > > > > > > A common issue in Makefile is a race in parallel building. > > > > > > > > You need to be careful to prevent multiple threads from writing to = the > > > > same file simultaneously. > > > > > > > > Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to n= ot > > > > generate invalid images") addressed such a bad scenario. > > > > > > > > A similar symptom occurs with the following command: > > > > > > > > $ make -j$(nproc) ARCH=3Dloongarch vmlinux.efi vmlinuz.efi > > > > [ snip ] > > > > SORTTAB vmlinux > > > > OBJCOPY arch/loongarch/boot/vmlinux.efi > > > > OBJCOPY arch/loongarch/boot/vmlinux.efi > > > > PAD arch/loongarch/boot/vmlinux.bin > > > > GZIP arch/loongarch/boot/vmlinuz > > > > OBJCOPY arch/loongarch/boot/vmlinuz.o > > > > LD arch/loongarch/boot/vmlinuz.efi.elf > > > > OBJCOPY arch/loongarch/boot/vmlinuz.efi > > > > > > > > The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twic= e. > > > > > > > > It indicates that two threads simultaneously enter arch/loongarch/b= oot/ > > > > and write to arch/loongarch/boot/vmlinux.efi. > > > > > > > > It occasionally leads to a build failure: > > > > > > > > $ make -j$(nproc) ARCH=3Dloongarch vmlinux.efi vmlinuz.efi > > > > [ snip ] > > > > SORTTAB vmlinux > > > > OBJCOPY arch/loongarch/boot/vmlinux.efi > > > > PAD arch/loongarch/boot/vmlinux.bin > > > > truncate: Invalid number: =E2=80=98arch/loongarch/boot/vmlinux.bi= n=E2=80=99 > > > > make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13: > > > > arch/loongarch/boot/vmlinux.bin] Error 1 > > > > make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin' > > > > make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2 > > > > make[1]: *** Waiting for unfinished jobs.... > > > > make: *** [Makefile:234: __sub-make] Error 2 > > > > > > > > vmlinuz.efi depends on vmlinux.efi, but such a dependency is not > > > > specified in arch/loongarch/Makefile. > > > > > > > > Signed-off-by: Masahiro Yamada > > > > --- > > > > > > > > arch/loongarch/Makefile | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile > > > > index 9eeb0c05f3f4..6022bf3d30c9 100644 > > > > --- a/arch/loongarch/Makefile > > > > +++ b/arch/loongarch/Makefile > > > > @@ -142,6 +142,7 @@ vdso-install-y +=3D arch/loongarch/vdso/vdso.so= .dbg > > > > > > > > all: $(notdir $(KBUILD_IMAGE)) > > > > > > > > +vmlinuz.efi: vmlinux.efi > > > > vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux > > > > $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ > > > It is a little strange, because > > > > > > in drivers/firmware/efi/libstub/Makefile.zboot: > > > vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on > > > vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on > > > vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD). > > > > > > in arch/loongarch/boot/Makefile, > > > EFI_ZBOOT_PAYLOAD :=3D vmlinux.efi > > > > > > So I think vmlinuz.efi has already depend on vmlinux.efi. > > > > > > > > That is a story in arch/loongarch/boot/Makefile. > > > > > > I am talking about arch/loongarch/Makefile, > > which is included from the top Makefile. > > > > > > See this code. > > > > > > vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux > > $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ > > > > > > > > > > Only the required dependency is > > > > - vmlinux.elf depends on vmlinux > > - vmlinuz.elf depends on vmlinux > > > > > > vmlinux.elf and vmlinuz.elf are independent of each other. > > > > > > > > In parallel building, GNU Make considers that > > vmlinux.elf and vmlinuz.elf can be built simultaneously. > > > > > > GNU Make spawns two processes to execute these simultaneously: > > > > $(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/vmlinux.elf > > $(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/vmlinuz.elf > > > > > > > > The former enters arch/loongarch/boot/Makefile to build > > vmlinux.elf. (A) > > > > > > The latter also enters arch/loongarch/boot/Makefile to build > > vmlinuz.elf, which depends on vmlinux.elf (B) > > > > > > > > (A) and (B) are independent processes, hence none of them > > know the other. > > > > > > I hope it is clearer. > Sorry, I'm not familiar with Makefile rules, so you are probably > right, but should we do it like this (remove the direct dependency > from vmlinuz.efi to vmlinux)? > > vmlinuz.efi: vmlinux.efi > vmlinux.elf vmlinux.efi: vmlinux > $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ No. It would create only vmlinux.efi because there is no recipe line for vmlinuz.efi vmlinuz.efi: vmlinux.efi $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ vmlinux.elf vmlinux.efi: vmlinux $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ will work, but I do not want to repeat the same recipe line. > Huacai > > > > > > > > > > > > > > > > Huacai > > > > > > > > > > > -- > > > > 2.40.1 > > > > > > > > > > > > > > > > > -- > > Best Regards > > Masahiro Yamada --=20 Best Regards Masahiro Yamada