powerpc/watchdog: Moderate touch_nmi_watchdog overhead
authorNicholas Piggin <npiggin@gmail.com>
Wed, 9 Aug 2017 12:41:23 +0000 (22:41 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 9 Aug 2017 13:45:29 +0000 (23:45 +1000)
Some code can go into a tight loop calling touch_nmi_watchdog (e.g.,
stop_machine CPU hotplug code). This can cause contention on watchdog
locks particularly if all CPUs with watchdog enabled are spinning in
the loops.

Avoid this storm of activity by running the watchdog timer callback
from this path if we have exceeded the timer period since it was last
run.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/watchdog.c

index fda4d044d3264508b93e163978e336d1d188eef4..426dd34891d68b34991d92dcea64be61937d40a4 100644 (file)
@@ -263,9 +263,11 @@ static void wd_timer_fn(unsigned long data)
 
 void arch_touch_nmi_watchdog(void)
 {
+       unsigned long ticks = tb_ticks_per_usec * wd_timer_period_ms * 1000;
        int cpu = smp_processor_id();
 
-       watchdog_timer_interrupt(cpu);
+       if (get_tb() - per_cpu(wd_timer_tb, cpu) >= ticks)
+               watchdog_timer_interrupt(cpu);
 }
 EXPORT_SYMBOL(arch_touch_nmi_watchdog);