mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
83 lines
1.6 KiB
C
83 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2020 Western Digital Corporation or its affiliates.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/err.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/sched/hotplug.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/cpu_ops.h>
|
|
#include <asm/numa.h>
|
|
#include <asm/sbi.h>
|
|
|
|
bool cpu_has_hotplug(unsigned int cpu)
|
|
{
|
|
if (cpu_ops[cpu]->cpu_stop)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* __cpu_disable runs on the processor to be shutdown.
|
|
*/
|
|
int __cpu_disable(void)
|
|
{
|
|
int ret = 0;
|
|
unsigned int cpu = smp_processor_id();
|
|
|
|
if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_stop)
|
|
return -EOPNOTSUPP;
|
|
|
|
if (cpu_ops[cpu]->cpu_disable)
|
|
ret = cpu_ops[cpu]->cpu_disable(cpu);
|
|
|
|
if (ret)
|
|
return ret;
|
|
|
|
remove_cpu_topology(cpu);
|
|
numa_remove_cpu(cpu);
|
|
set_cpu_online(cpu, false);
|
|
irq_migrate_all_off_this_cpu();
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Called on the thread which is asking for a CPU to be shutdown.
|
|
*/
|
|
void __cpu_die(unsigned int cpu)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (!cpu_wait_death(cpu, 5)) {
|
|
pr_err("CPU %u: didn't die\n", cpu);
|
|
return;
|
|
}
|
|
pr_notice("CPU%u: off\n", cpu);
|
|
|
|
/* Verify from the firmware if the cpu is really stopped*/
|
|
if (cpu_ops[cpu]->cpu_is_stopped)
|
|
ret = cpu_ops[cpu]->cpu_is_stopped(cpu);
|
|
if (ret)
|
|
pr_warn("CPU%d may not have stopped: %d\n", cpu, ret);
|
|
}
|
|
|
|
/*
|
|
* Called from the idle thread for the CPU which has been shutdown.
|
|
*/
|
|
void __noreturn arch_cpu_idle_dead(void)
|
|
{
|
|
idle_task_exit();
|
|
|
|
(void)cpu_report_death();
|
|
|
|
cpu_ops[smp_processor_id()]->cpu_stop();
|
|
/* It should never reach here */
|
|
BUG();
|
|
}
|