Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1901758rwi; Tue, 11 Oct 2022 01:53:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wnsQS7bmmTUQeEDvKqzSdYJkmdsjrky6iLz30phHiuhU8LrN5knQ7BZ8s65zadQznbP0y X-Received: by 2002:a63:4651:0:b0:43c:1cb7:5c09 with SMTP id v17-20020a634651000000b0043c1cb75c09mr20901131pgk.259.1665478402648; Tue, 11 Oct 2022 01:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665478402; cv=none; d=google.com; s=arc-20160816; b=ru/x6E09Qu8atVSltzvW6thjnlsl+Ndh+xhgILnmSI9BKNcaJ94nwGmkhPgC13qH1p sGVco2lggzXfBUuCFapIuUXL9sJI+B+cLFVkdIAEUMXw+7r378HaZgBVFq8zuwCdb55N qngEteR+iQOSoIRrQL/TDThusKBvH7clnSQJ0IA6JjDtR25SyNS7nFSQuBfg5nJT7DQL ymw1ZU0wPXku19tshjo4yVUyipWipWFNc3f8z1lzwg7OlQeegPzwC3JXV6uZw3KeM2x6 /O8VM4G3zb/bZxq5kVshQUSIex7y023Nfwg30hWFvHe8JOIpFjp3KKxKaPOcss6hLVpH 3V/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=e1/Nz04HRk4njfhqjOAZcCpmYF7QBi/leskY5cEiAWk=; b=cjR/gQo17SRt/sIP7MkWq6ONilQw0DxYqATwdVIfHgAdi3B9c5Ht4J5m1EZ4tWlDZ1 vrqdmRji0nAMRtLhsWvvG8MHylytRvWGc0LBTU3MjvbgqMrP1TZKkeNsxArvuuYoH9tD 4O2M3MRbvj5osY/MBO2HfpedWGKHZ6X8chxAx0ufgG8lE3l+bf0jt1ncBQmfE3k99xFu 3G2Sf6OfCm3Y+Q5Lzesh+72MKBIjavEwo/jyEtcGjTO3ya5gBKtMvny78AiiOyfG3uqX kIS4OwNd+bF9L+8r2eX2Wi9AdJ6JxlDys5hzV7Kd1bNcnAmSsEXQvM7AQvjRQdFb8Uro fQbw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a17090a08cf00b00209febadb7esi18258627pjn.24.2022.10.11.01.53.11; Tue, 11 Oct 2022 01:53: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229659AbiJKHc6 (ORCPT + 99 others); Tue, 11 Oct 2022 03:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiJKHcz (ORCPT ); Tue, 11 Oct 2022 03:32:55 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD40F8996B for ; Tue, 11 Oct 2022 00:32:51 -0700 (PDT) Received: from p5b127dea.dip0.t-ipconnect.de ([91.18.125.234] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oi9kd-0007DL-OH; Tue, 11 Oct 2022 09:32:31 +0200 From: Heiko Stuebner To: Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Tom Rix , Samuel Holland , linux-riscv@lists.infradead.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Jisheng Zhang Subject: Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints Date: Tue, 11 Oct 2022 09:32:30 +0200 Message-ID: <2432835.C4sosBPzcN@phil> In-Reply-To: <20221006064028.548-1-jszhang@kernel.org> References: <20221006064028.548-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR 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 Am Donnerstag, 6. Oktober 2022, 08:40:28 CEST schrieb Jisheng Zhang: > Samuel reported that the static branch usage in cpu_relax() breaks > building with CONFIG_CC_OPTIMIZE_FOR_SIZE[1]: > > 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 > > Maybe "-Os" prevents GCC from detecting that the key/branch arguments > can be treated as constants and used as immediate operands. Inspired > by x86's commit 864b435514b2("x86/jump_label: Mark arguments as const to > satisfy asm constraints"), and as pointed out by Steven in [2] "The "i" > constraint needs to be a constant.", let's do similar modifications to > riscv. > > Tested by CC_OPTIMIZE_FOR_SIZE + gcc and CC_OPTIMIZE_FOR_SIZE + clang. I ran into the same build-issue when enabling CC_OPTIMIZE_FOR_SIZE and this patch fixes it, so Tested-by: Heiko Stuebner > [1]https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > [2]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > Signed-off-by: Jisheng Zhang > --- > arch/riscv/include/asm/jump_label.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/jump_label.h b/arch/riscv/include/asm/jump_label.h > index 38af2ec7b9bf..6d58bbb5da46 100644 > --- a/arch/riscv/include/asm/jump_label.h > +++ b/arch/riscv/include/asm/jump_label.h > @@ -14,8 +14,8 @@ > > #define JUMP_LABEL_NOP_SIZE 4 > > -static __always_inline bool arch_static_branch(struct static_key *key, > - bool branch) > +static __always_inline bool arch_static_branch(struct static_key * const key, > + const bool branch) > { > asm_volatile_goto( > " .option push \n\t" > @@ -35,8 +35,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, > return true; > } > > -static __always_inline bool arch_static_branch_jump(struct static_key *key, > - bool branch) > +static __always_inline bool arch_static_branch_jump(struct static_key * const key, > + const bool branch) > { > asm_volatile_goto( > " .option push \n\t" >