[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87tu7k6o7n.fsf@jogness.linutronix.de>
Date: Thu, 14 Jul 2022 11:31:00 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Zhouyi Zhou <zhouzhouyi@...il.com>, mpe@...erman.id.au,
benh@...nel.crashing.org, paulus@...ba.org, npiggin@...il.com,
ldufour@...ux.ibm.com, pmladek@...e.com, Julia.Lawall@...ia.fr,
linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
lance@...osl.org, paulmck@...nel.org, rcu@...r.kernel.org
Cc: Zhouyi Zhou <zhouzhouyi@...il.com>
Subject: Re: [PATCH linux-next] powerpc: use raw_smp_processor_id in
arch_touch_nmi_watchdog
On 2022-07-14, Zhouyi Zhou <zhouzhouyi@...il.com> 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);
Powered by blists - more mailing lists