Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp826940rwb; Thu, 22 Sep 2022 06:58:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MFCWUK1syXRCiMV+/QBFX7KiIK0jPI0t+92Dk/2BAoUA3eXuc81lBbxEO1dJmfwwiNdIn X-Received: by 2002:a17:907:271c:b0:779:dcbe:3a91 with SMTP id w28-20020a170907271c00b00779dcbe3a91mr2868609ejk.715.1663855102962; Thu, 22 Sep 2022 06:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663855102; cv=none; d=google.com; s=arc-20160816; b=NoDP3dzlKCFkQFINDXoGvKMH3l3iVgvpZVct+TUPkEHWPPn4D96buyM1HMuLWOYfJ7 Va2ERhieXxlHtUlXgVbNLbKRNUNWQScg6e5FQiSZ9YEo2KsN6wxmSdbDNDJgX4DVzAKw sJXpmx1YmVEgoFT+mdTVK4JQSrAJG171aPnER2vtrIcIZm+v//7E/xMW+KobKiHtTZpM WuRpI+cjkQnIQtxvwV5/pMTAYJNYTYaqWn4wdUjkXWTkKnbdBPToW7hejcoYGXMRJYxk wOTgqPJXnyFPrLqs0F537Kt0WlnDtjOyjNlNrIFSGCasgWglK4bo8qh/61jR2e84/owZ 46zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aJgPwaz2o4bXekmRi1R1wGhaPKL3xSxewQ7L7bF4bG0=; b=O7sko9gcwK5UAAQdNlEVZXjSFi4oohPSKEoBsP09oD47srlHpamd5W3Kl/RzllG945 LvdTEvtKtypsD7ij//bYxz66EMylvtMsIkpenniMOrlFfRhxO4uRcvWk/L2HnjOdTZMo +W4QY+7hBjrNUETM2QaT8HtYNiWs/k9ixM2+mecXXwotz3y16NHYupcDc2pe2V0oUARd 7HJR04mGjVHFmGx/GOxAv88SmDdIcdqOR0BrFYNIm2JFH+iFxoObORn038z9kMhKC+20 gJ2vOH9G9Ua9tdaGVT2XQzUQk5jHvgwDNGjVqF+H2f1LLg09maxR7DM4N8Y6yk7XPl5N Uq5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=LDkssFbz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v4-20020a509544000000b00450c1de6234si5070955eda.587.2022.09.22.06.57.45; Thu, 22 Sep 2022 06:58:22 -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=@microchip.com header.s=mchp header.b=LDkssFbz; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbiIVNZp (ORCPT + 99 others); Thu, 22 Sep 2022 09:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiIVNZn (ORCPT ); Thu, 22 Sep 2022 09:25:43 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16BFCED5D6 for ; Thu, 22 Sep 2022 06:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1663853141; x=1695389141; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=cidiMQOO2/CtvRETpS3xh6wH67slG7ERsjd5cZuGqpU=; b=LDkssFbz87uTP5w6fwVgqXWWUnxqbBB+OnWDdPtfEUOiVUdAODhBuDzm /jZL6GcHSS6yBldqjTZyC39y4a4DfCX7vvGW5uTrLshQ8rhSygtplyWu4 0Nb5A0/cXrAvUgiy/Ap2vRYbEyfU2gaYpsl7lr3GZ+ho3gGyLELyhVLFL 35Vl8cXUDb73CRz7V42KJyXRdyjBncXho2ikzCedhNaRLDzAdxN1ZNr6b GtRzOI494aCa5U8+IbVqaPOEhCCRSIAmtSScIyMTG76GL+8FqjX7tt46A sd0+iLLn8TEpBgqyUFHEQkB/DBvp6mRTTmyviEcx1NMaLZmelOP6bt8Fb A==; X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="181533061" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Sep 2022 06:25:40 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Thu, 22 Sep 2022 06:25:39 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12 via Frontend Transport; Thu, 22 Sep 2022 06:25:37 -0700 Date: Thu, 22 Sep 2022 14:25:15 +0100 From: Conor Dooley To: Samuel Holland CC: Palmer Dabbelt , , Albert Ou , Anup Patel , Atish Patra , Dao Lu , Guo Ren , Heiko Stuebner , Jisheng Zhang , Paul Walmsley , Subject: Re: [PATCH] riscv: Fix build with CONFIG_CC_OPTIMIZE_FOR_SIZE=y Message-ID: References: <20220922060958.44203-1-samuel@sholland.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220922060958.44203-1-samuel@sholland.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham 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, Sep 22, 2022 at 01:09:58AM -0500, Samuel Holland wrote: > commit 8eb060e10185 ("arch/riscv: add Zihintpause support") broke > building with CONFIG_CC_OPTIMIZE_FOR_SIZE enabled (gcc 11.1.0): clang-15 chucks a fit too.. Reviewed-by: Conor Dooley > > CC arch/riscv/kernel/vdso/vgettimeofday.o > In file included from : > ./arch/riscv/include/asm/jump_label.h: In function 'cpu_relax': > ././include/linux/compiler_types.h:285:33: warning: 'asm' operand 0 probably does not match constraints > 285 | #define asm_volatile_goto(x...) asm goto(x) > | ^~~ > ./arch/riscv/include/asm/jump_label.h:41:9: note: in expansion of macro 'asm_volatile_goto' > 41 | asm_volatile_goto( > | ^~~~~~~~~~~~~~~~~ > ././include/linux/compiler_types.h:285:33: error: impossible constraint in 'asm' > 285 | #define asm_volatile_goto(x...) asm goto(x) > | ^~~ > ./arch/riscv/include/asm/jump_label.h:41:9: note: in expansion of macro 'asm_volatile_goto' > 41 | asm_volatile_goto( > | ^~~~~~~~~~~~~~~~~ > make[1]: *** [scripts/Makefile.build:249: arch/riscv/kernel/vdso/vgettimeofday.o] Error 1 > make: *** [arch/riscv/Makefile:128: vdso_prepare] Error 2 > > Having a static branch in cpu_relax() is problematic because that > function is widely inlined, including in some quite complex functions > like in the VDSO. A quick measurement shows this static branch is > responsible by itself for around 40% of the jump table. > > Drop the static branch, which ends up being the same number of > instructions anyway. If Zihintpause is supported, we trade the nop from > the static branch for a div. If Zihintpause is unsupported, we trade the > jump from the static branch for (what gets interpreted as) a nop. > > Fixes: 8eb060e10185 ("arch/riscv: add Zihintpause support") > Signed-off-by: Samuel Holland > --- > > arch/riscv/include/asm/hwcap.h | 3 --- > arch/riscv/include/asm/vdso/processor.h | 25 ++++++++++--------------- > 2 files changed, 10 insertions(+), 18 deletions(-) > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > index 6f59ec64175e..b21d46e68386 100644 > --- a/arch/riscv/include/asm/hwcap.h > +++ b/arch/riscv/include/asm/hwcap.h > @@ -68,7 +68,6 @@ enum riscv_isa_ext_id { > */ > enum riscv_isa_ext_key { > RISCV_ISA_EXT_KEY_FPU, /* For 'F' and 'D' */ > - RISCV_ISA_EXT_KEY_ZIHINTPAUSE, > RISCV_ISA_EXT_KEY_MAX, > }; > > @@ -88,8 +87,6 @@ static __always_inline int riscv_isa_ext2key(int num) > return RISCV_ISA_EXT_KEY_FPU; > case RISCV_ISA_EXT_d: > return RISCV_ISA_EXT_KEY_FPU; > - case RISCV_ISA_EXT_ZIHINTPAUSE: > - return RISCV_ISA_EXT_KEY_ZIHINTPAUSE; > default: > return -EINVAL; > } > diff --git a/arch/riscv/include/asm/vdso/processor.h b/arch/riscv/include/asm/vdso/processor.h > index 1e4f8b4aef79..789bdb8211a2 100644 > --- a/arch/riscv/include/asm/vdso/processor.h > +++ b/arch/riscv/include/asm/vdso/processor.h > @@ -4,30 +4,25 @@ > > #ifndef __ASSEMBLY__ > > -#include > #include > -#include > > static inline void cpu_relax(void) > { > - if (!static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_ZIHINTPAUSE])) { > #ifdef __riscv_muldiv > - int dummy; > - /* In lieu of a halt instruction, induce a long-latency stall. */ > - __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); > + int dummy; > + /* In lieu of a halt instruction, induce a long-latency stall. */ > + __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); > #endif > - } else { > - /* > - * Reduce instruction retirement. > - * This assumes the PC changes. > - */ > + /* > + * Reduce instruction retirement. > + * This assumes the PC changes. > + */ > #ifdef __riscv_zihintpause > - __asm__ __volatile__ ("pause"); > + __asm__ __volatile__ ("pause"); > #else > - /* Encoding of the pause instruction */ > - __asm__ __volatile__ (".4byte 0x100000F"); > + /* Encoding of the pause instruction */ > + __asm__ __volatile__ (".4byte 0x100000F"); > #endif > - } > barrier(); > } > > -- > 2.35.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv