Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1127441rwi; Mon, 31 Oct 2022 11:42:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HQ3PZP1CxcF7y+bvZuaNiVo6au5vkaBUSHsloZDzN7yhErCUQTsIQ+kSzpM6lldLQIzvX X-Received: by 2002:a17:902:c7c4:b0:186:5ebe:38e with SMTP id r4-20020a170902c7c400b001865ebe038emr15630644pla.33.1667241748206; Mon, 31 Oct 2022 11:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667241748; cv=none; d=google.com; s=arc-20160816; b=Fbh5d3nIlVv6GpRgmf4XIuzkkjJ/7Y4bWBgdsaXOPoRc4jvroLUvWpCU6cgpHdqrrD rzRYqeJmSIoYnJY1dHk+INn2U3G9cKsw9YX+hJ6ngL+hCMsQmR8DI39gaiXpAiSZkl7I vzD3e4LzR/tw9IirZWYIdzv6IW6chRrfyINDFtZ649ccTrxH18qQ810Q/G3aEeO1GGg0 PaZvr98RbJQgEu747/ud0UvzKGWcG5bKl/yL3qF5r2wmJzyLl103RXoAAmtrd/QKbQiD 2KbW8CJvPautbmrmsNpqwujKR1LbO7DKKUugJX4Wz53Z1SaVTaI8uBV6p5DdLbeCUE6J xLXw== 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=d+m6Im6MaR/mz8dFsZ/MohjWkphdSl2Gcb6/VOZhV24=; b=Gm7CM0+hjBGTMV+AJqzKBev0D0ixfqYBE+nDwlXuvsSwksgLZd96gh8Z0ul3eLzpwi K50M/RqmZbLv2Rb8HduvPlRJA3eBele7PcJ058inrcOY7PzerUWDvzBLngc9b0Xb0pxC 292h4eAISXA6eOFzuPpVHMQiCf1XrwBYnP4CA2HvF7vb5IKtklpawy2+mC85nV4RCB8F v3np7VRFlru5J6wsWOmioxO/U4L6mPFWXuBU5/PDuM03NbzdgZfytEhDU82/y9eqr1Hz bPq7v3KGbB8wONHFfjgbRzRl9ihDd7cRKFcyyBzZCln78kDsQU/fY0gtxUDoMI5+v4H6 K5hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TG3DxQsx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a17090341d100b0017514e57d7esi9688516ple.576.2022.10.31.11.42.15; Mon, 31 Oct 2022 11:42:28 -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=@kernel.org header.s=k20201202 header.b=TG3DxQsx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229566AbiJaR6s (ORCPT + 98 others); Mon, 31 Oct 2022 13:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiJaR6r (ORCPT ); Mon, 31 Oct 2022 13:58:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DC3925D2 for ; Mon, 31 Oct 2022 10:58:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BC2161358 for ; Mon, 31 Oct 2022 17:58:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42533C433D6; Mon, 31 Oct 2022 17:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667239124; bh=6k2VQy1WA5DlnNEe5C6X3CH+VCbSwygDOtxVDwcHUxQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TG3DxQsxTlcQfXVv7G4OFe4KJMjGMhM0EI8q77eUAjnNDZPO3drtH5yiToccym/Ba MGUyKb0gPaJC5nmCymcOKRi4vmVrZsr9fvhxwV+HQptia9Jq3DToqW5xW2FXxxi+ma Jlt/XrBdfjs3zzz+4OFy3ZRqnbNzMjYLP5d9z7Lx1jwwzVMzClc0h5KTkg58RjnIQj dJO/i8/n6Mz8rQZqdMwS04c65w/rv83/xpRmtX/xDEsGeahktfvGEwO/4iICiUGaru 0fXQwHH67hG4RWHhMspJxFALhErCWudYh2GKeOoQ70SYboE1TPhVyz/Qb5TTa21gNM ZsWLHtcqSAccA== Date: Tue, 1 Nov 2022 01:49:01 +0800 From: Jisheng Zhang To: Conor Dooley Cc: Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Samuel Holland , Andrew Jones Subject: Re: [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints Message-ID: References: <20221008145437.491-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Wed, Oct 12, 2022 at 02:28:16PM +0100, Conor Dooley wrote: > Hey Jisheng, Hi Conor, > LKP reported an error that seems to only have gone to myself & Samuel, > but the branch it's complaining about is your v1: > https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/ > > Any idea what the story is here? I tried the config in the link, I can reproduce the build error w/ and w/o the my patch. So I think the root cause of the build error is a different story. I have a fix in local repo, will send it out soon. Thanks > > Thanks, > Conor. > > On Sat, Oct 08, 2022 at 10:54:37PM +0800, Jisheng Zhang wrote: > > Samuel reported that the static branch usage in cpu_relax() breaks > > building with CONFIG_CC_OPTIMIZE_FOR_SIZE: > > > > 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: "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. > > > > Link: https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > > Link: https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > > Fixes: 8eb060e10185 ("arch/riscv: add Zihintpause support") > > Reported-by: Samuel Holland > > Signed-off-by: Jisheng Zhang > > Reviewed-by: Andrew Jones > > --- > > > > since v1: > > - add Reported-by, Reviewed-by, Fixes and Link tag > > > > 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 > >