Skip to content

Commit

Permalink
kernel/watchdog: provide watchdog_nmi_reconfigure() for arch watchdogs
Browse files Browse the repository at this point in the history
After reconfiguring watchdog sysctls etc., architecture specific
watchdogs may not get all their parameters updated.

watchdog_nmi_reconfigure() can be implemented to pull the new values in
and set the arch NMI watchdog.

[npiggin@gmail.com: add code comments]
  Link: http://lkml.kernel.org/r/20170617125933.774d3858@roar.ozlabs.ibm.com
[arnd@arndb.de: hide unused function]
  Link: http://lkml.kernel.org/r/20170620204854.966601-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/20170616065715.18390-5-npiggin@gmail.com
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Don Zickus <dzickus@redhat.com>
Tested-by: Babu Moger <babu.moger@oracle.com>	[sparc]
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Nicholas Piggin authored and Linus Torvalds committed Jul 12, 2017
1 parent 05a4a95 commit a10a842
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions kernel/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ int __read_mostly watchdog_suspended;
/*
* These functions can be overridden if an architecture implements its
* own hardlockup detector.
*
* watchdog_nmi_enable/disable can be implemented to start and stop when
* softlockup watchdog threads start and stop. The arch must select the
* SOFTLOCKUP_DETECTOR Kconfig.
*/
int __weak watchdog_nmi_enable(unsigned int cpu)
{
Expand All @@ -123,6 +127,22 @@ void __weak watchdog_nmi_disable(unsigned int cpu)
{
}

/*
* watchdog_nmi_reconfigure can be implemented to be notified after any
* watchdog configuration change. The arch hardlockup watchdog should
* respond to the following variables:
* - nmi_watchdog_enabled
* - watchdog_thresh
* - watchdog_cpumask
* - sysctl_hardlockup_all_cpu_backtrace
* - hardlockup_panic
* - watchdog_suspended
*/
void __weak watchdog_nmi_reconfigure(void)
{
}


#ifdef CONFIG_SOFTLOCKUP_DETECTOR

/* Helper for online, unparked cpus. */
Expand Down Expand Up @@ -600,6 +620,14 @@ static void watchdog_disable_all_cpus(void)
}
}

#ifdef CONFIG_SYSCTL
static int watchdog_update_cpus(void)
{
return smpboot_update_cpumask_percpu_thread(
&watchdog_threads, &watchdog_cpumask);
}
#endif

#else /* SOFTLOCKUP */
static int watchdog_park_threads(void)
{
Expand All @@ -619,6 +647,13 @@ static void watchdog_disable_all_cpus(void)
{
}

#ifdef CONFIG_SYSCTL
static int watchdog_update_cpus(void)
{
return 0;
}
#endif

static void set_sample_period(void)
{
}
Expand Down Expand Up @@ -651,6 +686,8 @@ int lockup_detector_suspend(void)
watchdog_enabled = 0;
}

watchdog_nmi_reconfigure();

mutex_unlock(&watchdog_proc_mutex);

return ret;
Expand All @@ -671,6 +708,8 @@ void lockup_detector_resume(void)
if (watchdog_running && !watchdog_suspended)
watchdog_unpark_threads();

watchdog_nmi_reconfigure();

mutex_unlock(&watchdog_proc_mutex);
put_online_cpus();
}
Expand All @@ -696,6 +735,8 @@ static int proc_watchdog_update(void)
else
watchdog_disable_all_cpus();

watchdog_nmi_reconfigure();

return err;

}
Expand Down Expand Up @@ -881,12 +922,11 @@ int proc_watchdog_cpumask(struct ctl_table *table, int write,
* a temporary cpumask, so we are likely not in a
* position to do much else to make things better.
*/
#ifdef CONFIG_SOFTLOCKUP_DETECTOR
if (smpboot_update_cpumask_percpu_thread(
&watchdog_threads, &watchdog_cpumask) != 0)
if (watchdog_update_cpus() != 0)
pr_err("cpumask update failed\n");
#endif
}

watchdog_nmi_reconfigure();
}
out:
mutex_unlock(&watchdog_proc_mutex);
Expand Down

0 comments on commit a10a842

Please sign in to comment.