Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1685307rdb; Sun, 19 Nov 2023 06:25:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEigr2ROGDkjZTbrAAKynZGTyTjVDuQK2ArrACV82k/qg3LlxWzKAn1vzghOOvhxT3Hsv7X X-Received: by 2002:a05:6a21:3998:b0:189:c0e1:4979 with SMTP id ad24-20020a056a21399800b00189c0e14979mr3416315pzc.29.1700403937923; Sun, 19 Nov 2023 06:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700403937; cv=none; d=google.com; s=arc-20160816; b=1AxgTv69KtSJ7RqT78aS3HL7lBH5lF7Qkbyyw4vFWWQqzfw5h8XoJn89tiSI19FfrU x386DkknluXICHw7myQe8gh2Tr4kjxk1onp3OetBcQ5sDTQawSku/TR5JVIuNKyOtac7 O9fOUWWnA+I3ycBI6mnsTRJShT7yhgxOh6K4Hm+O5k/n3BFf1bgYi1ScFiKIy+AvkwYe q8sXNe+VcQSiL0l44Ck5vUf3vw2ORkWU25hlgwdpklN+61dvhsyOOXQ+PB4idatyQBqs OjfGneVBdkKw6CITtD3RP2nmxklRNujL/m+LuEUYilt8YChAxHUQamnVcVeGt24TRu7U HlOA== 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=lJnC/ue1GuNto2zu3PDW1nXkGC+mxIsk2evY6AskUew=; fh=mwwYN66g/67jzy79kTl4d2IF09Yn4SWtnUi7nW/jSv8=; b=lQzgreepLg1nMcNzdFoEu7XIopdnosFKNHn4GYUynKaed9izcM9GzeHHreQZZOIjgd GgmZ/eiRJ9TbHPcmwX1PmexuE56E5YWr/M6oEXb84otwKIfbCPo/AQfWlYDjmqoimojq 26eZM5vkrbfLrlkx4H/cRKQbr6OVlkIdklWDGafjNnmEXzWeIqFd8GAXhtVEHAXnAKGT 3+PTA0M/qJxjl+/62PG65ERIJnjnjzCGDCaNU1OGdMwN59wlh2YIk1d71+L1A6aeedKy d+M83M1z7xSnykLNX1bZ1qQarbWhgzLQARAz5yNcTZqAv4XFAP7Ee3AqrTw0TsTQSw7c RZRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X6CvpV61; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id r18-20020aa79892000000b006cb901a9883si606054pfl.326.2023.11.19.06.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 06:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=X6CvpV61; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2C45E8060CB0; Sun, 19 Nov 2023 06:25:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjKSOZU (ORCPT + 99 others); Sun, 19 Nov 2023 09:25:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjKSOZT (ORCPT ); Sun, 19 Nov 2023 09:25:19 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27FCFBA for ; Sun, 19 Nov 2023 06:25:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2AC8C433CA; Sun, 19 Nov 2023 14:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700403915; bh=0dtY30CPhZvn8O3z06NpRjrEuqxkR7+uYsOGb9dcdao=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X6CvpV61YxVyRWd6/vtT+AoaD9pZ0tj3uNT7niektNZOuOBPq9FijgTIDSuKq9qTh Y/EJ8XnpTLJbrG/43spnOC9yPoGR3DI1CN3txOTfgS67g6m5J1bUqfqmwYWHS17/Ri tUedtEvN/I84NPcWt61kY3kdXNiZFgQ2RN8pckRIg6ewg8IBkJKBGmxutEsWs/qsJw oa2+ffB//dBMhhgbezkRUo2P6Us9rd5kKGBfXXkV5ZLpyVrjV+UqgNSuWk2ufgg+lk JGWB+brPzLT3Qk49pZXjQ6iCUYJIOEL/NXnrlooMrJZTGDkcsknNpqqeoRiVfwHbDB wA7o8aXf+RrVg== Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-1f03d9ad89fso2046732fac.1; Sun, 19 Nov 2023 06:25:15 -0800 (PST) X-Gm-Message-State: AOJu0YyQuh7l3zhEIuRPqOnz85GmeddD7AtZqRK/dlHB4WGsiTBRdfmB JSjkJdIlxd/FpdXNglSxIvQTNVbyj82t1MIjs9o= X-Received: by 2002:a05:6870:e09:b0:1e9:9aa5:997b with SMTP id mp9-20020a0568700e0900b001e99aa5997bmr5841334oab.20.1700403915009; Sun, 19 Nov 2023 06:25:15 -0800 (PST) MIME-Version: 1.0 References: <20231119053448.2367725-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Sun, 19 Nov 2023 23:24:38 +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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 06:25:34 -0800 (PST) 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 not > > 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 twice. > > > > It indicates that two threads simultaneously enter arch/loongarch/boot/ > > 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.bin=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. > Huacai > > > > > -- > > 2.40.1 > > > > > --=20 Best Regards Masahiro Yamada