cpu,sched: Mark arch_cpu_idle_dead() __noreturn
Subsystems (19)
Josh Poimboeuf
maintainerv2 cover cpu,sched: Mark arch_cpu_idle_dead() __noreturn
v2:
- make arch_call_rest_init() and rest_init() __noreturn
- make objtool 'global_returns' work for weak functions
- rebase on tip/objtool/core with dependencies merged in (mingo)
- add acks
v1.1:
- add __noreturn to all arch_cpu_idle_dead() implementations (mpe)
Josh Poimboeuf (24):
alpha/cpu: Expose arch_cpu_idle_dead()'s prototype declaration alpha/cpu: Make sure arch_cpu_idle_dead() doesn't return arm/cpu: Make sure arch_cpu_idle_dead() doesn't return arm64/cpu: Mark cpu_die() __noreturn
csky/cpu: Make sure arch_cpu_idle_dead() doesn't return ia64/cpu: Mark play_dead() __noreturn
loongarch/cpu: Make sure play_dead() doesn't return loongarch/cpu: Mark play_dead() __noreturn
mips/cpu: Expose play_dead()'s prototype definition mips/cpu: Make sure play_dead() doesn't return mips/cpu: Mark play_dead() __noreturn
powerpc/cpu: Mark start_secondary_resume() __noreturn sh/cpu: Make sure play_dead() doesn't return
sh/cpu: Mark play_dead() __noreturn
sh/cpu: Expose arch_cpu_idle_dead()'s prototype definition sparc/cpu: Mark cpu_play_dead() __noreturn
x86/cpu: Make sure play_dead() doesn't return
x86/cpu: Mark play_dead() __noreturn
xtensa/cpu: Make sure cpu_die() doesn't return xtensa/cpu: Mark cpu_die() __noreturn
sched/idle: Make sure weak version of arch_cpu_idle_dead() doesn't
return
objtool: Include weak functions in 'global_noreturns' check
init: Make arch_call_rest_init() and rest_init() __noreturn sched/idle: Mark arch_cpu_idle_dead() __noreturn
arch/alpha/kernel/process.c | 4 +++- arch/arm/kernel/smp.c | 4 +++- arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/process.c | 2 +- arch/csky/kernel/smp.c | 4 +++- arch/ia64/kernel/process.c | 6 +++--- arch/loongarch/include/asm/smp.h | 2 +- arch/loongarch/kernel/process.c | 2 +- arch/loongarch/kernel/smp.c | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/process.c | 2 +- arch/mips/kernel/smp-bmips.c | 3 +++ arch/mips/loongson64/smp.c | 1 + arch/parisc/kernel/process.c | 2 +- arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/kernel/smp.c | 2 +- arch/riscv/kernel/cpu-hotplug.c | 2 +- arch/s390/kernel/idle.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/sh/include/asm/smp-ops.h | 5 +++-- arch/sh/kernel/idle.c | 3 ++- arch/sparc/include/asm/smp_64.h | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/x86/include/asm/smp.h | 3 ++- arch/x86/kernel/process.c | 4 ++-- arch/xtensa/include/asm/smp.h | 2 +- arch/xtensa/kernel/smp.c | 4 +++- include/linux/cpu.h | 2 +- include/linux/start_kernel.h | 4 ++-- init/main.c | 4 ++-- kernel/sched/idle.c | 2 +- tools/objtool/check.c | 11 +++++++---- 32 files changed, 57 insertions(+), 39 deletions(-)
Signature · 1 line
2.39.1
Josh Poimboeuf
maintainerPATCH v2 1/24 alpha/cpu: Expose arch_cpu_idle_dead()'s prototype declaration
Include <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
--- arch/alpha/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/alpha/kernel/process.c +1 -0
@@ -9,6 +9,7 @@* This file handles the architecture-dependent parts of process handling. */ +#include <linux/cpu.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/sched.h>
Signature · 1 line
2.39.1
[tip: objtool/core] alpha/cpu: Expose arch_cpu_idle_dead()'s prototype declaration
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 1e8a0be5ed3aaa26dd77927df32bbd0df3449a1e Gitweb: https://git.kernel.org/tip/1e8a0be5ed3aaa26dd77927df32bbd0df3449a1e Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:35 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:03 -08:00
alpha/cpu: Expose arch_cpu_idle_dead()'s prototype declaration
Include <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
--- arch/alpha/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/alpha/kernel/process.c +1 -0
@@ -9,6 +9,7 @@* This file handles the architecture-dependent parts of process handling. */ +#include <linux/cpu.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/sched.h>
Josh Poimboeuf
maintainerPATCH v2 2/24 alpha/cpu: Make sure arch_cpu_idle_dead() doesn't return
In reply to Josh Poimboeufarch_cpu_idle_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/alpha/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/alpha/kernel/process.c +1 -0
@@ -63,6 +63,7 @@ void arch_cpu_idle(void)void arch_cpu_idle_dead (void ) {wtint (INT_MAX ); +BUG (); }#endif /* ALPHA_WTINT */
Signature · 1 line
2.39.1
[tip: objtool/core] alpha/cpu: Make sure arch_cpu_idle_dead() doesn't return
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 550db6795e9bb0b1b40f9c52bbe3d0ee735dbdb0 Gitweb: https://git.kernel.org/tip/550db6795e9bb0b1b40f9c52bbe3d0ee735dbdb0 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:36 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:03 -08:00
alpha/cpu: Make sure arch_cpu_idle_dead() doesn't return
arch_cpu_idle_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/alpha/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/alpha/kernel/process.c +1 -0
@@ -63,6 +63,7 @@ void arch_cpu_idle(void)void arch_cpu_idle_dead (void ) {wtint (INT_MAX ); +BUG (); }#endif /* ALPHA_WTINT */
Josh Poimboeuf
maintainerPATCH v2 3/24 arm/cpu: Make sure arch_cpu_idle_dead() doesn't return
In reply to Josh Poimboeufarch_cpu_idle_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/arm/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/smp.c +2 -0
@@ -382,6 +382,8 @@ void arch_cpu_idle_dead(void) : "r" (task_stack_page(current) + THREAD_SIZE - 8), "r" (current) : "r0"); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
Signature · 1 line
2.39.1
Russell King (Oracle)
maintainerRe: [PATCH v2 03/24] arm/cpu: Make sure arch_cpu_idle_dead() doesn't return
Quoted 6 lines · Josh Poimboeuf
arch_cpu_idle_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
This is silly. Just mark the function __noreturn and be done with it. If the CPU ever executes code past the "b" instruction, it's already really broken that the extra instructions that BUG() gives will be meaningless.
This patch does nothing except add yet more bloat the kernel.
Sorry, but NAK.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Josh Poimboeuf
maintainerRe: [PATCH v2 03/24] arm/cpu: Make sure arch_cpu_idle_dead() doesn't return
Quoted 8 lines · Russell King (Oracle)
Quoted 6 lines · Josh Poimboeuf
arch_cpu_idle_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
Quoted 8 lines
This is silly. Just mark the function
__noreturnand be done with it. If the CPU ever executes code past the "b" instruction, it's already really broken that the extra instructions thatBUG()gives will be meaningless.This patch does nothing except add yet more bloat the kernel.
Sorry, but NAK.
Problem is, the compiler can't read inline asm. So you'd get a "'noreturn' function does return" warning.
We can do an unreachable() instead of a BUG() here if you prefer undefined behavior.
Signature · 1 line
Josh
Russell King (Oracle)
maintainerRe: [PATCH v2 03/24] arm/cpu: Make sure arch_cpu_idle_dead() doesn't return
Quoted 16 lines · Josh Poimboeuf
Quoted 15 lines · Russell King (Oracle)
Quoted 6 lines · Josh Poimboeuf
arch_cpu_idle_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.This is silly. Just mark the function
__noreturnand be done with it. If the CPU ever executes code past the "b" instruction, it's already really broken that the extra instructions thatBUG()gives will be meaningless.This patch does nothing except add yet more bloat the kernel.
Quoted 7 lines
Quoted 1 line
Sorry, but NAK.
Problem is, the compiler can't read inline asm. So you'd get a "'noreturn' function does return" warning.
We can do an
unreachable()instead of aBUG()here if you prefer undefined behavior.
That's fine.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Josh Poimboeuf
maintainerPATCH v2 3/24 arm/cpu: Add unreachable() to arch_cpu_idle_dead()
arch_cpu_idle_dead() doesn't return. Make that visible to the compiler with an unreachable() code annotation.
--- arch/arm/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/smp.c +2 -0
@@ -382,6 +382,8 @@ void arch_cpu_idle_dead(void) : "r" (task_stack_page(current) + THREAD_SIZE - 8), "r" (current) : "r0"); + + unreachable(); }#endif /* CONFIG_HOTPLUG_CPU */
Signature · 1 line
2.39.1
[tip: objtool/core] arm/cpu: Add unreachable() to arch_cpu_idle_dead()
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: b40c7d6d31ac2f6b78371cdc08bc1b6b62f01375 Gitweb: https://git.kernel.org/tip/b40c7d6d31ac2f6b78371cdc08bc1b6b62f01375 Author: Josh Poimboeuf <[email protected]> AuthorDate: Thu, 16 Feb 2023 10:38:55 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:04 -08:00
arm/cpu: Add unreachable() to arch_cpu_idle_dead()
arch_cpu_idle_dead() doesn't return. Make that visible to the compiler with an unreachable() code annotation.
--- arch/arm/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/kernel/smp.c +2 -0
@@ -382,6 +382,8 @@ void arch_cpu_idle_dead(void) : "r" (task_stack_page(current) + THREAD_SIZE - 8), "r" (current) : "r0"); + + unreachable(); }#endif /* CONFIG_HOTPLUG_CPU */
Josh Poimboeuf
maintainerPATCH v2 4/24 arm64/cpu: Mark cpu_die() __noreturn
In reply to Josh Poimboeufcpu_die() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/arm64/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/smp.h +1 -1
@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );static inline void cpu_park_loop (void )
Signature · 1 line
2.39.1
Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn
Quoted 13 lines · Josh Poimboeuf
cpu_die()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/arm64/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/smp.h +0
-0
arch/arm64/include/asm/smp.h static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) · line 104
Quoted 6 lines
arch/arm64/include/asm/smp.h +1
-1@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );
Shouldn't cpu_operations::cpu_die() be declared noreturn first?
Re: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Josh Poimboeuf
cpu_die()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/arm64/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
arch/arm64/include/asm/smp.h static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) · line 103
Quoted 10 lines
arch/arm64/include/asm/smp.h +1
-1@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );Shouldn't
cpu_operations::cpu_die()be declared noreturn first?
The cpu_die() function ends with a BUG(), and so does not return, even if a cpu_operations::cpu_die() function that it calls erroneously returned.
We *could* mark cpu_operations::cpu_die() as noreturn, but I'd prefer that we did not so that the compiler doesn't optimize away the BUG() which is there to catch such erroneous returns.
That said, could we please add __noreturn to the implementation of cpu_die() in arch/arm64/kernel/smp.c? i.e. the fixup below.
With that fixup:
Mark.
---->8----
arch/arm64/kernel/smp.c +1 -1
@@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu)* Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die (void ) +void __noreturn cpu_die (void ) {unsigned int cpu =smp_processor_id ();const struct cpu_operations *ops =get_cpu_ops (cpu);
Josh Poimboeuf
maintainerRe: [PATCH v2 04/24] arm64/cpu: Mark cpu_die() __noreturn
Quoted 26 lines · Mark Rutland
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Josh Poimboeuf
cpu_die()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/arm64/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 12 lines
arch/arm64/include/asm/smp.h static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) · line 103
Quoted 10 lines
arch/arm64/include/asm/smp.h +1
-1@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );Shouldn't
cpu_operations::cpu_die()be declared noreturn first?The
cpu_die()function ends with aBUG(), and so does not return, even if acpu_operations::cpu_die()function that it calls erroneously returned.
Quoted 6 lines
We *could* mark
cpu_operations::cpu_die()as noreturn, but I'd prefer that we did not so that the compiler doesn't optimize away theBUG()which is there to catch such erroneous returns.That said, could we please add
__noreturnto the implementation ofcpu_die()inarch/arm64/kernel/smp.c? i.e. the fixup below.
Done.
Quoted 3 lines
With that fixup:
Acked-by Mark Rutland <[email protected]>
Thanks!
Signature · 1 line
Josh
Josh Poimboeuf
maintainerPATCH v2 4/24 arm64/cpu: Mark cpu_die() __noreturn
cpu_die() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/smp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/smp.h +1 -1
@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );static inline void cpu_park_loop (void )
arch/arm64/kernel/smp.c +1 -1
@@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu)* Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die (void ) +void __noreturn cpu_die (void ) {unsigned int cpu =smp_processor_id ();const struct cpu_operations *ops =get_cpu_ops (cpu);
Signature · 1 line
2.39.1
Re: [PATCH v2.1 04/24] arm64/cpu: Mark cpu_die() __noreturn
Quoted 9 lines · Josh Poimboeuf
cpu_die()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Acked-by Mark Rutland <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/smp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[tip: objtool/core] arm64/cpu: Mark cpu_die() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 9bdc61ef27db5eaac48f1cc5deb8224603e79c89 Gitweb: https://git.kernel.org/tip/9bdc61ef27db5eaac48f1cc5deb8224603e79c89 Author: Josh Poimboeuf <[email protected]> AuthorDate: Thu, 16 Feb 2023 10:42:01 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:04 -08:00
arm64/cpu: Mark cpu_die() __noreturn
cpu_die() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/smp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/smp.h +1 -1
@@ -100,7 +100,7 @@ static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu); -extern void cpu_die (void ); +extern void __noreturn cpu_die (void );extern void cpu_die_early (void );static inline void cpu_park_loop (void )
arch/arm64/kernel/smp.c +1 -1
@@ -361,7 +361,7 @@ void __cpu_die(unsigned int cpu)* Called from the idle thread for the CPU which has been shutdown. * */ -void cpu_die (void ) +void __noreturn cpu_die (void ) {unsigned int cpu =smp_processor_id ();const struct cpu_operations *ops =get_cpu_ops (cpu);
Josh Poimboeuf
maintainerPATCH v2 5/24 csky/cpu: Make sure arch_cpu_idle_dead() doesn't return
In reply to Josh Poimboeufarch_cpu_idle_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/csky/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/csky/kernel/smp.c +2 -0
@@ -317,5 +317,7 @@ void arch_cpu_idle_dead(void) "jmpi csky_start_secondary" : : "r" (secondary_stack)); + + BUG(); }#endif
Signature · 1 line
2.39.1
[tip: objtool/core] csky/cpu: Make sure arch_cpu_idle_dead() doesn't return
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 1b2442a835a0acc7d76ae2f48ca7a94f962b29c8 Gitweb: https://git.kernel.org/tip/1b2442a835a0acc7d76ae2f48ca7a94f962b29c8 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:39 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:05 -08:00
csky/cpu: Make sure arch_cpu_idle_dead() doesn't return
arch_cpu_idle_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/csky/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/csky/kernel/smp.c +2 -0
@@ -317,5 +317,7 @@ void arch_cpu_idle_dead(void) "jmpi csky_start_secondary" : : "r" (secondary_stack)); + + BUG(); }#endif
Josh Poimboeuf
maintainerPATCH v2 6/24 ia64/cpu: Mark play_dead() __noreturn
In reply to Josh Poimboeufplay_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/ia64/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/ia64/kernel/process.c +2 -2
@@ -201,7 +201,7 @@ __setup("nohalt", nohalt_setup);#ifdef CONFIG_HOTPLUG_CPU /* We don't actually take CPU down, just spin without interrupts. */ -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {unsigned int this_cpu =smp_processor_id ();
@@ -219,7 +219,7 @@ static inline void play_dead(void) BUG(); }#else -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Signature · 1 line
2.39.1
Re: [PATCH v2 06/24] ia64/cpu: Mark play_dead() __noreturn
Quoted 7 lines · Josh Poimboeuf
play_dead()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/ia64/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
[tip: objtool/core] ia64/cpu: Mark play_dead() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 93c0edffbc92abe1efb8c7081df0cc1577a79ace Gitweb: https://git.kernel.org/tip/93c0edffbc92abe1efb8c7081df0cc1577a79ace Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:40 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:05 -08:00
ia64/cpu: Mark play_dead() __noreturn
play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/ia64/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/ia64/kernel/process.c +2 -2
@@ -201,7 +201,7 @@ __setup("nohalt", nohalt_setup);#ifdef CONFIG_HOTPLUG_CPU /* We don't actually take CPU down, just spin without interrupts. */ -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {unsigned int this_cpu =smp_processor_id ();
@@ -219,7 +219,7 @@ static inline void play_dead(void) BUG(); }#else -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Josh Poimboeuf
maintainerPATCH v2 7/24 loongarch/cpu: Make sure play_dead() doesn't return
In reply to Josh Poimboeufplay_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/loongarch/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/smp.c +1 -1
@@ -336,7 +336,7 @@ void play_dead(void)iocsr_write32 (0xffffffff ,LOONGARCH_IOCSR_IPI_CLEAR );init_fn (); - unreachable(); + BUG(); }#endif
Signature · 1 line
2.39.1
[tip: objtool/core] loongarch/cpu: Make sure play_dead() doesn't return
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 13bf7923a4dd34f3d2681768a148b10ddbdb95ed Gitweb: https://git.kernel.org/tip/13bf7923a4dd34f3d2681768a148b10ddbdb95ed Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:41 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:06 -08:00
loongarch/cpu: Make sure play_dead() doesn't return
play_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/loongarch/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/smp.c +1 -1
@@ -336,7 +336,7 @@ void play_dead(void)iocsr_write32 (0xffffffff ,LOONGARCH_IOCSR_IPI_CLEAR );init_fn (); - unreachable(); + BUG(); }#endif
Josh Poimboeuf
maintainerPATCH v2 8/24 loongarch/cpu: Mark play_dead() __noreturn
In reply to Josh Poimboeufplay_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/loongarch/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/include/asm/smp.h +1 -1
@@ -99,7 +99,7 @@ static inline void __cpu_die(unsigned int cpu)loongson_cpu_die (cpu); } -extern void play_dead (void ); +extern void __noreturn play_dead (void );#endif #endif /* __ASM_SMP_H */
Signature · 1 line
2.39.1
Re: [PATCH v2 08/24] loongarch/cpu: Mark play_dead() __noreturn
Quoted 7 lines · Josh Poimboeuf
play_dead()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/loongarch/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[tip: objtool/core] loongarch/cpu: Mark play_dead() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 6c0f2d071eded22cb72413e0abfaa5b3373b4d96 Gitweb: https://git.kernel.org/tip/6c0f2d071eded22cb72413e0abfaa5b3373b4d96 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:42 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 06 Mar 2023 15:34:06 -08:00
loongarch/cpu: Mark play_dead() __noreturn
play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/loongarch/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/include/asm/smp.h +1 -1
@@ -99,7 +99,7 @@ static inline void __cpu_die(unsigned int cpu)loongson_cpu_die (cpu); } -extern void play_dead (void ); +extern void __noreturn play_dead (void );#endif #endif /* __ASM_SMP_H */
Josh Poimboeuf
maintainerPATCH v2 9/24 mips/cpu: Expose play_dead()'s prototype definition
In reply to Josh PoimboeufInclude <asm/smp.h> to make sure play_dead() matches its prototype going forward.
--- arch/mips/kernel/smp-bmips.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/kernel/smp-bmips.c +1 -0
@@ -38,6 +38,7 @@#include <asm/traps.h> #include <asm/barrier.h> #include <asm/cpu-features.h> +#include <asm/smp.h> static int __maybe_unused max_cpus =1 ;
Signature · 1 line
2.39.1
Re: [PATCH v2 09/24] mips/cpu: Expose play_dead()'s prototype definition
Hi Josh,
Quoted 14 lines · Josh Poimboeuf
Include <
asm/smp.h> to make sureplay_dead()matches its prototype going forward.Acked-by Florian Fainelli <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/kernel/smp-bmips.c | 1 + 1 file changed, 1 insertion(+)arch/mips/kernel/smp-bmips.c +0
-0
arch/mips/kernel/smp-bmips.c line 41
Quoted 4 lines
arch/mips/kernel/smp-bmips.c +1
-0@@ -38,6 +38,7 @@#include <asm/traps.h> #include <asm/barrier.h> #include <asm/cpu-features.h> +#include <asm/smp.h>
What about the other implementations?
$ git grep -L asm/smp.h $(git grep -wlF 'play_dead(void)' arch/mips) arch/mips/cavium-octeon/smp.c arch/mips/kernel/smp-bmips.c arch/mips/kernel/smp-cps.c arch/mips/loongson64/smp.c
Josh Poimboeuf
maintainerRe: [PATCH v2 09/24] mips/cpu: Expose play_dead()'s prototype definition
Quoted 24 lines · Philippe Mathieu-Daudé
Hi Josh,
Quoted 14 lines · Josh Poimboeuf
Include <
asm/smp.h> to make sureplay_dead()matches its prototype going forward.Acked-by Florian Fainelli <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/kernel/smp-bmips.c | 1 + 1 file changed, 1 insertion(+)arch/mips/kernel/smp-bmips.c +0
-0arch/mips/kernel/smp-bmips.c line 41
Quoted 4 lines
arch/mips/kernel/smp-bmips.c +1
-0@@ -38,6 +38,7 @@#include <asm/traps.h> #include <asm/barrier.h> #include <asm/cpu-features.h> +#include <asm/smp.h> What about the other implementations?
Quoted 5 lines
$ git grep -L asm/smp.h $(git grep -wlF 'play_dead(void)' arch/mips) arch/mips/cavium-octeon/smp.c arch/mips/kernel/smp-bmips.c arch/mips/kernel/smp-cps.c arch/mips/loongson64/smp.c
Indeed. I really wish we had -Wmissing-prototypes.
I'll squash this in:
arch/mips/cavium-octeon/smp.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mmu_context.h> #include <asm/time.h> #include <asm/setup.h> +#include <asm/smp.h> #include <asm/octeon/octeon.h>
arch/mips/kernel/smp-cps.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mipsregs.h> #include <asm/pm-cps.h> #include <asm/r4kcache.h> +#include <asm/smp.h> #include <asm/smp-cps.h> #include <asm/time.h> #include <asm/uasm.h>
arch/mips/loongson64/smp.c +1 -0
@@ -14,6 +14,7 @@#include <linux/cpufreq.h> #include <linux/kexec.h> #include <asm/processor.h> +#include <asm/smp.h> #include <asm/time.h> #include <asm/tlbflush.h> #include <asm/cacheflush.h>
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH v2 09/24] mips/cpu: Expose play_dead()'s prototype definition
Quoted 64 lines · Josh Poimboeuf
Quoted 24 lines · Philippe Mathieu-Daudé
Hi Josh,
Quoted 14 lines · Josh Poimboeuf
Include <
asm/smp.h> to make sureplay_dead()matches its prototype going forward.Acked-by Florian Fainelli <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/kernel/smp-bmips.c | 1 + 1 file changed, 1 insertion(+)arch/mips/kernel/smp-bmips.c +0
-0arch/mips/kernel/smp-bmips.c line 41
Quoted 4 lines
arch/mips/kernel/smp-bmips.c +1
-0@@ -38,6 +38,7 @@#include <asm/traps.h> #include <asm/barrier.h> #include <asm/cpu-features.h> +#include <asm/smp.h> What about the other implementations?
Quoted 5 lines
$ git grep -L asm/smp.h $(git grep -wlF 'play_dead(void)' arch/mips) arch/mips/cavium-octeon/smp.c arch/mips/kernel/smp-bmips.c arch/mips/kernel/smp-cps.c arch/mips/loongson64/smp.cIndeed. I really wish we had -Wmissing-prototypes.
I'll squash this in:
arch/mips/cavium-octeon/smp.c +1
-0@@ -20,6 +20,7 @@#include <asm/mmu_context.h> #include <asm/time.h> #include <asm/setup.h> +#include <asm/smp.h> #include <asm/octeon/octeon.h> arch/mips/kernel/smp-cps.c +1
-0@@ -20,6 +20,7 @@#include <asm/mipsregs.h> #include <asm/pm-cps.h> #include <asm/r4kcache.h> +#include <asm/smp.h> #include <asm/smp-cps.h> #include <asm/time.h> #include <asm/uasm.h> arch/mips/loongson64/smp.c +0
-0
arch/mips/loongson64/smp.c line 20
Quoted 7 lines
arch/mips/loongson64/smp.c +1
-0@@ -14,6 +14,7 @@#include <linux/cpufreq.h> #include <linux/kexec.h> #include <asm/processor.h> +#include <asm/smp.h> #include <asm/time.h> #include <asm/tlbflush.h> #include <asm/cacheflush.h>
Thanks.
Josh Poimboeuf
maintainerPATCH v2 9/24 mips/cpu: Expose play_dead()'s prototype definition
Include <asm/smp.h> to make sure play_dead() matches its prototype going forward.
--- arch/mips/cavium-octeon/smp.c | 1 + arch/mips/kernel/smp-bmips.c | 1 + arch/mips/kernel/smp-cps.c | 1 + arch/mips/loongson64/smp.c | 1 + 4 files changed, 4 insertions(+)
arch/mips/cavium-octeon/smp.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mmu_context.h> #include <asm/time.h> #include <asm/setup.h> +#include <asm/smp.h> #include <asm/octeon/octeon.h>
arch/mips/kernel/smp-bmips.c +1 -0
@@ -38,6 +38,7 @@#include <asm/traps.h> #include <asm/barrier.h> #include <asm/cpu-features.h> +#include <asm/smp.h> static int __maybe_unused max_cpus =1 ;
arch/mips/kernel/smp-cps.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mipsregs.h> #include <asm/pm-cps.h> #include <asm/r4kcache.h> +#include <asm/smp.h> #include <asm/smp-cps.h> #include <asm/time.h> #include <asm/uasm.h>
arch/mips/loongson64/smp.c +1 -0
@@ -14,6 +14,7 @@#include <linux/cpufreq.h> #include <linux/kexec.h> #include <asm/processor.h> +#include <asm/smp.h> #include <asm/time.h> #include <asm/tlbflush.h> #include <asm/cacheflush.h>
Signature · 1 line
2.39.1
Josh Poimboeuf
maintainerRe: [PATCH v2.1 09/24] mips/cpu: Expose play_dead()'s prototype definition
Quoted 6 lines · Josh Poimboeuf
Include <
asm/smp.h> to make sureplay_dead()matches its prototype going forward.Acked-by Florian Fainelli <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>
The latest version of this patch triggered a new kbuild warning which is fixed by the below patch. If there are no objections I'll bundle it in with the rest of the set for merging.
---8<---
Subject: [PATCH] mips/smp: Add CONFIG_SMP guard for raw_smp_processor_id()
Content-type: text/plain
Without CONFIG_SMP, raw_smp_processor_id() is not expected to be defined by the arch.
--- arch/mips/include/asm/smp.h | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/include/asm/smp.h +2 -0
@@ -25,6 +25,7 @@ extern cpumask_t cpu_sibling_map[];extern cpumask_t cpu_core_map[];extern cpumask_t cpu_foreign_map[]; +#ifdef CONFIG_SMP static inline int raw_smp_processor_id (void ) {#if defined(__VDSO__)
@@ -36,6 +37,7 @@ static inline int raw_smp_processor_id(void) #endif }#define raw_smp_processor_id raw_smp_processor_id +#endif /* Map from cpu id to sequential logical cpu number. This will only not be idempotent when cpus failed to come on-line. */
Signature · 1 line
2.39.1
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH v2.1 09/24] mips/cpu: Expose play_dead()'s prototype definition
Quoted 32 lines · Josh Poimboeuf
The latest version of this patch triggered a new kbuild warning which is fixed by the below patch. If there are no objections I'll bundle it in with the rest of the set for merging.
---8<---
Subject: [PATCH] mips/smp: Add
CONFIG_SMPguard forraw_smp_processor_id()
Content-type: text/plainWithout
CONFIG_SMP,raw_smp_processor_id()is not expected to be defined by the arch.Reported-by kernel test robot <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/include/asm/smp.h | 2 ++ 1 file changed, 2 insertions(+)arch/mips/include/asm/smp.h +1
-0@@ -25,6 +25,7 @@ extern cpumask_t cpu_sibling_map[];extern cpumask_t cpu_core_map[];extern cpumask_t cpu_foreign_map[]; +#ifdef CONFIG_SMP static inline int raw_smp_processor_id (void ) {#if defined(__VDSO__)
arch/mips/include/asm/smp.h static inline int raw_smp_processor_id(void) · line 43
Quoted 7 lines
arch/mips/include/asm/smp.h +1
-0@@ -36,6 +37,7 @@ static inline int raw_smp_processor_id(void) #endif }#define raw_smp_processor_id raw_smp_processor_id +#endif /* Map from cpu id to sequential logical cpu number. This will only not be idempotent when cpus failed to come on-line. */
[tip: objtool/core] mips/cpu: Expose play_dead()'s prototype definition
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 142dbcf3b6a93ecfe8ccbee60c611175f5459c23 Gitweb: https://git.kernel.org/tip/142dbcf3b6a93ecfe8ccbee60c611175f5459c23 Author: Josh Poimboeuf <[email protected]> AuthorDate: Thu, 16 Feb 2023 10:42:52 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:19 -08:00
mips/cpu: Expose play_dead()'s prototype definition
Include <asm/smp.h> to make sure play_dead() matches its prototype going forward.
--- arch/mips/cavium-octeon/smp.c | 1 + arch/mips/kernel/smp-bmips.c | 2 ++ arch/mips/kernel/smp-cps.c | 1 + arch/mips/loongson64/smp.c | 1 + 4 files changed, 5 insertions(+)
arch/mips/cavium-octeon/smp.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mmu_context.h> #include <asm/time.h> #include <asm/setup.h> +#include <asm/smp.h> #include <asm/octeon/octeon.h>
arch/mips/kernel/smp-bmips.c +2 -0
@@ -54,6 +54,8 @@ static void bmips_set_reset_vec(int cpu, u32 val);#ifdef CONFIG_SMP +#include <asm/smp.h> +/* initial $sp, $gp - used by arch/mips/kernel/bmips_vec.S */ unsigned long bmips_smp_boot_sp;unsigned long bmips_smp_boot_gp;
arch/mips/kernel/smp-cps.c +1 -0
@@ -20,6 +20,7 @@#include <asm/mipsregs.h> #include <asm/pm-cps.h> #include <asm/r4kcache.h> +#include <asm/smp.h> #include <asm/smp-cps.h> #include <asm/time.h> #include <asm/uasm.h>
arch/mips/loongson64/smp.c +1 -0
@@ -14,6 +14,7 @@#include <linux/cpufreq.h> #include <linux/kexec.h> #include <asm/processor.h> +#include <asm/smp.h> #include <asm/time.h> #include <asm/tlbflush.h> #include <asm/cacheflush.h>
Josh Poimboeuf
maintainerPATCH v2 10/24 mips/cpu: Make sure play_dead() doesn't return
In reply to Josh Poimboeufplay_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/mips/kernel/smp-bmips.c | 2 ++ arch/mips/loongson64/smp.c | 1 + 2 files changed, 3 insertions(+)
arch/mips/kernel/smp-bmips.c +2 -0
@@ -414,6 +414,8 @@ void __ref play_dead(void) " wait\n" " j bmips_secondary_reentry\n" : : : "memory"); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
arch/mips/loongson64/smp.c +1 -0
@@ -822,6 +822,7 @@ void play_dead(void) state_addr = &per_cpu (cpu_state, cpu);mb ();play_dead_at_ckseg1 (state_addr); +BUG (); }static int loongson3_disable_clock (unsigned int cpu)
Signature · 1 line
2.39.1
Re: [PATCH v2 10/24] mips/cpu: Make sure play_dead() doesn't return
Quoted 6 lines · Josh Poimboeuf
play_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
Quoted 6 lines
Acked-by Florian Fainelli <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/kernel/smp-bmips.c | 2 ++ arch/mips/loongson64/smp.c | 1 + 2 files changed, 3 insertions(+)
[tip: objtool/core] mips/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: a80ceed6c9c24088d7a2e3c414eae1fe88a8ccbe Gitweb: https://git.kernel.org/tip/a80ceed6c9c24088d7a2e3c414eae1fe88a8ccbe Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:44 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:23 -08:00
mips/cpu: Make sure play_dead() doesn't return
play_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/mips/kernel/smp-bmips.c | 2 ++ arch/mips/loongson64/smp.c | 1 + 2 files changed, 3 insertions(+)
arch/mips/kernel/smp-bmips.c +2 -0
@@ -415,6 +415,8 @@ void __ref play_dead(void) " wait\n" " j bmips_secondary_reentry\n" : : : "memory"); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
arch/mips/loongson64/smp.c +1 -0
@@ -823,6 +823,7 @@ out: state_addr = &per_cpu (cpu_state, cpu);mb ();play_dead_at_ckseg1 (state_addr); +BUG (); }static int loongson3_disable_clock (unsigned int cpu)
Josh Poimboeuf
maintainerPATCH v2 11/24 mips/cpu: Mark play_dead() __noreturn
In reply to Josh Poimboeufplay_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/mips/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/smp.h +1 -1
@@ -88,7 +88,7 @@ static inline void __cpu_die(unsigned int cpu) mp_ops->cpu_die(cpu); } -extern void play_dead (void ); +extern void __noreturn play_dead (void );#endif #ifdef CONFIG_KEXEC
Signature · 1 line
2.39.1
Re: [PATCH v2 11/24] mips/cpu: Mark play_dead() __noreturn
Quoted 8 lines · Josh Poimboeuf
play_dead()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Acked-by Florian Fainelli <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>--- arch/mips/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[tip: objtool/core] mips/cpu: Mark play_dead() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 9e57f049d1571db1dc77c69c87403defc9d3e5ae Gitweb: https://git.kernel.org/tip/9e57f049d1571db1dc77c69c87403defc9d3e5ae Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:45 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:23 -08:00
mips/cpu: Mark play_dead() __noreturn
play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/mips/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/include/asm/smp.h +1 -1
@@ -88,7 +88,7 @@ static inline void __cpu_die(unsigned int cpu) mp_ops->cpu_die(cpu); } -extern void play_dead (void ); +extern void __noreturn play_dead (void );#endif #ifdef CONFIG_KEXEC
Josh Poimboeuf
maintainerPATCH v2 12/24 powerpc/cpu: Mark start_secondary_resume() __noreturn
In reply to Josh Poimboeufstart_secondary_resume() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/powerpc/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/smp.h +1 -1
@@ -66,7 +66,7 @@ void start_secondary(void *unused);extern int smp_send_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern int smp_send_safe_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern void smp_send_debugger_break (void ); -extern void start_secondary_resume (void ); +extern void __noreturn start_secondary_resume (void );extern void smp_generic_give_timebase (void );extern void smp_generic_take_timebase (void );
Signature · 1 line
2.39.1
Re: [PATCH v2 12/24] powerpc/cpu: Mark start_secondary_resume() __noreturn
Le 14/02/2023 à 08:05, Josh Poimboeuf a écrit :
Quoted 5 lines
start_secondary_resume()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>
Quoted 9 lines
--- arch/powerpc/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/include/asm/smp.h +0
-0
arch/powerpc/include/asm/smp.h void start_secondary(void *unused); · line 69
Quoted 5 lines
arch/powerpc/include/asm/smp.h +1
-1@@ -66,7 +66,7 @@ void start_secondary(void *unused);extern int smp_send_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern int smp_send_safe_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern void smp_send_debugger_break (void ); -extern void start_secondary_resume (void ); +extern void __noreturn start_secondary_resume (void );
Would have been a good opportunity to drop the pointless 'extern' keyword.
Checkpatch reports:
CHECK: extern prototypes should be avoided in .h files #19: FILE: arch/powerpc/include/asm/smp.h:69:
+extern void __noreturn start_secondary_resume(void);
Quoted 3 lines
arch/powerpc/include/asm/smp.h +0
-0extern void smp_generic_give_timebase (void );extern void smp_generic_take_timebase (void );
[tip: objtool/core] powerpc/cpu: Mark start_secondary_resume() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 5e00d69cdef4cd1c737e6286a39f83ce20a91034 Gitweb: https://git.kernel.org/tip/5e00d69cdef4cd1c737e6286a39f83ce20a91034 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:46 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:24 -08:00
powerpc/cpu: Mark start_secondary_resume() __noreturn
start_secondary_resume() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/powerpc/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/include/asm/smp.h +1 -1
@@ -67,7 +67,7 @@ void start_secondary(void *unused);extern int smp_send_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern int smp_send_safe_nmi_ipi (int cpu,void (*fn)(struct pt_regs *),u64 delay_us);extern void smp_send_debugger_break (void ); -extern void start_secondary_resume (void ); +extern void __noreturn start_secondary_resume (void );extern void smp_generic_give_timebase (void );extern void smp_generic_take_timebase (void );
Josh Poimboeuf
maintainerPATCH v2 13/24 sh/cpu: Make sure play_dead() doesn't return
In reply to Josh Poimboeufplay_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/sh/include/asm/smp-ops.h | 1 + 1 file changed, 1 insertion(+)
arch/sh/include/asm/smp-ops.h +1 -0
@@ -27,6 +27,7 @@ static inline void plat_smp_setup(void)static inline void play_dead (void ) { mp_ops->play_dead (); +BUG (); }extern void register_smp_ops (struct plat_smp_ops *ops);
Signature · 1 line
2.39.1
Re: [PATCH v2 13/24] sh/cpu: Make sure play_dead() doesn't return
Quoted 16 lines · Josh Poimboeuf
play_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/sh/include/asm/smp-ops.h | 1 + 1 file changed, 1 insertion(+)arch/sh/include/asm/smp-ops.h +0
-0
arch/sh/include/asm/smp-ops.h static inline void plat_smp_setup(void) · line 31
Quoted 5 lines
arch/sh/include/asm/smp-ops.h +1
-0@@ -27,6 +27,7 @@ static inline void plat_smp_setup(void)static inline void play_dead (void ) { mp_ops->play_dead (); +BUG (); }
Shouldn't we decorate plat_smp_ops::play_dead() as noreturn first?
Josh Poimboeuf
maintainerRe: [PATCH v2 13/24] sh/cpu: Make sure play_dead() doesn't return
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 11 lines · Josh Poimboeuf
play_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/sh/include/asm/smp-ops.h | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
arch/sh/include/asm/smp-ops.h static inline void plat_smp_setup(void) · line 31
Quoted 10 lines
arch/sh/include/asm/smp-ops.h +1
-0@@ -27,6 +27,7 @@ static inline void plat_smp_setup(void)static inline void play_dead (void ) { mp_ops->play_dead (); +BUG (); }Shouldn't we decorate
plat_smp_ops::play_dead()as noreturn first?
I guess it really depends on how far we want to go down the __noreturn rabbit hole. To keep the patch set constrained yet still useful I stopped when I got to a function pointer, as I think it still needs a BUG() afterwards either way.
That said, there would still be benefits of adding __noreturn to function pointers, I just wanted to keep the patch set down to a manageable size ;-)
Signature · 1 line
Josh
Re: [PATCH v2 13/24] sh/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufQuoted 16 lines · Josh Poimboeuf
play_dead()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/sh/include/asm/smp-ops.h | 1 + 1 file changed, 1 insertion(+)arch/sh/include/asm/smp-ops.h +0
-0
arch/sh/include/asm/smp-ops.h static inline void plat_smp_setup(void) · line 31
Quoted 5 lines
arch/sh/include/asm/smp-ops.h +1
-0@@ -27,6 +27,7 @@ static inline void plat_smp_setup(void)static inline void play_dead (void ) { mp_ops->play_dead (); +BUG (); }
Shouldn't we decorate plat_smp_ops::play_dead() as noreturn first?
[tip: objtool/core] sh/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 243971885418fcf772f18019eb3fabadcf0205d1 Gitweb: https://git.kernel.org/tip/243971885418fcf772f18019eb3fabadcf0205d1 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:47 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:24 -08:00
sh/cpu: Make sure play_dead() doesn't return
play_dead() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/sh/include/asm/smp-ops.h | 1 + 1 file changed, 1 insertion(+)
arch/sh/include/asm/smp-ops.h +1 -0
@@ -27,6 +27,7 @@ static inline void plat_smp_setup(void)static inline void play_dead (void ) { mp_ops->play_dead (); +BUG (); }extern void register_smp_ops (struct plat_smp_ops *ops);
Josh Poimboeuf
maintainerPATCH v2 14/24 sh/cpu: Mark play_dead() __noreturn
In reply to Josh Poimboeufplay_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/sh/include/asm/smp-ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/include/asm/smp-ops.h +2 -2
@@ -24,7 +24,7 @@ static inline void plat_smp_setup(void) mp_ops->smp_setup (); } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) { mp_ops->play_dead ();BUG ();
@@ -43,7 +43,7 @@ static inline void register_smp_ops(struct plat_smp_ops *ops) { } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Signature · 1 line
2.39.1
[tip: objtool/core] sh/cpu: Mark play_dead() __noreturn
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 1644b74192265875cdf37dadfa33f34e0ea4fcc8 Gitweb: https://git.kernel.org/tip/1644b74192265875cdf37dadfa33f34e0ea4fcc8 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:48 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:24 -08:00
sh/cpu: Mark play_dead() __noreturn
play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/sh/include/asm/smp-ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/include/asm/smp-ops.h +2 -2
@@ -24,7 +24,7 @@ static inline void plat_smp_setup(void) mp_ops->smp_setup (); } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) { mp_ops->play_dead ();BUG ();
@@ -43,7 +43,7 @@ static inline void register_smp_ops(struct plat_smp_ops *ops) { } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Josh Poimboeuf
maintainerPATCH v2 15/24 sh/cpu: Expose arch_cpu_idle_dead()'s prototype definition
In reply to Josh PoimboeufInclude <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
--- arch/sh/kernel/idle.c | 1 + 1 file changed, 1 insertion(+)
arch/sh/kernel/idle.c +1 -0
@@ -4,6 +4,7 @@* * Copyright (C) 2002 - 2009 Paul Mundt */ +#include <linux/cpu.h> #include <linux/module.h> #include <linux/init.h> #include <linux/mm.h>
Signature · 1 line
2.39.1
[tip: objtool/core] sh/cpu: Expose arch_cpu_idle_dead()'s prototype definition
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: fd49efb3c75475b65d7541ee40603498807ff110 Gitweb: https://git.kernel.org/tip/fd49efb3c75475b65d7541ee40603498807ff110 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:49 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:25 -08:00
sh/cpu: Expose arch_cpu_idle_dead()'s prototype definition
Include <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
--- arch/sh/kernel/idle.c | 1 + 1 file changed, 1 insertion(+)
arch/sh/kernel/idle.c +1 -0
@@ -4,6 +4,7 @@* * Copyright (C) 2002 - 2009 Paul Mundt */ +#include <linux/cpu.h> #include <linux/module.h> #include <linux/init.h> #include <linux/mm.h>
Josh Poimboeuf
maintainerPATCH v2 16/24 sparc/cpu: Mark cpu_play_dead() __noreturn
In reply to Josh Poimboeufcpu_play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/sparc/include/asm/smp_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/include/asm/smp_64.h +1 -1
@@ -49,7 +49,7 @@ int hard_smp_processor_id(void);void smp_fill_in_cpu_possible_map (void );void smp_fill_in_sib_core_maps (void ); -void cpu_play_dead (void ); +void __noreturn cpu_play_dead (void );void smp_fetch_global_regs (void );void smp_fetch_global_pmu (void );
Signature · 1 line
2.39.1
Re: [PATCH v2 16/24] sparc/cpu: Mark cpu_play_dead() __noreturn
Quoted 7 lines · Josh Poimboeuf
cpu_play_dead()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/sparc/include/asm/smp_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[tip: objtool/core] sparc/cpu: Mark cpu_play_dead() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: b9952d5009440b01dedd793a57abbe6cfe10f995 Gitweb: https://git.kernel.org/tip/b9952d5009440b01dedd793a57abbe6cfe10f995 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:50 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:25 -08:00
sparc/cpu: Mark cpu_play_dead() __noreturn
cpu_play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/sparc/include/asm/smp_64.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/include/asm/smp_64.h +1 -1
@@ -49,7 +49,7 @@ int hard_smp_processor_id(void);void smp_fill_in_cpu_possible_map (void );void smp_fill_in_sib_core_maps (void ); -void cpu_play_dead (void ); +void __noreturn cpu_play_dead (void );void smp_fetch_global_regs (void );void smp_fetch_global_pmu (void );
Josh Poimboeuf
maintainerPATCH v2 17/24 x86/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufAfter commit 076cbf5d2163 ("x86/xen: don't let xen_pv_play_dead() return"), play_dead() never returns. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/x86/include/asm/smp.h | 1 + 1 file changed, 1 insertion(+)
arch/x86/include/asm/smp.h +1 -0
@@ -96,6 +96,7 @@ static inline void __cpu_die(unsigned int cpu)static inline void play_dead (void ) { smp_ops.play_dead (); +BUG (); }static inline void smp_send_reschedule (int cpu)
Signature · 1 line
2.39.1
Re: [PATCH v2 17/24] x86/cpu: Make sure play_dead() doesn't return
Quoted 18 lines · Josh Poimboeuf
After commit
076cbf5d2163("x86/xen: don't letxen_pv_play_dead()return"),play_dead()never returns. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/x86/include/asm/smp.h | 1 + 1 file changed, 1 insertion(+)arch/x86/include/asm/smp.h +0
-0
arch/x86/include/asm/smp.h static inline void __cpu_die(unsigned int cpu) · line 100
Quoted 5 lines
arch/x86/include/asm/smp.h +1
-0@@ -96,6 +96,7 @@ static inline void __cpu_die(unsigned int cpu)static inline void play_dead (void ) { smp_ops.play_dead (); +BUG (); }
Similarly, smp_ops::play_dead() should be decorated noreturn first.
Re: [PATCH v2 17/24] x86/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufQuoted 18 lines · Josh Poimboeuf
After commit
076cbf5d2163("x86/xen: don't letxen_pv_play_dead()return"),play_dead()never returns. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/x86/include/asm/smp.h | 1 + 1 file changed, 1 insertion(+)arch/x86/include/asm/smp.h +0
-0
arch/x86/include/asm/smp.h static inline void __cpu_die(unsigned int cpu) · line 100
Quoted 5 lines
arch/x86/include/asm/smp.h +1
-0@@ -96,6 +96,7 @@ static inline void __cpu_die(unsigned int cpu)static inline void play_dead (void ) { smp_ops.play_dead (); +BUG (); }
Similarly, smp_ops::play_dead() should be decorated noreturn first.
[tip: objtool/core] x86/cpu: Make sure play_dead() doesn't return
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: a02f50b573b3c90a3633a5ab67435fe4c0de144d Gitweb: https://git.kernel.org/tip/a02f50b573b3c90a3633a5ab67435fe4c0de144d Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:51 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:26 -08:00
x86/cpu: Make sure play_dead() doesn't return
After commit 076cbf5d2163 ("x86/xen: don't let xen_pv_play_dead() return"), play_dead() never returns. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/x86/include/asm/smp.h | 1 + 1 file changed, 1 insertion(+)
arch/x86/include/asm/smp.h +1 -0
@@ -96,6 +96,7 @@ static inline void __cpu_die(unsigned int cpu)static inline void play_dead (void ) { smp_ops.play_dead (); +BUG (); }static inline void smp_send_reschedule (int cpu)
Josh Poimboeuf
maintainerPATCH v2 18/24 x86/cpu: Mark play_dead() __noreturn
In reply to Josh Poimboeufplay_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/smp.h +1 -1
@@ -93,7 +93,7 @@ static inline void __cpu_die(unsigned int cpu) smp_ops.cpu_die (cpu); } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) { smp_ops.play_dead ();BUG ();
arch/x86/kernel/process.c +1 -1
@@ -715,7 +715,7 @@ static bool x86_idle_set(void) }#ifndef CONFIG_SMP -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Signature · 1 line
2.39.1
[tip: objtool/core] x86/cpu: Mark play_dead() __noreturn
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: eab89405b6b59947ee29cc21fb39ead66142c9b5 Gitweb: https://git.kernel.org/tip/eab89405b6b59947ee29cc21fb39ead66142c9b5 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:52 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:26 -08:00
x86/cpu: Mark play_dead() __noreturn
play_dead() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/x86/include/asm/smp.h | 2 +- arch/x86/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/smp.h +1 -1
@@ -93,7 +93,7 @@ static inline void __cpu_die(unsigned int cpu) smp_ops.cpu_die (cpu); } -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) { smp_ops.play_dead ();BUG ();
arch/x86/kernel/process.c +1 -1
@@ -715,7 +715,7 @@ static bool x86_idle_set(void) }#ifndef CONFIG_SMP -static inline void play_dead (void ) +static inline void __noreturn play_dead (void ) {BUG (); }
Josh Poimboeuf
maintainerPATCH v2 19/24 xtensa/cpu: Make sure cpu_die() doesn't return
In reply to Josh Poimboeufcpu_die() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/xtensa/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/xtensa/kernel/smp.c +2 -0
@@ -341,6 +341,8 @@ void __ref cpu_die(void) __asm__ __volatile__(" movi a2, cpu_restart\n" " jx a2\n" ); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
Signature · 1 line
2.39.1
Re: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
Hi Josh,
arch/xtensa/kernel/smp.c
Quoted 15 lines · Josh Poimboeuf
cpu_die()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/xtensa/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)arch/xtensa/kernel/smp.c +0
-0
Can you update the documentation along? Currently we have:
/*
* Called from the idle thread for the CPU which has been shutdown. *
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/
Quoted 9 lines
arch/xtensa/kernel/smp.c +2
-0@@ -341,6 +341,8 @@ void __ref cpu_die(void) __asm__ __volatile__(" movi a2, cpu_restart\n" " jx a2\n" ); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
Josh Poimboeuf
maintainerRe: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
Quoted 21 lines · Philippe Mathieu-Daudé
Hi Josh,
arch/xtensa/kernel/smp.c
Quoted 15 lines · Josh Poimboeuf
cpu_die()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/xtensa/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)arch/xtensa/kernel/smp.c +0
-0Can you update the documentation along? Currently we have:
Quoted 8 lines
/*
* Called from the idle thread for the CPU which has been shutdown. *
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/
void __ref cpu_die(void)
{
idle_task_exit();
local_irq_disable();
__asm__ __volatile__(
" movi a2, cpu_restart\n"
" jx a2\n");
BUG();
}Hm, not only is the comment wrong, but it seems to be branching to cpu_restart? That doesn't seem right at all.
Max/Chris?
Signature · 1 line
Josh
Steven Rostedt
reviewerRe: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
Quoted 11 lines · On Tue, 14 Feb 2023 10:23:22 -0800 Josh Poimboeuf <[email protected]> wrote:
void
__refcpu_die(void){ idle_task_exit(); local_irq_disable(); __asm__ __volatile__( " movi a2, cpu_restart\n" " jx a2\n"); BUG(); }
Quoted 2 lines
Hm, not only is the comment wrong, but it seems to be branching to
cpu_restart? That doesn't seem right at all.
Agreed, that does not look right at all.
-- Steve
Quoted 3 lines
Max/Chris?
Max Filippov
maintainerRe: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
In reply to Josh PoimboeufQuoted 23 lines · Josh Poimboeuf
Quoted 10 lines · Philippe Mathieu-Daudé
Can you update the documentation along? Currently we have:
/*
* Called from the idle thread for the CPU which has been shutdown. *
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/void
__refcpu_die(void){ idle_task_exit(); local_irq_disable(); __asm__ __volatile__( " movi a2, cpu_restart\n" " jx a2\n"); BUG(); }
Quoted 2 lines
Hm, not only is the comment wrong, but it seems to be branching to
cpu_restart? That doesn't seem right at all.
Perhaps the name is a bit misleading. The CPU that enters 'cpu_restart' loops there until a call to 'boot_secondary' releases it, after which it goes to '_startup'. So it is a restart, but not immediate.
Signature · 2 lines
Thanks. -- Max
Josh Poimboeuf
maintainerRe: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
Quoted 24 lines · Max Filippov
Quoted 23 lines · Josh Poimboeuf
Quoted 10 lines · Philippe Mathieu-Daudé
Can you update the documentation along? Currently we have:
/*
* Called from the idle thread for the CPU which has been shutdown. *
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/void
__refcpu_die(void){ idle_task_exit(); local_irq_disable(); __asm__ __volatile__( " movi a2, cpu_restart\n" " jx a2\n"); BUG(); }
Quoted 6 lines
Quoted 2 lines
Hm, not only is the comment wrong, but it seems to be branching to
cpu_restart? That doesn't seem right at all.Perhaps the name is a bit misleading. The CPU that enters '
cpu_restart' loops there until a call to 'boot_secondary' releases it, after which it goes to '_startup'. So it is a restart, but not immediate.
Ah, I see. That sounds similar to what Xen does.
Signature · 1 line
Josh
Re: [PATCH v2 19/24] xtensa/cpu: Make sure cpu_die() doesn't return
In reply to Josh PoimboeufHi Josh,
arch/xtensa/kernel/smp.c
Quoted 15 lines · Josh Poimboeuf
cpu_die()doesn't return. Make that more explicit with aBUG().
BUG()is preferable tounreachable()becauseBUG()is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/xtensa/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)arch/xtensa/kernel/smp.c +0
-0
Can you update the documentation along? Currently we have:
/*
* Called from the idle thread for the CPU which has been shutdown. *
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/
Quoted 9 lines
arch/xtensa/kernel/smp.c +2
-0@@ -341,6 +341,8 @@ void __ref cpu_die(void) __asm__ __volatile__(" movi a2, cpu_restart\n" " jx a2\n" ); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
[tip: objtool/core] xtensa/cpu: Make sure cpu_die() doesn't return
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: d08e12e8126ec88d6cb1a7eb160d8d7b52c8699f Gitweb: https://git.kernel.org/tip/d08e12e8126ec88d6cb1a7eb160d8d7b52c8699f Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:53 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:27 -08:00
xtensa/cpu: Make sure cpu_die() doesn't return
cpu_die() doesn't return. Make that more explicit with a BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit failure mode and avoids undefined behavior like falling off the edge of the function into whatever code happens to be next.
--- arch/xtensa/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/xtensa/kernel/smp.c +2 -0
@@ -341,6 +341,8 @@ void __ref cpu_die(void) __asm__ __volatile__(" movi a2, cpu_restart\n" " jx a2\n" ); + + BUG(); }#endif /* CONFIG_HOTPLUG_CPU */
Josh Poimboeuf
maintainerPATCH v2 20/24 xtensa/cpu: Mark cpu_die() __noreturn
In reply to Josh Poimboeufcpu_die() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/xtensa/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/include/asm/smp.h +1 -1
@@ -33,7 +33,7 @@ void show_ipi_list(struct seq_file *p, int prec);void __cpu_die (unsigned int cpu);int __cpu_disable (void ); -void cpu_die (void ); +void __noreturn cpu_die (void );void cpu_restart (void );#endif /* CONFIG_HOTPLUG_CPU */
Signature · 1 line
2.39.1
Re: [PATCH v2 20/24] xtensa/cpu: Mark cpu_die() __noreturn
Quoted 8 lines · Josh Poimboeuf
cpu_die()doesn't return. Annotate it as such. By extension this also makesarch_cpu_idle_dead()noreturn.Signed-off-by Josh Poimboeuf <[email protected]>--- arch/xtensa/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Thanks. -- Max
[tip: objtool/core] xtensa/cpu: Mark cpu_die() __noreturn
In reply to Josh PoimboeufThe following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 69dee6f0338a20c76a7bc61c0a6b59f25e1b25c8 Gitweb: https://git.kernel.org/tip/69dee6f0338a20c76a7bc61c0a6b59f25e1b25c8 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:54 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:27 -08:00
xtensa/cpu: Mark cpu_die() __noreturn
cpu_die() doesn't return. Annotate it as such. By extension this also makes arch_cpu_idle_dead() noreturn.
--- arch/xtensa/include/asm/smp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/include/asm/smp.h +1 -1
@@ -33,7 +33,7 @@ void show_ipi_list(struct seq_file *p, int prec);void __cpu_die (unsigned int cpu);int __cpu_disable (void ); -void cpu_die (void ); +void __noreturn cpu_die (void );void cpu_restart (void );#endif /* CONFIG_HOTPLUG_CPU */
Josh Poimboeuf
maintainerPATCH v2 21/24 sched/idle: Make sure weak version of arch_cpu_idle_dead() doesn't return
In reply to Josh Poimboeufarch_cpu_idle_dead() should never return. Make it so.
--- kernel/sched/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/idle.c +1 -1
@@ -75,7 +75,7 @@ static noinline int __cpuidle cpu_idle_poll(void)void __weak arch_cpu_idle_prepare (void ) { }void __weak arch_cpu_idle_enter (void ) { }void __weak arch_cpu_idle_exit (void ) { } -void __weak arch_cpu_idle_dead (void ) { } +void __weak arch_cpu_idle_dead (void ) {while (1 ); }void __weak arch_cpu_idle (void ) { cpu_idle_force_poll =1 ;
Signature · 1 line
2.39.1
[tip: objtool/core] sched/idle: Make sure weak version of arch_cpu_idle_dead() doesn't return
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: dfb0f170cadb03da4f408ae53cc2908120e1f90e Gitweb: https://git.kernel.org/tip/dfb0f170cadb03da4f408ae53cc2908120e1f90e Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:55 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:27 -08:00
sched/idle: Make sure weak version of arch_cpu_idle_dead() doesn't return
arch_cpu_idle_dead() should never return. Make it so.
--- kernel/sched/idle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/idle.c +1 -1
@@ -75,7 +75,7 @@ static noinline int __cpuidle cpu_idle_poll(void)void __weak arch_cpu_idle_prepare (void ) { }void __weak arch_cpu_idle_enter (void ) { }void __weak arch_cpu_idle_exit (void ) { } -void __weak arch_cpu_idle_dead (void ) { } +void __weak arch_cpu_idle_dead (void ) {while (1 ); }void __weak arch_cpu_idle (void ) { cpu_idle_force_poll =1 ;
Josh Poimboeuf
maintainerPATCH v2 22/24 objtool: Include weak functions in 'global_noreturns' check
In reply to Josh PoimboeufIf a global __noreturn function prototype has a corresponding weak function, it should also be __noreturn.
--- tools/objtool/check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/objtool/check.c +4 -4
@@ -193,14 +193,14 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,if (!func)return false; -if (func->bind ==STB_WEAK ) -return false; - -if (func->bind ==STB_GLOBAL ) +if (func->bind ==STB_GLOBAL || func->bind ==STB_WEAK )for (i =0 ; i <ARRAY_SIZE (global_noreturns); i++)if (!strcmp (func->name, global_noreturns[i]))return true; +if (func->bind ==STB_WEAK ) +return false; +if (!func->len)return false;
Signature · 1 line
2.39.1
Josh Poimboeuf
maintainerPATCH v2 23/24 init: Make arch_call_rest_init() and rest_init() __noreturn
In reply to Josh Poimboeufarch_call_rest_init() and rest_init() don't return. Annotate them as such.
Fixes the following warning:
init/main.o: warning: objtool: start_kernel+0x4ad: unreachable instruction
--- arch/s390/kernel/setup.c | 2 +- include/linux/start_kernel.h | 4 ++-- init/main.c | 4 ++-- tools/objtool/check.c | 2 ++ 4 files changed, 7 insertions(+), 5 deletions(-)
arch/s390/kernel/setup.c +1 -1
@@ -393,7 +393,7 @@ int __init arch_early_irq_init(void)return 0 ; } -void __init arch_call_rest_init (void ) +void __init __noreturn arch_call_rest_init (void ) {unsigned long stack;
include/linux/start_kernel.h +2 -2
@@ -9,7 +9,7 @@up something else. */ extern asmlinkage void __init start_kernel(void); -extern void __init arch_call_rest_init (void ); -extern void __ref rest_init (void ); +extern void __init __noreturn arch_call_rest_init (void ); +extern void __ref __noreturn rest_init (void );#endif /* _LINUX_START_KERNEL_H */
init/main.c +2 -2
@@ -683,7 +683,7 @@ static void __init setup_command_line(char *command_line)static __initdata DECLARE_COMPLETION (kthreadd_done); -noinline void __ref rest_init(void) +noinline void __ref __noreturn rest_init(void) {struct task_struct *tsk;int pid;
@@ -889,7 +889,7 @@ static int __init early_randomize_kstack_offset(char *buf)early_param ("randomize_kstack_offset" , early_randomize_kstack_offset);#endif -void __init __weak arch_call_rest_init (void ) +void __init __weak __noreturn arch_call_rest_init (void ) {rest_init (); }
tools/objtool/check.c +2 -0
@@ -167,6 +167,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__reiserfs_panic" ,"__stack_chk_fail" ,"__ubsan_handle_builtin_unreachable" , +"arch_call_rest_init" ,"cpu_bringup_and_idle" ,"cpu_startup_entry" , "do_exit",
@@ -181,6 +182,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"machine_real_restart" ,"make_task_dead" ,"panic" , +"rest_init" ,"rewind_stack_and_make_dead" ,"sev_es_terminate" , "snp_abort",
Signature · 1 line
2.39.1
Josh Poimboeuf
maintainerPATCH v2 24/24 sched/idle: Mark arch_cpu_idle_dead() __noreturn
In reply to Josh PoimboeufBefore commit 076cbf5d2163 ("x86/xen: don't let xen_pv_play_dead() return"), in Xen, when a previously offlined CPU was brought back online, it unexpectedly resumed execution where it left off in the middle of the idle loop.
There were some hacks to make that work, but the behavior was surprising as do_idle() doesn't expect an offlined CPU to return from the dead (in arch_cpu_idle_dead()).
Now that Xen has been fixed, and the arch-specific implementations of arch_cpu_idle_dead() also don't return, give it a __noreturn attribute.
This will cause the compiler to complain if an arch-specific implementation might return. It also improves code generation for both caller and callee.
Also fixes the following warning:
vmlinux.o: warning: objtool: do_idle+0x25f: unreachable instruction
--- arch/alpha/kernel/process.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm64/kernel/process.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/ia64/kernel/process.c | 2 +- arch/loongarch/kernel/process.c | 2 +- arch/mips/kernel/process.c | 2 +- arch/parisc/kernel/process.c | 2 +- arch/powerpc/kernel/smp.c | 2 +- arch/riscv/kernel/cpu-hotplug.c | 2 +- arch/s390/kernel/idle.c | 2 +- arch/sh/kernel/idle.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/x86/kernel/process.c | 2 +- arch/xtensa/kernel/smp.c | 2 +- include/linux/cpu.h | 2 +- kernel/sched/idle.c | 2 +- tools/objtool/check.c | 1 + 18 files changed, 18 insertions(+), 17 deletions(-)
arch/alpha/kernel/process.c +1 -1
@@ -60,7 +60,7 @@ void arch_cpu_idle(void)wtint (0 ); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {wtint (INT_MAX );BUG ();
arch/arm/kernel/smp.c +1 -1
@@ -320,7 +320,7 @@ void __cpu_die(unsigned int cpu)* of the other hotplug-cpu capable cores, so presumably coming * out of idle fixes this. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {unsigned int cpu =smp_processor_id ();
arch/arm64/kernel/process.c +1 -1
@@ -69,7 +69,7 @@ void (*pm_power_off)(void);EXPORT_SYMBOL_GPL (pm_power_off);#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
arch/csky/kernel/smp.c +1 -1
@@ -300,7 +300,7 @@ void __cpu_die(unsigned int cpu)pr_notice ("CPU%u: shutdown\n" , cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {idle_task_exit ();
arch/ia64/kernel/process.c +1 -1
@@ -225,7 +225,7 @@ static inline void __noreturn play_dead(void) }#endif /* CONFIG_HOTPLUG_CPU */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/loongarch/kernel/process.c +1 -1
@@ -61,7 +61,7 @@ unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;EXPORT_SYMBOL (boot_option_idle_override);#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/mips/kernel/process.c +1 -1
@@ -40,7 +40,7 @@#include <asm/stacktrace.h> #ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/parisc/kernel/process.c +1 -1
@@ -159,7 +159,7 @@ EXPORT_SYMBOL(running_on_qemu);/* * Called from the idle thread for the CPU which has been shutdown. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {#ifdef CONFIG_HOTPLUG_CPU idle_task_exit ();
arch/powerpc/kernel/smp.c +1 -1
@@ -1752,7 +1752,7 @@ void __cpu_die(unsigned int cpu) smp_ops->cpu_die (cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {/* * Disable on the down path. This will be re-enabled by
arch/riscv/kernel/cpu-hotplug.c +1 -1
@@ -71,7 +71,7 @@ void __cpu_die(unsigned int cpu)/* * Called from the idle thread for the CPU which has been shutdown. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {idle_task_exit ();
arch/s390/kernel/idle.c +1 -1
@@ -143,7 +143,7 @@ void arch_cpu_idle_exit(void) { } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
arch/sh/kernel/idle.c +1 -1
@@ -30,7 +30,7 @@ void default_idle(void)clear_bl_bit (); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/sparc/kernel/process_64.c +1 -1
@@ -95,7 +95,7 @@ void arch_cpu_idle(void) }#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {sched_preempt_enable_no_resched ();cpu_play_dead ();
arch/x86/kernel/process.c +1 -1
@@ -727,7 +727,7 @@ void arch_cpu_idle_enter(void)local_touch_nmi (); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/xtensa/kernel/smp.c +1 -1
@@ -322,7 +322,7 @@ void __cpu_die(unsigned int cpu)pr_err ("CPU%u: unable to kill\n" , cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
include/linux/cpu.h +1 -1
@@ -182,7 +182,7 @@ void arch_cpu_idle(void);void arch_cpu_idle_prepare (void );void arch_cpu_idle_enter (void );void arch_cpu_idle_exit (void ); -void arch_cpu_idle_dead (void ); +void __noreturn arch_cpu_idle_dead (void );int cpu_report_state (int cpu);int cpu_check_up_prepare (int cpu);
kernel/sched/idle.c +1 -1
@@ -75,7 +75,7 @@ static noinline int __cpuidle cpu_idle_poll(void)void __weak arch_cpu_idle_prepare (void ) { }void __weak arch_cpu_idle_enter (void ) { }void __weak arch_cpu_idle_exit (void ) { } -void __weak arch_cpu_idle_dead (void ) {while (1 ); } +void __weak __noreturn arch_cpu_idle_dead (void ) {while (1 ); }void __weak arch_cpu_idle (void ) { cpu_idle_force_poll =1 ;
tools/objtool/check.c +1 -0
@@ -168,6 +168,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__stack_chk_fail" ,"__ubsan_handle_builtin_unreachable" ,"arch_call_rest_init" , +"arch_cpu_idle_dead" ,"cpu_bringup_and_idle" ,"cpu_startup_entry" , "do_exit",
Signature · 1 line
2.39.1
[tip: objtool/core] sched/idle: Mark arch_cpu_idle_dead() __noreturn
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 071c44e4278156f18a6a56958617223b6bffa6ab Gitweb: https://git.kernel.org/tip/071c44e4278156f18a6a56958617223b6bffa6ab Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 13 Feb 2023 23:05:58 -08:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:28 -08:00
sched/idle: Mark arch_cpu_idle_dead() __noreturn
Before commit 076cbf5d2163 ("x86/xen: don't let xen_pv_play_dead() return"), in Xen, when a previously offlined CPU was brought back online, it unexpectedly resumed execution where it left off in the middle of the idle loop.
There were some hacks to make that work, but the behavior was surprising as do_idle() doesn't expect an offlined CPU to return from the dead (in arch_cpu_idle_dead()).
Now that Xen has been fixed, and the arch-specific implementations of arch_cpu_idle_dead() also don't return, give it a __noreturn attribute.
This will cause the compiler to complain if an arch-specific implementation might return. It also improves code generation for both caller and callee.
Also fixes the following warning:
vmlinux.o: warning: objtool: do_idle+0x25f: unreachable instruction
--- arch/alpha/kernel/process.c | 2 +- arch/arm/kernel/smp.c | 2 +- arch/arm64/kernel/process.c | 2 +- arch/csky/kernel/smp.c | 2 +- arch/ia64/kernel/process.c | 2 +- arch/loongarch/kernel/process.c | 2 +- arch/mips/kernel/process.c | 2 +- arch/parisc/kernel/process.c | 2 +- arch/powerpc/kernel/smp.c | 2 +- arch/riscv/kernel/cpu-hotplug.c | 2 +- arch/s390/kernel/idle.c | 2 +- arch/sh/kernel/idle.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/x86/kernel/process.c | 2 +- arch/xtensa/kernel/smp.c | 2 +- include/linux/cpu.h | 2 +- kernel/sched/idle.c | 2 +- tools/objtool/check.c | 1 + 18 files changed, 18 insertions(+), 17 deletions(-)
arch/alpha/kernel/process.c +1 -1
@@ -60,7 +60,7 @@ void arch_cpu_idle(void)wtint (0 ); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {wtint (INT_MAX );BUG ();
arch/arm/kernel/smp.c +1 -1
@@ -320,7 +320,7 @@ void __cpu_die(unsigned int cpu)* of the other hotplug-cpu capable cores, so presumably coming * out of idle fixes this. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {unsigned int cpu =smp_processor_id ();
arch/arm64/kernel/process.c +1 -1
@@ -69,7 +69,7 @@ void (*pm_power_off)(void);EXPORT_SYMBOL_GPL (pm_power_off);#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
arch/csky/kernel/smp.c +1 -1
@@ -300,7 +300,7 @@ void __cpu_die(unsigned int cpu)pr_notice ("CPU%u: shutdown\n" , cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {idle_task_exit ();
arch/ia64/kernel/process.c +1 -1
@@ -225,7 +225,7 @@ static inline void __noreturn play_dead(void) }#endif /* CONFIG_HOTPLUG_CPU */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/loongarch/kernel/process.c +1 -1
@@ -62,7 +62,7 @@ unsigned long boot_option_idle_override = IDLE_NO_OVERRIDE;EXPORT_SYMBOL (boot_option_idle_override);#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/mips/kernel/process.c +1 -1
@@ -40,7 +40,7 @@#include <asm/stacktrace.h> #ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/parisc/kernel/process.c +1 -1
@@ -159,7 +159,7 @@ EXPORT_SYMBOL(running_on_qemu);/* * Called from the idle thread for the CPU which has been shutdown. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {#ifdef CONFIG_HOTPLUG_CPU idle_task_exit ();
arch/powerpc/kernel/smp.c +1 -1
@@ -1752,7 +1752,7 @@ void __cpu_die(unsigned int cpu) smp_ops->cpu_die (cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {/* * Disable on the down path. This will be re-enabled by
arch/riscv/kernel/cpu-hotplug.c +1 -1
@@ -71,7 +71,7 @@ void __cpu_die(unsigned int cpu)/* * Called from the idle thread for the CPU which has been shutdown. */ -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {idle_task_exit ();
arch/s390/kernel/idle.c +1 -1
@@ -88,7 +88,7 @@ void arch_cpu_idle_exit(void) { } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
arch/sh/kernel/idle.c +1 -1
@@ -30,7 +30,7 @@ void default_idle(void)clear_bl_bit (); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/sparc/kernel/process_64.c +1 -1
@@ -95,7 +95,7 @@ void arch_cpu_idle(void) }#ifdef CONFIG_HOTPLUG_CPU -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {sched_preempt_enable_no_resched ();cpu_play_dead ();
arch/x86/kernel/process.c +1 -1
@@ -727,7 +727,7 @@ void arch_cpu_idle_enter(void)local_touch_nmi (); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {play_dead (); }
arch/xtensa/kernel/smp.c +1 -1
@@ -322,7 +322,7 @@ void __cpu_die(unsigned int cpu)pr_err ("CPU%u: unable to kill\n" , cpu); } -void arch_cpu_idle_dead (void ) +void __noreturn arch_cpu_idle_dead (void ) {cpu_die (); }
include/linux/cpu.h +1 -1
@@ -182,7 +182,7 @@ void arch_cpu_idle(void);void arch_cpu_idle_prepare (void );void arch_cpu_idle_enter (void );void arch_cpu_idle_exit (void ); -void arch_cpu_idle_dead (void ); +void __noreturn arch_cpu_idle_dead (void );int cpu_report_state (int cpu);int cpu_check_up_prepare (int cpu);
kernel/sched/idle.c +1 -1
@@ -75,7 +75,7 @@ static noinline int __cpuidle cpu_idle_poll(void)void __weak arch_cpu_idle_prepare (void ) { }void __weak arch_cpu_idle_enter (void ) { }void __weak arch_cpu_idle_exit (void ) { } -void __weak arch_cpu_idle_dead (void ) {while (1 ); } +void __weak __noreturn arch_cpu_idle_dead (void ) {while (1 ); }void __weak arch_cpu_idle (void ) { cpu_idle_force_poll =1 ;
tools/objtool/check.c +1 -0
@@ -202,6 +202,7 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,"__reiserfs_panic" ,"__stack_chk_fail" ,"__ubsan_handle_builtin_unreachable" , +"arch_cpu_idle_dead" ,"cpu_bringup_and_idle" ,"cpu_startup_entry" , "do_exit",
[PATCH v2 25/24] x86/cpu: Expose arch_cpu_idle_dead()'s prototype definition
In reply to Josh PoimboeufInclude <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
---
Josh, feel free to include in your v3.
--- arch/x86/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/process.c +1 -0
@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/mm.h> #include <linux/smp.h> +#include <linux/cpu.h> #include <linux/prctl.h> #include <linux/slab.h> #include <linux/sched.h>
Signature · 1 line
2.38.1
[tip: objtool/core] x86/cpu: Expose arch_cpu_idle_dead()'s prototype definition
The following commit has been merged into the objtool/core branch of tip:
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: b4c108d7daf1039cf19388baff30a94563de3f3e Gitweb: https://git.kernel.org/tip/b4c108d7daf1039cf19388baff30a94563de3f3e Author: Philippe Mathieu-Daudé <[email protected]> AuthorDate: Tue, 14 Feb 2023 09:38:57 +01:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Wed, 08 Mar 2023 08:44:30 -08:00
x86/cpu: Expose arch_cpu_idle_dead()'s prototype definition
Include <linux/cpu.h> to make sure arch_cpu_idle_dead() matches its prototype going forward.
--- arch/x86/kernel/process.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/process.c +1 -0
@@ -5,6 +5,7 @@#include <linux/kernel.h> #include <linux/mm.h> #include <linux/smp.h> +#include <linux/cpu.h> #include <linux/prctl.h> #include <linux/slab.h> #include <linux/sched.h>
Quoted 8 lines · Josh Poimboeuf
v2:
- makearch_call_rest_init()andrest_init()__noreturn
- make objtool 'global_returns' work for weak functions
- rebase on tip/objtool/core with dependencies merged in (mingo)
- add acksv1.1:
- add__noreturnto allarch_cpu_idle_dead()implementations (mpe)
Possible similar candidates: panic_smp_self_stop, nmi_panic_self_stop and kexec.
Josh Poimboeuf
maintainerQuoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Josh Poimboeuf
v2:
- makearch_call_rest_init()andrest_init()__noreturn
- make objtool 'global_returns' work for weak functions
- rebase on tip/objtool/core with dependencies merged in (mingo)
- add acks
Quoted 5 lines
Quoted 2 lines
v1.1:
- add__noreturnto allarch_cpu_idle_dead()implementations (mpe)Possible similar candidates:
panic_smp_self_stop,nmi_panic_self_stopand kexec.
Agreed. Any volunteers?
Signature · 1 line
Josh
Quoted 8 lines · Josh Poimboeuf
v2:
- makearch_call_rest_init()andrest_init()__noreturn
- make objtool 'global_returns' work for weak functions
- rebase on tip/objtool/core with dependencies merged in (mingo)
- add acksv1.1:
- add__noreturnto allarch_cpu_idle_dead()implementations (mpe)
Possible similar candidates: panic_smp_self_stop, nmi_panic_self_stop and kexec.
Quoted 8 lines · Josh Poimboeuf
v2:
- makearch_call_rest_init()andrest_init()__noreturn
- make objtool 'global_returns' work for weak functions
- rebase on tip/objtool/core with dependencies merged in (mingo)
- add acksv1.1:
- add__noreturnto allarch_cpu_idle_dead()implementations (mpe)
With this, rcutorture no longer gets objtool complaints on x86, thank you!
Quoted 64 lines
Josh Poimboeuf (24):
alpha/cpu: Expose arch_cpu_idle_dead()'s prototype declaration alpha/cpu: Make surearch_cpu_idle_dead()doesn't return arm/cpu: Make surearch_cpu_idle_dead()doesn't return arm64/cpu: Markcpu_die()__noreturn
csky/cpu: Make surearch_cpu_idle_dead()doesn't return ia64/cpu: Markplay_dead()__noreturn
loongarch/cpu: Make sureplay_dead()doesn't return loongarch/cpu: Markplay_dead()__noreturn
mips/cpu: Expose play_dead()'s prototype definition mips/cpu: Make sureplay_dead()doesn't return mips/cpu: Markplay_dead()__noreturn
powerpc/cpu: Markstart_secondary_resume()__noreturnsh/cpu: Make sureplay_dead()doesn't return
sh/cpu: Markplay_dead()__noreturn
sh/cpu: Expose arch_cpu_idle_dead()'s prototype definition sparc/cpu: Markcpu_play_dead()__noreturn
x86/cpu: Make sureplay_dead()doesn't return
x86/cpu: Markplay_dead()__noreturn
xtensa/cpu: Make surecpu_die()doesn't return xtensa/cpu: Markcpu_die()__noreturn
sched/idle: Make sure weak version ofarch_cpu_idle_dead()doesn't
return
objtool: Include weak functions in 'global_noreturns' check
init: Makearch_call_rest_init()andrest_init()__noreturnsched/idle: Markarch_cpu_idle_dead()__noreturnarch/alpha/kernel/process.c | 4 +++- arch/arm/kernel/smp.c | 4 +++- arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/process.c | 2 +- arch/csky/kernel/smp.c | 4 +++- arch/ia64/kernel/process.c | 6 +++--- arch/loongarch/include/asm/smp.h | 2 +- arch/loongarch/kernel/process.c | 2 +- arch/loongarch/kernel/smp.c | 2 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/kernel/process.c | 2 +- arch/mips/kernel/smp-bmips.c | 3 +++ arch/mips/loongson64/smp.c | 1 + arch/parisc/kernel/process.c | 2 +- arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/kernel/smp.c | 2 +- arch/riscv/kernel/cpu-hotplug.c | 2 +- arch/s390/kernel/idle.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/sh/include/asm/smp-ops.h | 5 +++-- arch/sh/kernel/idle.c | 3 ++- arch/sparc/include/asm/smp_64.h | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/x86/include/asm/smp.h | 3 ++- arch/x86/kernel/process.c | 4 ++-- arch/xtensa/include/asm/smp.h | 2 +- arch/xtensa/kernel/smp.c | 4 +++- include/linux/cpu.h | 2 +- include/linux/start_kernel.h | 4 ++-- init/main.c | 4 ++-- kernel/sched/idle.c | 2 +- tools/objtool/check.c | 11 +++++++---- 32 files changed, 57 insertions(+), 39 deletions(-)Signature · 1 line
2.39.1