* [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints
@ 2022-10-08 14:54 Jisheng Zhang
2022-10-11 7:39 ` Heiko Stuebner
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jisheng Zhang @ 2022-10-08 14:54 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
Cc: linux-riscv, linux-kernel, llvm, Samuel Holland, Andrew Jones
Samuel reported that the static branch usage in cpu_relax() breaks
building with CONFIG_CC_OPTIMIZE_FOR_SIZE:
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: "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 <samuel@sholland.org>
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
---
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 14:54 [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints Jisheng Zhang @ 2022-10-11 7:39 ` Heiko Stuebner 2022-10-12 13:28 ` Conor Dooley 2022-10-26 13:43 ` Palmer Dabbelt 2 siblings, 0 replies; 5+ messages in thread From: Heiko Stuebner @ 2022-10-11 7:39 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, linux-riscv Cc: linux-riscv, linux-kernel, llvm, Samuel Holland, Andrew Jones, Jisheng Zhang Am Samstag, 8. Oktober 2022, 16:54:37 CEST schrieb Jisheng Zhang: > Samuel reported that the static branch usage in cpu_relax() breaks > building with CONFIG_CC_OPTIMIZE_FOR_SIZE: > > 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: "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 <samuel@sholland.org> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> 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> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 14:54 [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints Jisheng Zhang 2022-10-11 7:39 ` Heiko Stuebner @ 2022-10-12 13:28 ` Conor Dooley 2022-10-31 17:49 ` Jisheng Zhang 2022-10-26 13:43 ` Palmer Dabbelt 2 siblings, 1 reply; 5+ messages in thread From: Conor Dooley @ 2022-10-12 13:28 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, linux-riscv, linux-kernel, llvm, Samuel Holland, Andrew Jones Hey Jisheng, 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? 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 <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: "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 <samuel@sholland.org> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org> > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > --- > > 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 > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-12 13:28 ` Conor Dooley @ 2022-10-31 17:49 ` Jisheng Zhang 0 siblings, 0 replies; 5+ messages in thread From: Jisheng Zhang @ 2022-10-31 17:49 UTC (permalink / raw) 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, linux-kernel, llvm, Samuel Holland, Andrew Jones 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 <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: "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 <samuel@sholland.org> > > Signed-off-by: Jisheng Zhang <jszhang@kernel.org> > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com> > > --- > > > > 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 > > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints 2022-10-08 14:54 [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints Jisheng Zhang 2022-10-11 7:39 ` Heiko Stuebner 2022-10-12 13:28 ` Conor Dooley @ 2022-10-26 13:43 ` Palmer Dabbelt 2 siblings, 0 replies; 5+ messages in thread From: Palmer Dabbelt @ 2022-10-26 13:43 UTC (permalink / raw) To: Tom Rix, Ard Biesheuvel, Steven Rostedt, Jisheng Zhang, Paul Walmsley, Peter Zijlstra, Nathan Chancellor, Nick Desaulniers, Palmer Dabbelt, Albert Ou, Josh Poimboeuf, Jason Baron Cc: linux-riscv, Samuel Holland, llvm, Andrew Jones, linux-kernel On Sat, 8 Oct 2022 22:54:37 +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 <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 > > [...] Applied, thanks! [1/1] riscv: jump_label: mark arguments as const to satisfy asm constraints commit: 89fd4a1df829187d4d35f6a520cc531de622e6f0 Best regards, -- Palmer Dabbelt <palmer@rivosinc.com> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-31 17:59 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-08 14:54 [PATCH v2] riscv: jump_label: mark arguments as const to satisfy asm constraints Jisheng Zhang 2022-10-11 7:39 ` Heiko Stuebner 2022-10-12 13:28 ` Conor Dooley 2022-10-31 17:49 ` Jisheng Zhang 2022-10-26 13:43 ` Palmer Dabbelt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).