* [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints
@ 2022-10-06 6:40 Jisheng Zhang
2022-10-06 12:41 ` Andrew Jones
2022-10-11 7:32 ` Heiko Stuebner
0 siblings, 2 replies; 9+ messages in thread
From: Jisheng Zhang @ 2022-10-06 6:40 UTC (permalink / raw)
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, linux-kernel, llvm
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/
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 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 2022-10-11 7:32 ` Heiko Stuebner 1 sibling, 1 reply; 9+ messages in thread From: Andrew Jones @ 2022-10-06 12:41 UTC (permalink / raw) 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, linux-kernel, llvm 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/ > 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> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-06 12:41 ` Andrew Jones @ 2022-10-06 12:44 ` Conor.Dooley 2022-10-08 13:55 ` Jisheng Zhang 0 siblings, 1 reply; 9+ messages in thread From: Conor.Dooley @ 2022-10-06 12:44 UTC (permalink / raw) To: jszhang Cc: peterz, jpoimboe, jbaron, rostedt, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-06 12:44 ` Conor.Dooley @ 2022-10-08 13:55 ` Jisheng Zhang 2022-10-08 14:07 ` Steven Rostedt 2022-10-08 14:22 ` Conor Dooley 0 siblings, 2 replies; 9+ messages in thread From: Jisheng Zhang @ 2022-10-08 13:55 UTC (permalink / raw) To: Conor.Dooley Cc: peterz, jpoimboe, jbaron, rostedt, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm On Thu, Oct 06, 2022 at 12:44:32PM +0000, Conor.Dooley@microchip.com wrote: > 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, Hi, > > Could you please make these normal link tags.? How to make these link tags? I just used the permalink in lore.kernel.org > Also could you please add the reported-by from samuel & a fixes tag? I will add Reported-by tag, but I'm not sure whether fixes tag is suitable, and which commit I could use? commit 8eb060e1018 ("arch/riscv: add Zihintpause support")? > > 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 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 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:22 ` Conor Dooley 1 sibling, 1 reply; 9+ messages in thread From: Steven Rostedt @ 2022-10-08 14:07 UTC (permalink / raw) To: Jisheng Zhang Cc: Conor.Dooley, peterz, jpoimboe, jbaron, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm On Sat, 8 Oct 2022 21:55:07 +0800 Jisheng Zhang <jszhang@kernel.org> wrote: > > >> [1]https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > > >> [2]https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > > > > > > Could you please make these normal link tags.? > > How to make these link tags? I just used the permalink in > lore.kernel.org Link: https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ Link: https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ -- Steve ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 14:07 ` Steven Rostedt @ 2022-10-08 14:09 ` Steven Rostedt 2022-10-08 14:08 ` Jisheng Zhang 0 siblings, 1 reply; 9+ messages in thread From: Steven Rostedt @ 2022-10-08 14:09 UTC (permalink / raw) To: Jisheng Zhang Cc: Conor.Dooley, peterz, jpoimboe, jbaron, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm On Sat, 8 Oct 2022 10:07:48 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > Link: https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > Link: https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > This way tools can be used to map commits to links relevant to them. They key off the "Link:" tag keyword. -- Steve ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 14:09 ` Steven Rostedt @ 2022-10-08 14:08 ` Jisheng Zhang 0 siblings, 0 replies; 9+ messages in thread From: Jisheng Zhang @ 2022-10-08 14:08 UTC (permalink / raw) To: Steven Rostedt Cc: Conor.Dooley, peterz, jpoimboe, jbaron, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm On Sat, Oct 08, 2022 at 10:09:02AM -0400, Steven Rostedt wrote: > On Sat, 8 Oct 2022 10:07:48 -0400 > Steven Rostedt <rostedt@goodmis.org> wrote: > > > Link: https://lore.kernel.org/linux-riscv/20220922060958.44203-1-samuel@sholland.org/ > > Link: https://lore.kernel.org/all/20210212094059.5f8d05e8@gandalf.local.home/ > > > > This way tools can be used to map commits to links relevant to them. > They key off the "Link:" tag keyword. Thank you so much! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 13:55 ` Jisheng Zhang 2022-10-08 14:07 ` Steven Rostedt @ 2022-10-08 14:22 ` Conor Dooley 1 sibling, 0 replies; 9+ messages in thread From: Conor Dooley @ 2022-10-08 14:22 UTC (permalink / raw) To: Jisheng Zhang Cc: Conor.Dooley, peterz, jpoimboe, jbaron, rostedt, ajones, ardb, paul.walmsley, palmer, aou, nathan, ndesaulniers, trix, samuel, linux-riscv, linux-kernel, llvm On Sat, Oct 08, 2022 at 09:55:07PM +0800, Jisheng Zhang wrote: > On Thu, Oct 06, 2022 at 12:44:32PM +0000, Conor.Dooley@microchip.com wrote: > > Also could you please add the reported-by from samuel & a fixes tag? > > I will add Reported-by tag, but I'm not sure whether fixes tag > is suitable, and which commit I could use? commit 8eb060e1018 > ("arch/riscv: add Zihintpause support")? That is the commit that Samuel blamed for the issue & is the one that added the static branch - so I guess so! Thanks, Conor. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] riscv: jump_label: mark arguments as const to satisfy asm constraints 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-11 7:32 ` Heiko Stuebner 1 sibling, 0 replies; 9+ messages in thread From: Heiko Stuebner @ 2022-10-11 7:32 UTC (permalink / raw) 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, linux-riscv Cc: linux-riscv, linux-kernel, llvm, Jisheng Zhang Am Donnerstag, 6. Oktober 2022, 08:40:28 CEST schrieb Jisheng Zhang: > 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. I ran into the same build-issue when enabling CC_OPTIMIZE_FOR_SIZE and this patch fixes it, so Tested-by: Heiko Stuebner <heiko@sntech.de> > [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 <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" > ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-10-11 7:32 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox