riscv: jump_label: mark arguments as const to satisfy asm constraints
Subsystems (2)
PATCH 1/1 riscv: jump_label: mark arguments as const to satisfy asm constraints
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/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
--- arch/riscv/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/riscv/include/asm/jump_label.h +4 -4
@@ -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"
Signature · 1 line
2.37.2
Quoted 70 lines · 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 | #defineasm_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 | #defineasm_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 2Maybe "-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 andCC_OPTIMIZE_FOR_SIZE+ clang.[1]https://lore.kernel.org/linux-riscv/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/include/asm/jump_label.h +4
-4@@ -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"Signature · 1 line
2.37.2
Quoted 39 lines · Andrew Jones
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 36 lines · 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 | #defineasm_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 | #defineasm_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 2Maybe "-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 andCC_OPTIMIZE_FOR_SIZE+ clang.[1]https://lore.kernel.org/linux-riscv/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
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.
Quoted 41 lines
Quoted 32 lines
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/include/asm/jump_label.h +4
-5@@ -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" --Quoted 2 lines
2.37.2
Reviewed-by Andrew Jones <[email protected]>_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 36 lines · On Thu, Oct 06, 2022 at 12:44:32PM +0000, [email protected] wrote:
Quoted 35 lines · Andrew Jones
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 32 lines · 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 | #defineasm_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 | #defineasm_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 2Maybe "-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.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Tested by
CC_OPTIMIZE_FOR_SIZE+ gcc andCC_OPTIMIZE_FOR_SIZE+ clang.[1]https://lore.kernel.org/linux-riscv/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
Hey Jisheng,
Hi,
Quoted 2 lines
Could you please make these normal link tags.?
How to make these link tags? I just used the permalink in lore.kernel.org
Quoted 1 line
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")?
Quoted 46 lines
Thanks,
Conor.Quoted 41 lines
Quoted 32 lines
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/include/asm/jump_label.h +4
-5@@ -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" --Quoted 2 lines
2.37.2
Reviewed-by Andrew Jones <[email protected]>_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Steven Rostedt
reviewerQuoted 8 lines · On Sat, 8 Oct 2022 21:55:07 +0800 Jisheng Zhang <[email protected]> wrote:
Quoted 5 lines
Quoted 2 lines
Could you please make these normal link tags.?
How to make these link tags? I just used the permalink in lore.kernel.org
-- Steve
Steven Rostedt
reviewerQuoted 3 lines · On Sat, 8 Oct 2022 10:07:48 -0400 Steven Rostedt <[email protected]> wrote:
This way tools can be used to map commits to links relevant to them. They key off the "Link:" tag keyword.
-- Steve
Quoted 9 lines · Steven Rostedt
Quoted 3 lines · On Sat, 8 Oct 2022 10:07:48 -0400 Steven Rostedt <[email protected]> wrote:
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!
Quoted 6 lines · Jisheng Zhang
Quoted 1 line · On Thu, Oct 06, 2022 at 12:44:32PM +0000, [email protected] 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.
Am Donnerstag, 6. Oktober 2022, 08:40:28 CEST schrieb Jisheng Zhang:
Quoted 25 lines
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 | #defineasm_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 | #defineasm_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
Quoted 8 lines
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 andCC_OPTIMIZE_FOR_SIZE+ clang.
I ran into the same build-issue when enabling CC_OPTIMIZE_FOR_SIZE and this patch fixes it, so
Quoted 34 lines
[1]https://lore.kernel.org/linux-riscv/[email protected]/ [2]https://lore.kernel.org/all/[email protected]/
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/riscv/include/asm/jump_label.h +4
-4@@ -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"