On 2022-07-14, Zhouyi Zhou <zhouzhouyi@xxxxxxxxx> wrote: > use raw_smp_processor_id() in arch_touch_nmi_watchdog > because when called from watchdog, the cpu is preemptible. I would expect the correct solution is to make it a non-migration section. Something like the below (untested) patch. John Ogness diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index bfc27496fe7e..9d34aa809241 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c @@ -450,17 +450,23 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) void arch_touch_nmi_watchdog(void) { unsigned long ticks = tb_ticks_per_usec * wd_timer_period_ms * 1000; - int cpu = smp_processor_id(); + int cpu; u64 tb; - if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) + cpu = get_cpu(); + + if (!cpumask_test_cpu(cpu, &watchdog_cpumask)) { + goto out; return; + } tb = get_tb(); if (tb - per_cpu(wd_timer_tb, cpu) >= ticks) { per_cpu(wd_timer_tb, cpu) = tb; wd_smp_clear_cpu_pending(cpu); } +out: + put_cpu(); } EXPORT_SYMBOL(arch_touch_nmi_watchdog);