Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3719784rwb; Mon, 5 Sep 2022 17:37:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VRNtAePtq1OfLSPhXLpOFgFfaeEuG55wmqyLSzDgvCBcY2f25yPozXDQgSLtXT5mtylTz X-Received: by 2002:a05:6402:26c4:b0:448:6e4:7cda with SMTP id x4-20020a05640226c400b0044806e47cdamr38669356edd.325.1662424635542; Mon, 05 Sep 2022 17:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662424635; cv=none; d=google.com; s=arc-20160816; b=P0+XWyu6MQdQp1Qehr51t9zKmQHUNMmgST11Y1t9ZFq8PTG3yH+GFSVbmD+0LJlE1T 3coTOyuMKb71s0FrVDg9mlztZyNi7gMjdsyspVY8fPM8YCgEFkp7uCWjioapkU37lV5R nhYONGZTOW2qNsqv6A60So1ig3lStZAaFdleWUhR7zFLO9BHSu3wG+kboezdS/Yl4a7W YqYlu7L0G9xlYg2HlIgfv59TVpcyj9orDEgg+ZKBW+poYN/5rgwty9QKy/p/PbuK1sBv vsxTPnqANxkVLUaU81dndd4a4wVB/OsM5irrOBeyqYly2OhAq0Vqlp/cLIPPoewb6gbm uZOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=MEFUNC1SfmnvHcQvUXukekdEtOijdGZ7i3qu/YqdpnY=; b=DBhFTgLu9aYfSMNQFtVpEeT+BQorrd9Op8H/a+Zre4tyIJu3H7zeuMoQT4rl9cO+m5 nRUcqkB8Nm6Z8ACfiTOjV7TxbdAIPhdVRvtBwUuAHtMVopZAT8t3LN9Ye4Vr3IhiRpA5 n4chOcuuJz1IAUkRgWgLQIIsZ5fAm38WKGUNLdnvkgH/D0tnK7Wf57OUvN2xpcWlD2Xq Gi/P2tQo96UcTBTSU4Vc3hhG12Y6tPTD7XGe4Ny5rOCL3E6cLiwo240PsxRYmXhaN0mo y5NX/XXF+7Fg+iIIVlBfmCaXtTQoeuzPGKnBWg2DhD9JCga5g1zZYmFFzxbl2I8xuZfn rKKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=Icsh2aKi; 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=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs24-20020a1709073e9800b0072abb95e8e4si298764ejc.598.2022.09.05.17.36.50; Mon, 05 Sep 2022 17:37:15 -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=@xry111.site header.s=default header.b=Icsh2aKi; 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=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbiIFAcV (ORCPT + 99 others); Mon, 5 Sep 2022 20:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiIFAcU (ORCPT ); Mon, 5 Sep 2022 20:32:20 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4708867C97 for ; Mon, 5 Sep 2022 17:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1662424337; bh=tnkg6NDxCuY/leErq28zhAiAg1e8lpHeUNO0dIKqK9k=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Icsh2aKiMJaRvYwsBLvliJiM6JvC0BpVyKB7ha/7oyBcYjXPnao5sqrOpv6gQL2/T HK0VesT/Fb+Zur1m4JUpyHqIiCJy4Z7sckeiewcdVRxN5QwpM0S9Uzdjfq2vx1EgKt ZRYC3e0OEvDzc3pdqGKHKL+QaYr9C6Hoj30wPJhI= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id B70B265A9D; Mon, 5 Sep 2022 20:32:15 -0400 (EDT) Message-ID: Subject: Re: [PATCH v7 0/5] LoongArch: Support toolchain with new relocation types From: Xi Ruoyao To: Huacai Chen Cc: Jinyang He , WANG Xuerui , loongarch@lists.linux.dev, LKML , Youling Tang Date: Tue, 06 Sep 2022 08:32:13 +0800 In-Reply-To: References: <20220830104806.128365-1-xry111@xry111.site> <5b87173faeef587a2ffaaa6f58d34e0940231067.camel@xry111.site> <97291c0fe5a660c844475ff019c8db6af77ecf86.camel@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.45.3 MIME-Version: 1.0 X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, 2022-09-01 at 10:17 +0800, Huacai Chen wrote: > Now all global variable accesses are via got, I think the performance > may be much worse than before when we didn't use explicit-relocs. > I don't know whether "a new code model" or your "(1)(2)(3)" is easier > to implement, but I think it is better to solve the performance issue > before 6.1-rc1. Hi Huacai, We've added a GCC option for this at https://gcc.gnu.org/r13-2433. On the kernel side we need a one-line change: diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 92c4a52c4c3e..69b39ba3a09d 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -54,6 +54,7 @@ LDFLAGS_vmlinux +=3D -G0 -static -n= -nostdlib # upgrade the compiler or downgrade the assembler. ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS cflags-y +=3D -mexplicit-relocs +KBUILD_CFLAGS_KERNEL +=3D -mdirect-extern-access else cflags-y +=3D $(call cc-option,-mno-explicit-relocs) KBUILD_AFLAGS_KERNEL +=3D -Wa,-mla-global-with-pcrel And we also need a one-line change in the EFI stub patch (under review): diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/l= ibstub/Makefile index 8931ed24379e..8c1225b92492 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -27,7 +27,7 @@ cflags-$(CONFIG_ARM) :=3D $(subst $(CC_FLAGS_FTR= ACE),,$(KBUILD_CFLAGS)) \ cflags-$(CONFIG_RISCV) :=3D $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_C= FLAGS)) \ -fpic cflags-$(CONFIG_LOONGARCH) :=3D $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_C= FLAGS)) \ - -fpic + -fpie =20 cflags-$(CONFIG_EFI_GENERIC_STUB) +=3D -I$(srctree)/scripts/dtc/libfdt (Some explanation: -fpic does not only mean "generate position- independent code", but "generate position-independent code *suitable for use in a shared library*". On LoongArch -mdirect-extern-access cannot work for a shared library so the "-fpic -mdirect-extern-access" combination is rejected deliberately.) Not sure how to submit these changes properly... Do you prefer me to send V8 of this series or a single patch on top of your tree on GitHub? --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University