]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched/idle: Mark arch_cpu_idle_dead() __noreturn
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Feb 2023 07:05:58 +0000 (23:05 -0800)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 8 Mar 2023 16:44:28 +0000 (08:44 -0800)
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

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/60d527353da8c99d4cf13b6473131d46719ed16d.1676358308.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
18 files changed:
arch/alpha/kernel/process.c
arch/arm/kernel/smp.c
arch/arm64/kernel/process.c
arch/csky/kernel/smp.c
arch/ia64/kernel/process.c
arch/loongarch/kernel/process.c
arch/mips/kernel/process.c
arch/parisc/kernel/process.c
arch/powerpc/kernel/smp.c
arch/riscv/kernel/cpu-hotplug.c
arch/s390/kernel/idle.c
arch/sh/kernel/idle.c
arch/sparc/kernel/process_64.c
arch/x86/kernel/process.c
arch/xtensa/kernel/smp.c
include/linux/cpu.h
kernel/sched/idle.c
tools/objtool/check.c

index a82fefa31bdbabe00ed407393a15626cead41939..582d96548385dd63e392ed27a25dde367f0b4d3a 100644 (file)
@@ -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();
index 441ea5cff3901999984a702d0e4e65fd9ee2297e..d6be4507d22db18c558218c044e44d241a734e5b 100644 (file)
@@ -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();
 
index 71d59b5abede11aa0471f6cbd0cb8edb88575db0..089ced6d6bd6d8e6a99dacbcbf6e3787e9d859ad 100644 (file)
@@ -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();
 }
index 0ec20efaf5fdb79f7deb3fbde3f33128795e2d37..9c7a20b73ac607f15e5a1d7bf0c05cec278a05bd 100644 (file)
@@ -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();
 
index 78f5794b2dde7c13bd6291eabb37bd6dd3409fb3..9a5cd9fad3a9ab10614b13bd4f59d966780ab58a 100644 (file)
@@ -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();
 }
index fa2443c7afb23688ff4b5ca0ba8363720c981282..b71e17c1cc0c094b8ffe4a340f72676c727f8c3b 100644 (file)
@@ -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();
 }
index 093dbbd6b843508bab1d75f17b894955b400b6b5..a3225912c862da7bbe3bd315950f5073006f99e9 100644 (file)
@@ -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();
 }
index c064719b49b09b214a9fede71dd290ab59f98c8c..97c6f875bd0e12f188215afa07815356711593f5 100644 (file)
@@ -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();
index 6b90f10a6c819b2cf95accf64950e23ce92cc538..f62e5e651bcd7eca41d109d2c7e4a57e927d2114 100644 (file)
@@ -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
index f7a832e3a1d1d44f0568a5f7336eb587092d85a0..59b80211c25ff3eb9bda6b17b2cad20c10799d3e 100644 (file)
@@ -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();
 
index 38e267c7bff7249560c2676cfebba4585c2bee46..e7239aaf428b0a6674e081940d1930592f191ece 100644 (file)
@@ -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();
 }
index 114f0c4abeac216a7c84b38b6947aef62506e318..d662503b0665da219acd3816fc8145a1d3f0a969 100644 (file)
@@ -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();
 }
index 91c2b8124527fbefda742e083a4254069b51213e..b51d8fb0ecdc2d693b3e30fb0b908a074df362e3 100644 (file)
@@ -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();
index f1ec36caf1d86530fce60a91df8d53160d13f445..3e30147a537e7392d0deced0da1dc3969dcf5f51 100644 (file)
@@ -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();
 }
index 7bad78495536954c6caf8f3028499f2afcc1bff9..054bd64eab191dd0ed8c4caa802bd912701dc21b 100644 (file)
@@ -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();
 }
index f83e4519c5f05407ce87992f4afefad2f6f0c196..8582a7142623d8b00805196cf69e6619b6997e2a 100644 (file)
@@ -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);
index 56e152f06d0f9515af8a6478a7243ebf9569b835..342f58a329f528fcc6060208cfba9b7e908d3a98 100644 (file)
@@ -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;
index f937be1afe65ca9c968038c701b927dd4126f409..37c36dc1d8688912017d4905dfeb9dd06e4f0bab 100644 (file)
@@ -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",