Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp722895rwb; Thu, 6 Oct 2022 03:44:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5S4vrNN1WJ+V+qMRGyWmVl09Mp2ERLRJb96dFf9z4JuYDLPSOP4o1COApvaqySQDuH16je X-Received: by 2002:aa7:d306:0:b0:459:6e9:6284 with SMTP id p6-20020aa7d306000000b0045906e96284mr3926681edq.70.1665053047511; Thu, 06 Oct 2022 03:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665053047; cv=none; d=google.com; s=arc-20160816; b=EMCyONCaY0Gm1Tz08ywzmA98AE78ylPTsEzQ7LcCont2pXihScOfRwJemYXPfJW2r7 IBHwgegR/Rgap2JffHRSh1JaiFnWpLbTD+4SBjQz9qEUDnMrPzq8N63KUtiVKPf+Gp+V u08r10Dvkpm5aeeCvypjn/uyicOPF4o6x/jXWOTvTUVCarK73I0jnWRp8Y7aiw4KAip3 gdnLXfSX/iCxeshkjDAqM7iH8AHS3nc70Tzg7YVjm58RdQdh71Y0SyPITj640olKzJxR zImhFyPNfao2UvZRfv/K+xaWh3VuYRcPEYciTACAZ6qvwKCNRrjIFgn7vzCEJH6BtiF+ Tb2Q== 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; bh=uxGGCQWTTFFkdF+n7o4pwTAcbz0bveT4GUqrNqryh8g=; b=oGovP1SQ1eez3RsBd5Dqg5BwQvLfdsJpdU52TrGNvOAD5pTWTsk3OBh4M2N0gLRlee jqAQIxqdBJCczIosutw9eWM4yqnQ2TvP62S1dX5+jCVziArYP0QJV3DeVyEAMaTyluXv eiQYTlBrKgw51/M0lotyS8y+UvqKLsUdhofOkPSC2J5txnogwmfi2maa6V6mYNtwm/ZH P9lYZzzNZLjAF/PzyXLq7Y0u6PHIi4pXHGAKMpf94TP+Z/Rtmgf4jblF5cAqz/0ntXdm 1gJq9bwCOwlv2Vh8EkjDwur7EJ8oZM0DdcOe6DMB1WP1S15JmnTy1benDCS3Kx2wW9ia r/Ig== 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=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp20-20020a170906c15400b00783d10996f7si9716188ejc.606.2022.10.06.03.43.41; Thu, 06 Oct 2022 03:44:07 -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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiJFKOy (ORCPT + 99 others); Thu, 6 Oct 2022 06:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbiJFKOu (ORCPT ); Thu, 6 Oct 2022 06:14:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 52A4BFAD7 for ; Thu, 6 Oct 2022 03:14:49 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 57D73169C; Thu, 6 Oct 2022 03:14:55 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.34.149]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B705F3F792; Thu, 6 Oct 2022 03:14:47 -0700 (PDT) Date: Thu, 6 Oct 2022 11:14:42 +0100 From: Mark Rutland To: Jisheng Zhang Cc: Catalin Marinas , Will Deacon , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] arm64: jump_label: mark arguments as const to satisfy asm constraints Message-ID: References: <20221006075542.2658-1-jszhang@kernel.org> <20221006075542.2658-2-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221006075542.2658-2-jszhang@kernel.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 03:55:41PM +0800, Jisheng Zhang wrote: > Inspired by x86 commit 864b435514b2("x86/jump_label: Mark arguments as > const to satisfy asm constraints"), mark arch_static_branch()'s and > arch_static_branch_jump()'s arguments as const to satisfy asm > constraints. And Steven in [1] also pointed out that "The "i" > constraint needs to be a constant." It needs to be a *compile-time constant*, but `const` on a function argument only ensures that the function can't modify the argument, not that it's a constant in the caller. I think this is a quirk of the optimizer rather than anything else. > Tested with building a simple external kernel module with "O0". Is building with `-O0` supported? I thought we required using `-O2` or above for a bunch of code that requires constant propagation, etc. I don't really have a problem with making this const, but I don't particularly want to try to "fix" all the other code that depends on constant propagation to assemble, and I'm worried this is the canary in the coal mine. Thanks, Mark. > > [1]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > > Signed-off-by: Jisheng Zhang > --- > arch/arm64/include/asm/jump_label.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h > index cea441b6aa5d..48ddc0f45d22 100644 > --- a/arch/arm64/include/asm/jump_label.h > +++ b/arch/arm64/include/asm/jump_label.h > @@ -15,8 +15,8 @@ > > #define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE > > -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( > "1: nop \n\t" > @@ -32,8 +32,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( > "1: b %l[l_yes] \n\t" > -- > 2.37.2 >