Skip to contentSkip to conversation

watchdog: Fix a watchdog crash in some configurations

PATCH In review [email protected] 2 participants 2 messages May 5, 2015 – May 18, 2015 1 message not in the archive Linux-next tree

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v4 1/1 watchdog: Fix a watchdog crash in some configurations

From: John Hubbard <[email protected]>

Commit <8fcf2cc768acd845c> in linux-next
introduced a regression in some configurations. Specifically, with CONFIG_NO_HZ_FULL set, and CONFIG_NO_HZ_FULL_ALL *not* set, the kernel will crash in lockup_detector_init(), due to a NULL tick_nohz_full_mask pointer.

This is because the above commit uses tick_nohz_full_mask (in lockup_detector_init), if CONFIG_NO_HZ_FULL is set, but tick_nohz_full_mask only gets allocated if either:

a) CONFIG_NO_HZ_FULL_ALL is set, or

b) Someone passes in nohz_full=<any_value> on the boot args line.

To correct this, change lockup_detector_init so that it does a runtime check in addition to the ifdef check. This fix is simpler than my original proposed fix, thanks to Chris Metcalf for that.

---
 kernel/watchdog.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/watchdog.c +7 -4
index 40fda2f..be34f7f 100644
@@ -921,10 +921,13 @@ void __init lockup_detector_init(void)
 	set_sample_period();
 
 #ifdef CONFIG_NO_HZ_FULL
-	if (!cpumask_empty(tick_nohz_full_mask))
-		pr_info("Disabling watchdog on nohz_full cores by default\n");
-	cpumask_andnot(&watchdog_cpumask, cpu_possible_mask,
-		       tick_nohz_full_mask);
+	if (tick_nohz_full_enabled()) {
+		if (!cpumask_empty(tick_nohz_full_mask))
+			pr_info("Disabling watchdog on nohz_full cores by default\n");
+		cpumask_andnot(&watchdog_cpumask, cpu_possible_mask,
+			       tick_nohz_full_mask);
+	} else
+		cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
 #else
 	cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
 #endif
Signature · 1 line
2.3.7
Acked-by on v4 1/1
#2 lore raw
Quoted 14 lines · On Tue, May 05, 2015 at 04:00:24PM -0700, [email protected] wrote:

From: John Hubbard <[email protected]>

Commit <8fcf2cc768acd845c> in linux-next
introduced a regression in some configurations. Specifically, with CONFIG_NO_HZ_FULL set, and CONFIG_NO_HZ_FULL_ALL *not* set, the kernel will crash in lockup_detector_init(), due to a NULL tick_nohz_full_mask pointer.

This is because the above commit uses tick_nohz_full_mask (in lockup_detector_init), if CONFIG_NO_HZ_FULL is set, but tick_nohz_full_mask only gets allocated if either:

a) CONFIG_NO_HZ_FULL_ALL is set, or

Quoted 7 lines

b) Someone passes in nohz_full=<any_value> on the boot args line.

To correct this, change lockup_detector_init so that it does a runtime check in addition to the ifdef check. This fix is simpler than my original proposed fix, thanks to Chris Metcalf for that.

Quoted 31 lines
---
 kernel/watchdog.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/watchdog.c +7 -4
index 40fda2f..be34f7f 100644
@@ -921,10 +921,13 @@ void __init lockup_detector_init(void)
 	set_sample_period();
 
 #ifdef CONFIG_NO_HZ_FULL
-	if (!cpumask_empty(tick_nohz_full_mask))
-		pr_info("Disabling watchdog on nohz_full cores by default\n");
-	cpumask_andnot(&watchdog_cpumask, cpu_possible_mask,
-		       tick_nohz_full_mask);
+	if (tick_nohz_full_enabled()) {
+		if (!cpumask_empty(tick_nohz_full_mask))
+			pr_info("Disabling watchdog on nohz_full cores by default\n");
+		cpumask_andnot(&watchdog_cpumask, cpu_possible_mask,
+			       tick_nohz_full_mask);
+	} else
+		cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
 #else
 	cpumask_copy(&watchdog_cpumask, cpu_possible_mask);
 #endif
Signature · 1 line
2.3.7