Re: [PATCH] x86/apic: Do not use smp_processor_id() in preemptible code

From: Thomas Gleixner
Date: Tue Sep 26 2017 - 15:03:23 EST


On Tue, 26 Sep 2017, Borislav Petkov wrote:

> From: Borislav Petkov <bp@xxxxxxx>
>
> Call stack is:
>
> check_preemption_disabled
> ? x2apic_prepare_cpu
> x2apic_dead_cpu
> cpuhp_invoke_callback
> ? cpuhp_kick_ap_work
> ? cpumask_next
> _cpu_down
> freeze_secondary_cpus
> hibernation_snapshot
> ...
>
> i.e., box is doing suspend-to-disk.
> Signed-off-by: Borislav Petkov <bp@xxxxxxx>
> ---
> arch/x86/kernel/apic/x2apic_cluster.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
> index 3da94277140f..6050c5364bdc 100644
> --- a/arch/x86/kernel/apic/x2apic_cluster.c
> +++ b/arch/x86/kernel/apic/x2apic_cluster.c
> @@ -156,7 +156,7 @@ static int x2apic_dead_cpu(unsigned int dead_cpu)
> {
> struct cluster_mask *cmsk = per_cpu(cluster_masks, dead_cpu);
>
> - cpumask_clear_cpu(smp_processor_id(), &cmsk->mask);
> + cpumask_clear_cpu(dead_cpu, &cmsk->mask);

Duh......

> free_cpumask_var(per_cpu(ipi_mask, dead_cpu));
> return 0;
> }
> --
> 2.13.0
>
>