mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 22:58:29 +00:00
cpu/hotplug: Create a new function to shutdown nonboot cpus
This function will be used later in machine_shutdown() for some architectures. disable_nonboot_cpus() is not safe to use when doing machine_down(), because it relies on freeze_secondary_cpus() which in turn is a suspend/resume related freeze and could abort if the logic detects any pending activities that can prevent finishing the offlining process. Signed-off-by: Qais Yousef <qais.yousef@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20200323135110.30522-3-qais.yousef@arm.com
This commit is contained in:
parent
93ef1429e5
commit
0441a5597c
2 changed files with 44 additions and 0 deletions
|
@ -120,6 +120,7 @@ extern void cpu_hotplug_enable(void);
|
||||||
void clear_tasks_mm_cpumask(int cpu);
|
void clear_tasks_mm_cpumask(int cpu);
|
||||||
int cpu_down(unsigned int cpu);
|
int cpu_down(unsigned int cpu);
|
||||||
int remove_cpu(unsigned int cpu);
|
int remove_cpu(unsigned int cpu);
|
||||||
|
extern void smp_shutdown_nonboot_cpus(unsigned int primary_cpu);
|
||||||
|
|
||||||
#else /* CONFIG_HOTPLUG_CPU */
|
#else /* CONFIG_HOTPLUG_CPU */
|
||||||
|
|
||||||
|
@ -131,6 +132,7 @@ static inline int cpus_read_trylock(void) { return true; }
|
||||||
static inline void lockdep_assert_cpus_held(void) { }
|
static inline void lockdep_assert_cpus_held(void) { }
|
||||||
static inline void cpu_hotplug_disable(void) { }
|
static inline void cpu_hotplug_disable(void) { }
|
||||||
static inline void cpu_hotplug_enable(void) { }
|
static inline void cpu_hotplug_enable(void) { }
|
||||||
|
static inline void smp_shutdown_nonboot_cpus(unsigned int primary_cpu) { }
|
||||||
#endif /* !CONFIG_HOTPLUG_CPU */
|
#endif /* !CONFIG_HOTPLUG_CPU */
|
||||||
|
|
||||||
/* Wrappers which go away once all code is converted */
|
/* Wrappers which go away once all code is converted */
|
||||||
|
|
42
kernel/cpu.c
42
kernel/cpu.c
|
@ -1069,6 +1069,48 @@ int remove_cpu(unsigned int cpu)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(remove_cpu);
|
EXPORT_SYMBOL_GPL(remove_cpu);
|
||||||
|
|
||||||
|
void smp_shutdown_nonboot_cpus(unsigned int primary_cpu)
|
||||||
|
{
|
||||||
|
unsigned int cpu;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
cpu_maps_update_begin();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make certain the cpu I'm about to reboot on is online.
|
||||||
|
*
|
||||||
|
* This is inline to what migrate_to_reboot_cpu() already do.
|
||||||
|
*/
|
||||||
|
if (!cpu_online(primary_cpu))
|
||||||
|
primary_cpu = cpumask_first(cpu_online_mask);
|
||||||
|
|
||||||
|
for_each_online_cpu(cpu) {
|
||||||
|
if (cpu == primary_cpu)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
error = cpu_down_maps_locked(cpu, CPUHP_OFFLINE);
|
||||||
|
if (error) {
|
||||||
|
pr_err("Failed to offline CPU%d - error=%d",
|
||||||
|
cpu, error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure all but the reboot CPU are offline.
|
||||||
|
*/
|
||||||
|
BUG_ON(num_online_cpus() > 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the CPUs won't be enabled by someone else after this
|
||||||
|
* point. Kexec will reboot to a new kernel shortly resetting
|
||||||
|
* everything along the way.
|
||||||
|
*/
|
||||||
|
cpu_hotplug_disabled++;
|
||||||
|
|
||||||
|
cpu_maps_update_done();
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define takedown_cpu NULL
|
#define takedown_cpu NULL
|
||||||
#endif /*CONFIG_HOTPLUG_CPU*/
|
#endif /*CONFIG_HOTPLUG_CPU*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue