linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug
@ 2019-03-26 21:51 Thomas Gleixner
  2019-03-27 15:16 ` Oleg Nesterov
  2019-03-28 12:37 ` [tip:core/urgent] " tip-bot for Thomas Gleixner
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Gleixner @ 2019-03-26 21:51 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, x86, Oleg Nesterov, Michael Ellerman,
	Nicholas Piggin, Don Zickus, Ricardo Neri

The rework of the watchdog core to use cpu_stop_work broke the watchdog
cpumask on CPU hotplug.

The watchdog_enable/disable() functions are now called unconditionally from
the hotplug callback, i.e. even on CPUs which are not in the watchdog
cpumask.

Only invoke them when the plugged CPU is in the watchdog cpumask.

Fixes: 9cf57731b63e ("watchdog/softlockup: Replace "watchdog/%u" threads with cpu_stop_work")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
 kernel/watchdog.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -547,13 +547,15 @@ static void softlockup_start_all(void)
 
 int lockup_detector_online_cpu(unsigned int cpu)
 {
-	watchdog_enable(cpu);
+	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
+		watchdog_enable(cpu);
 	return 0;
 }
 
 int lockup_detector_offline_cpu(unsigned int cpu)
 {
-	watchdog_disable(cpu);
+	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
+		watchdog_disable(cpu);
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug
  2019-03-26 21:51 [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug Thomas Gleixner
@ 2019-03-27 15:16 ` Oleg Nesterov
  2019-03-27 19:10   ` Thomas Gleixner
  2019-03-28 12:37 ` [tip:core/urgent] " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2019-03-27 15:16 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Peter Zijlstra, x86, Michael Ellerman, Nicholas Piggin,
	Don Zickus, Ricardo Neri, Maxime Coquelin

On 03/26, Thomas Gleixner wrote:
>
> The rework of the watchdog core to use cpu_stop_work broke the watchdog
> cpumask on CPU hotplug.
>
> The watchdog_enable/disable() functions are now called unconditionally from
> the hotplug callback, i.e. even on CPUs which are not in the watchdog
> cpumask.
>
> Only invoke them when the plugged CPU is in the watchdog cpumask.
>
> Fixes: 9cf57731b63e ("watchdog/softlockup: Replace "watchdog/%u" threads with cpu_stop_work")
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>  kernel/watchdog.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -547,13 +547,15 @@ static void softlockup_start_all(void)
>
>  int lockup_detector_online_cpu(unsigned int cpu)
>  {
> -	watchdog_enable(cpu);
> +	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
> +		watchdog_enable(cpu);
>  	return 0;
>  }
>
>  int lockup_detector_offline_cpu(unsigned int cpu)
>  {
> -	watchdog_disable(cpu);
> +	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
> +		watchdog_disable(cpu);
>  	return 0;
>  }

IIUC without this fix an NMI watchdog can too be enabled at boot time even
if the initial watchdog_cpumask = housekeeping_cpumask(HK_FLAG_TIMER) doesn't
include the plugged CPU.

And after that writing 0 to /proc/sys/kernel/nmi_watchdog clears
NMI_WATCHDOG_ENABLED but this can't disable NMI watchdog's outside of
watchdog_allowed_mask.

So may be this can explain the problem reported by Maxime ?
See https://lore.kernel.org/lkml/b99c5a25-a5fe-18dd-2f1d-bdd6834f03e5@redhat.com/

Oleg.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug
  2019-03-27 15:16 ` Oleg Nesterov
@ 2019-03-27 19:10   ` Thomas Gleixner
  2019-03-28  9:36     ` Maxime Coquelin
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2019-03-27 19:10 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: LKML, Peter Zijlstra, x86, Michael Ellerman, Nicholas Piggin,
	Don Zickus, Ricardo Neri, Maxime Coquelin

On Wed, 27 Mar 2019, Oleg Nesterov wrote:
> On 03/26, Thomas Gleixner wrote:
> >
> > The rework of the watchdog core to use cpu_stop_work broke the watchdog
> > cpumask on CPU hotplug.
> >
> > The watchdog_enable/disable() functions are now called unconditionally from
> > the hotplug callback, i.e. even on CPUs which are not in the watchdog
> > cpumask.
> >
> > Only invoke them when the plugged CPU is in the watchdog cpumask.
> 
> IIUC without this fix an NMI watchdog can too be enabled at boot time even
> if the initial watchdog_cpumask = housekeeping_cpumask(HK_FLAG_TIMER) doesn't
> include the plugged CPU.

Yes.

> And after that writing 0 to /proc/sys/kernel/nmi_watchdog clears
> NMI_WATCHDOG_ENABLED but this can't disable NMI watchdog's outside of
> watchdog_allowed_mask.

Correct

> So may be this can explain the problem reported by Maxime ?
> See https://lore.kernel.org/lkml/b99c5a25-a5fe-18dd-2f1d-bdd6834f03e5@redhat.com/

That looks so.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug
  2019-03-27 19:10   ` Thomas Gleixner
@ 2019-03-28  9:36     ` Maxime Coquelin
  0 siblings, 0 replies; 5+ messages in thread
From: Maxime Coquelin @ 2019-03-28  9:36 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov
  Cc: LKML, Peter Zijlstra, x86, Michael Ellerman, Nicholas Piggin,
	Don Zickus, Ricardo Neri



On 3/27/19 8:10 PM, Thomas Gleixner wrote:
> On Wed, 27 Mar 2019, Oleg Nesterov wrote:
>> On 03/26, Thomas Gleixner wrote:
>>>
>>> The rework of the watchdog core to use cpu_stop_work broke the watchdog
>>> cpumask on CPU hotplug.
>>>
>>> The watchdog_enable/disable() functions are now called unconditionally from
>>> the hotplug callback, i.e. even on CPUs which are not in the watchdog
>>> cpumask.
>>>
>>> Only invoke them when the plugged CPU is in the watchdog cpumask.
>>
>> IIUC without this fix an NMI watchdog can too be enabled at boot time even
>> if the initial watchdog_cpumask = housekeeping_cpumask(HK_FLAG_TIMER) doesn't
>> include the plugged CPU.
> 
> Yes.
> 
>> And after that writing 0 to /proc/sys/kernel/nmi_watchdog clears
>> NMI_WATCHDOG_ENABLED but this can't disable NMI watchdog's outside of
>> watchdog_allowed_mask.
> 
> Correct
> 
>> So may be this can explain the problem reported by Maxime ?
>> See https://lore.kernel.org/lkml/b99c5a25-a5fe-18dd-2f1d-bdd6834f03e5@redhat.com/
> 
> That looks so.

I had a trial with your patch, and I can confirm it fixes my issue:

Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime

> Thanks,
> 
> 	tglx
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:core/urgent] watchdog: Respect watchdog cpumask on CPU hotplug
  2019-03-26 21:51 [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug Thomas Gleixner
  2019-03-27 15:16 ` Oleg Nesterov
@ 2019-03-28 12:37 ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Thomas Gleixner @ 2019-03-28 12:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, peterz, npiggin, oleg, ricardo.neri-calderon, hpa, dzickus,
	mpe, maxime.coquelin, linux-kernel, mingo

Commit-ID:  7dd47617114921fdd8c095509e5e7b4373cc44a1
Gitweb:     https://git.kernel.org/tip/7dd47617114921fdd8c095509e5e7b4373cc44a1
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 26 Mar 2019 22:51:02 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 28 Mar 2019 13:32:01 +0100

watchdog: Respect watchdog cpumask on CPU hotplug

The rework of the watchdog core to use cpu_stop_work broke the watchdog
cpumask on CPU hotplug.

The watchdog_enable/disable() functions are now called unconditionally from
the hotplug callback, i.e. even on CPUs which are not in the watchdog
cpumask. As a consequence the watchdog can become unstoppable.

Only invoke them when the plugged CPU is in the watchdog cpumask.

Fixes: 9cf57731b63e ("watchdog/softlockup: Replace "watchdog/%u" threads with cpu_stop_work")
Reported-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1903262245490.1789@nanos.tec.linutronix.de

---
 kernel/watchdog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 403c9bd90413..6a5787233113 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -554,13 +554,15 @@ static void softlockup_start_all(void)
 
 int lockup_detector_online_cpu(unsigned int cpu)
 {
-	watchdog_enable(cpu);
+	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
+		watchdog_enable(cpu);
 	return 0;
 }
 
 int lockup_detector_offline_cpu(unsigned int cpu)
 {
-	watchdog_disable(cpu);
+	if (cpumask_test_cpu(cpu, &watchdog_allowed_mask))
+		watchdog_disable(cpu);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-03-28 12:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 21:51 [PATCH] watchdog: Respect watchdog cpumask on CPU hotplug Thomas Gleixner
2019-03-27 15:16 ` Oleg Nesterov
2019-03-27 19:10   ` Thomas Gleixner
2019-03-28  9:36     ` Maxime Coquelin
2019-03-28 12:37 ` [tip:core/urgent] " tip-bot for Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).