Re: [PATCH AUTOSEL 5.15 14/28] watchdog: export lockup_detector_reconfigure

From: Laurent Dufour
Date: Tue Aug 23 2022 - 08:04:09 EST


Le 14/08/2022 à 18:25, Sasha Levin a écrit :
> From: Laurent Dufour <ldufour@xxxxxxxxxxxxx>
>
> [ Upstream commit 7c56a8733d0a2a4be2438a7512566e5ce552fccf ]

Hi Sasha,

Thanks for picking this patch.

Do you plan to pick the 2 others patches of this series in the older
kernels, as you did for 5.18 and 5.19 ?

The 2 other patches in this series are:
118b1366930c ("powerpc/pseries/mobility: set NMI watchdog factor during an
LPM")
f5e74e836097 ("powerpc/watchdog: introduce a NMI watchdog's factor")

I'm not sure how well they apply to these older kernels.

Thanks,
Laurent.

>
> In some circumstances it may be interesting to reconfigure the watchdog
> from inside the kernel.
>
> On PowerPC, this may helpful before and after a LPAR migration (LPM) is
> initiated, because it implies some latencies, watchdog, and especially NMI
> watchdog is expected to be triggered during this operation. Reconfiguring
> the watchdog with a factor, would prevent it to happen too frequently
> during LPM.
>
> Rename lockup_detector_reconfigure() as __lockup_detector_reconfigure() and
> create a new function lockup_detector_reconfigure() calling
> __lockup_detector_reconfigure() under the protection of watchdog_mutex.
>
> Signed-off-by: Laurent Dufour <ldufour@xxxxxxxxxxxxx>
> [mpe: Squash in build fix from Laurent, reported by Sachin]
> Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/20220713154729.80789-3-ldufour@xxxxxxxxxxxxx
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---
> include/linux/nmi.h | 2 ++
> kernel/watchdog.c | 21 ++++++++++++++++-----
> 2 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/nmi.h b/include/linux/nmi.h
> index 750c7f395ca9..f700ff2df074 100644
> --- a/include/linux/nmi.h
> +++ b/include/linux/nmi.h
> @@ -122,6 +122,8 @@ int watchdog_nmi_probe(void);
> int watchdog_nmi_enable(unsigned int cpu);
> void watchdog_nmi_disable(unsigned int cpu);
>
> +void lockup_detector_reconfigure(void);
> +
> /**
> * touch_nmi_watchdog - restart NMI watchdog timeout.
> *
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index ad912511a0c0..1cfa269bd448 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -537,7 +537,7 @@ int lockup_detector_offline_cpu(unsigned int cpu)
> return 0;
> }
>
> -static void lockup_detector_reconfigure(void)
> +static void __lockup_detector_reconfigure(void)
> {
> cpus_read_lock();
> watchdog_nmi_stop();
> @@ -557,6 +557,13 @@ static void lockup_detector_reconfigure(void)
> __lockup_detector_cleanup();
> }
>
> +void lockup_detector_reconfigure(void)
> +{
> + mutex_lock(&watchdog_mutex);
> + __lockup_detector_reconfigure();
> + mutex_unlock(&watchdog_mutex);
> +}
> +
> /*
> * Create the watchdog infrastructure and configure the detector(s).
> */
> @@ -573,13 +580,13 @@ static __init void lockup_detector_setup(void)
> return;
>
> mutex_lock(&watchdog_mutex);
> - lockup_detector_reconfigure();
> + __lockup_detector_reconfigure();
> softlockup_initialized = true;
> mutex_unlock(&watchdog_mutex);
> }
>
> #else /* CONFIG_SOFTLOCKUP_DETECTOR */
> -static void lockup_detector_reconfigure(void)
> +static void __lockup_detector_reconfigure(void)
> {
> cpus_read_lock();
> watchdog_nmi_stop();
> @@ -587,9 +594,13 @@ static void lockup_detector_reconfigure(void)
> watchdog_nmi_start();
> cpus_read_unlock();
> }
> +void lockup_detector_reconfigure(void)
> +{
> + __lockup_detector_reconfigure();
> +}
> static inline void lockup_detector_setup(void)
> {
> - lockup_detector_reconfigure();
> + __lockup_detector_reconfigure();
> }
> #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
>
> @@ -629,7 +640,7 @@ static void proc_watchdog_update(void)
> {
> /* Remove impossible cpus to keep sysctl output clean. */
> cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask);
> - lockup_detector_reconfigure();
> + __lockup_detector_reconfigure();
> }
>
> /*