[PATCH 02/19] cpu/hotplug: Avoid trying to bring up CPUs that are already online
Jinjie Ruan
ruanjinjie at huawei.com
Mon Sep 7 20:13:20 PDT 2026
在 2026/9/8 0:40, Will Deacon 写道:
> There's little point trying to bring up a CPU that is already online.
> Although _cpu_up() handles this case by doing nothing (because the
> target state has already been reached), it's wasted effort when we can
> easily elide the call to cpu_up() in the first place.
>
> Check that the target CPU isn't already online before invoking cpu_up()
> from cpuhp_bringup_mask().
>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> kernel/cpu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cpu.c b/kernel/cpu.c
> index 198c929c452a..97a9bfe4edad 100644
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -1769,7 +1769,8 @@ static void __init cpuhp_bringup_mask(const struct cpumask *mask, unsigned int n
> for_each_cpu(cpu, mask) {
> struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
>
> - if (cpu_up(cpu, target) && can_rollback_cpu(st)) {
> + if (!cpu_online(cpu) && cpu_up(cpu, target) &&
> + can_rollback_cpu(st)) {
Make sense to me.
Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> /*
> * If this failed then cpu_up() might have only
> * rolled back to CPUHP_BP_KICK_AP for the final
More information about the linux-arm-kernel
mailing list