Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp876344rwb; Thu, 6 Oct 2022 05:49:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67yM/6ZvXqRCU00MWK1xI2Hagdh70u1GZyVxJL4Tvt+vNCpyRWgtOgY7x2CxQum+xacDX6 X-Received: by 2002:a17:906:eec7:b0:733:189f:b07a with SMTP id wu7-20020a170906eec700b00733189fb07amr3885262ejb.230.1665060552761; Thu, 06 Oct 2022 05:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665060552; cv=none; d=google.com; s=arc-20160816; b=ioysPC91XLYfvSC9EygtXlGloQ6qzX7HLcKT9Jl8TGKIeze4PtpFkwRFeeZXtW4Izu 92lK5iHSLG3tvAFPLH8awH7fM/OOjG/GfIbVEdYE2qxOpiP3CR4p6AdWZF5QB4lLHgMp /5FQVAVlTtBqEzcsa1netbYrHtvbVvcVLUwXBDUpDVm3sSZusilbTv5bo+ajXpqk9UzJ wwi9N4fqMVNMxoCzYimT9l6/mfAGP5zZC0aV9vuePERAwRKXkAIJkQwGGiltYrdUIZty JMxZoTK5LWzPGJbUPywy+B709ApyF35HmSfGKw5mA2wGrnc39dcSzXBDRzpBFJsGQpqF 4Xhg== 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=AK+3/ho4RvmuiMuVJwr3Rpg3eo+stcqQKAj7PVtNyyk=; b=a3yIs02UnNEujT6RyA5+j5/RxqfAQI9QlW56E2d0Ks2klFVOn2tlMCTiLFgHqV782f JT41ytaFCGtlrQ5yu1S256jbrQiL5zZbRlNoNt7yM5YPVl/GT68u/2+eybnC8NLSqmps 2ambbXp5ES41gw766hXj06yf9tUpKXJFsO6JGQDXWth1og+dZbGosxHpH8Jv1gT2RMuX yhrTRe76Xsccn797IntVJmNuEP4r880X8h+k9/y7G1D2DrrBMkXwy1Pa7sth1OcYqUId E9zjBlASyt71ombHvp5IHg4mO3NNhCA6l7vu4wAK1VnbOug8FRyjwdwk/rWKO9zxeAql YVkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Cn5WuPb4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga31-20020a1709070c1f00b007803b5893f2si16706472ejc.672.2022.10.06.05.48.47; Thu, 06 Oct 2022 05:49:12 -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=@ventanamicro.com header.s=google header.b=Cn5WuPb4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229575AbiJFMmD (ORCPT + 99 others); Thu, 6 Oct 2022 08:42:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbiJFMlx (ORCPT ); Thu, 6 Oct 2022 08:41:53 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66EEA9C2FA for ; Thu, 6 Oct 2022 05:41:52 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id bj12so4190768ejb.13 for ; Thu, 06 Oct 2022 05:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=AK+3/ho4RvmuiMuVJwr3Rpg3eo+stcqQKAj7PVtNyyk=; b=Cn5WuPb4Je4FcUwPxSwP26BPdp11/zoskFJi5zb67Br/FE3od2wcCzBU9vAZAc9iVX 2jZ1jngYT90kB69JX4wfUxYtSl0HShjHlB0fTVejxdULPmLS5Iyb3xq+dob4S4X+2InN OGJ/V0F8ZnG646cAcqFEsdNTsGzSw4zijnBZJOj72ttfr8lCWPIPzL1K65z2v46/ahkd nsEwXeCtXu3Ad4EhE4KStgBO9/QsjDNYFzPKBczoRFikiKSf2DPyWq6SU9lUu29GhMVU SHiqJVWRjPXwGCBpVOfvVKY3Jbb64nzyYK0YLwcPjEvd1yAd03Oy/QhuEGhOYhtzr6kM 6LWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=AK+3/ho4RvmuiMuVJwr3Rpg3eo+stcqQKAj7PVtNyyk=; b=POfmo1VcfRKI1tZxGFKCqGAJTGrB4OWNVHov+s+pC4GdPkdfPPNxMMcGyIm7OYerqO 4qFv3gBVqonfVti14k6/gk6gOQ6DfMjkAGO4MjNL6wt6QZP/WsirCYsZYpAiDsviQ+Gf dLbNFpDoZJq3xc/rke8ajSfNgfCWi+Sv7KUUENc1vNWHRMONmk3fmbSfYRn4uHWuwku/ 71jfRitehoYjBKbrRu+r2QHLun5x2EzW2znAbUQSFmoeHcwSswyhe627Vo2ACBRYyNsC 1+RLrUM1hq8vBveWcUv2f9vzsAiyyvWY7tYhZAT6ZdhvmZ93X/V+LaZ0pKzV74AhRYzT Ix0Q== X-Gm-Message-State: ACrzQf0aGRJEGcgIuAzUgRbU0oZMizqnnBTF+UZt7k7GpM7Itwb+7LLa J6m2UZGAZobIaEhloPMxI3AItQ== X-Received: by 2002:a17:906:9b8e:b0:78c:65a4:af84 with SMTP id dd14-20020a1709069b8e00b0078c65a4af84mr3755800ejc.127.1665060110985; Thu, 06 Oct 2022 05:41:50 -0700 (PDT) Received: from localhost (cst2-173-61.cust.vodafone.cz. [31.30.173.61]) by smtp.gmail.com with ESMTPSA id k7-20020a170906a38700b0078d2a2ca930sm2742860ejz.85.2022.10.06.05.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 05:41:50 -0700 (PDT) Date: Thu, 6 Oct 2022 14:41:44 +0200 From: Andrew Jones To: Jisheng Zhang Cc: 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, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints Message-ID: <20221006124144.abaz74g7nxrb5hxj@kamzik> References: <20221006064028.548-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221006064028.548-1-jszhang@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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, Oct 06, 2022 at 02:40:28PM +0800, Jisheng Zhang wrote: > 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. > > [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" > -- > 2.37.2 > Reviewed-by: Andrew Jones