Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp528164rwb; Thu, 6 Oct 2022 00:13:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5y8qIo04WADnzOrRnffvl4vLsEjwIZUSLwRWss8xPa8Jo98k6SFMTvZVoOgwjskd7HiutI X-Received: by 2002:a17:90b:3ece:b0:20a:ea98:b93e with SMTP id rm14-20020a17090b3ece00b0020aea98b93emr3719519pjb.123.1665040388409; Thu, 06 Oct 2022 00:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665040388; cv=none; d=google.com; s=arc-20160816; b=A3yomitOKoHNfSCtXRb93bwywNaqa89b3hevRTvpxg2eXHx8z7YZw23CXN0gmxQryK wSg2zGdas8/nZPZf8AlItS0/2fT1fHkkWnmo0NwMSrGQXeL5mNJK2O7RxTuSGd+Sx5Ql aPal5j5VruM2IKmBbhiRrg6m3eW+17U1RqgR9VM3IpyP8q+6hHlvNVlO2yPSKw6mDX8e D5+Mr6TvhH9Wmwd96KM21jbt/ANNJBDDz/KFBNXGoszwPheJCehbAefvlbMthSohmDRL hCfMTgxp6XBrdr/rwUdGY+AX1KbVZWYu1rE/UzC1VZKzLx1d6ErmcD1AJjbVYRTyBhDk 4Z+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 :message-id:date:subject:cc:to:from:dkim-signature; bh=6d4UWLLAp5CbbJ7mVyx1JfeuffYH3wP3V/iLO3kR7rc=; b=vTO51kt4ccPhFtEzouqmHuhZlPdkV48TU5VrK6IofPDQxz4gnNv/fyIGqMFMitQ8vt 3KrYGeiLD1mfCRcbd0eLFVtJUSYSD+t4w7yevqlJY6PI1J4Wz898bXQqme6mQ1D9D0n7 SAowBXTwbsw2+60MS723B39WXDAeVPgqNMnGGVNv7cgmR0lsbgnNhdzEdfqjQ+7/Aa8k ku52yh7n+3ArPerB9HMlNt2xaRF1SUAWgH3OCM93LFCo7AMEiiK6I1laVX/EsclKtfOf 11VhhEIWmE88IAWwJIkcrzh1pNqMnD4cxfrgWfAF+pvxElxFk99qlDzJQpiKSzk5+W1c LfvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nzw9aL84; 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 mi16-20020a17090b4b5000b0020a9664b1b5si2360354pjb.17.2022.10.06.00.12.56; Thu, 06 Oct 2022 00:13:08 -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=nzw9aL84; 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 S229637AbiJFGuP (ORCPT + 99 others); Thu, 6 Oct 2022 02:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiJFGuK (ORCPT ); Thu, 6 Oct 2022 02:50:10 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2C1A895D3 for ; Wed, 5 Oct 2022 23:50:08 -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 sin.source.kernel.org (Postfix) with ESMTPS id 68662CE0B2A for ; Thu, 6 Oct 2022 06:50:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C8EBC433C1; Thu, 6 Oct 2022 06:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665039002; bh=8znyUi7frmFRBSfuJybw+EkaJdAE56P9QcmLz7WlrfU=; h=From:To:Cc:Subject:Date:From; b=nzw9aL84H/hEuWBrmMCqO7iVRhyDMlG92G8VdzvEhwA5J7VnKKgTXIZxr9alq5saR eOsn40rDosNmHBJ1201GllDNCWXi4+vICrBWr823ZlLxzX/eU9rho7b9itXQlT1wCK nobAVA+SB7ec/EHF/A71eObffcMnDWHOmGybB+seGnp/tDeaocq+6SwiXQ3rQGPzVH yMK7dEzF5BBfG2SxbACWCycSX2pR8P/b4Tg37hmYy5uWkTW3I2BLVp0YKwiKFOdZ3r hpcN/v4b3nKwY8kRZy3Fos+F4hcmgk22kt0cshIcfa3bu+wl340nJeY9ZZ4wYKcrqq WJd0IXmW3VOxQ== From: Jisheng Zhang 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 Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints Date: Thu, 6 Oct 2022 14:40:28 +0800 Message-Id: <20221006064028.548-1-jszhang@kernel.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.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 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