From: <Conor.Dooley@microchip.com>
To: <jszhang@kernel.org>
Cc: <peterz@infradead.org>, <jpoimboe@kernel.org>,
<jbaron@akamai.com>, <rostedt@goodmis.org>,
<ajones@ventanamicro.com>, <ardb@kernel.org>,
<paul.walmsley@sifive.com>, <palmer@dabbelt.com>,
<aou@eecs.berkeley.edu>, <nathan@kernel.org>,
<ndesaulniers@google.com>, <trix@redhat.com>,
<samuel@sholland.org>, <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
Date: Thu, 6 Oct 2022 12:44:32 +0000 [thread overview]
Message-ID: <4c8fa16a-8463-ee32-7307-0383fa94403c@microchip.com> (raw)
In-Reply-To: <20221006124144.abaz74g7nxrb5hxj@kamzik>
On 06/10/2022 13:41, Andrew Jones wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> 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 <command-line>:
>> ./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/
Hey Jisheng,
Could you please make these normal link tags.?
Also could you please add the reported-by from samuel & a fixes tag?
Thanks,
Conor.
>> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
>> ---
>> 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 <ajones@ventanamicro.com>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-10-06 12:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 6:40 [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints Jisheng Zhang
2022-10-06 12:41 ` Andrew Jones
2022-10-06 12:44 ` Conor.Dooley [this message]
2022-10-08 13:55 ` Jisheng Zhang
2022-10-08 14:07 ` Steven Rostedt
2022-10-08 14:09 ` Steven Rostedt
2022-10-08 14:08 ` Jisheng Zhang
2022-10-08 14:22 ` Conor Dooley
2022-10-11 7:32 ` Heiko Stuebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c8fa16a-8463-ee32-7307-0383fa94403c@microchip.com \
--to=conor.dooley@microchip.com \
--cc=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=jbaron@akamai.com \
--cc=jpoimboe@kernel.org \
--cc=jszhang@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=samuel@sholland.org \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox