watchdog: Fix a watchdog crash in some configurations
PATCH 1/1 watchdog: Fix a watchdog crash in some configurations
From: John Hubbard <[email protected]>
Commit 8fcf2cc768acd845c1fed837bf9cfe2d7106336d 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 now matches the way most of the other CONFIG_NO_HZ_FULL code does it's checking. This fix is a little simpler than my original proposed fix, thanks to Chris Metcalf for that.
--- kernel/watchdog.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
kernel/watchdog.c +8 -4
@@ -921,10 +921,14 @@ 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
Quoted 14 lines · On Mon, May 04, 2015 at 04:17:07PM -0700, [email protected] wrote:
From: John Hubbard <[email protected]>
Commit
8fcf2cc768acd845c1fed837bf9cfe2d7106336din linux-next introduced a regression in some configurations. Specifically, withCONFIG_NO_HZ_FULLset, andCONFIG_NO_HZ_FULL_ALL*not* set, the kernel will crash inlockup_detector_init(), due to a NULLtick_nohz_full_maskpointer.This is because the above commit uses
tick_nohz_full_mask(inlockup_detector_init), ifCONFIG_NO_HZ_FULLis set, buttick_nohz_full_maskonly gets allocated if either:a)
CONFIG_NO_HZ_FULL_ALLis set, or
Quoted 8 lines
b) Someone passes in nohz_full=<any_value> on the boot args line.
To correct this, change
lockup_detector_initso that it does a runtime check (in addition to the ifdef check). This now matches the way most of the otherCONFIG_NO_HZ_FULLcode does it's checking. This fix is a little simpler than my original proposed fix, thanks to Chris Metcalf for that.
Hi Chris,
If you are ok with this, I can forward it along.
Cheers,
Don
Quoted 32 lines
Signed-off-by John Hubbard <[email protected]>--- kernel/watchdog.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)kernel/watchdog.c +8
-4@@ -921,10 +921,14 @@ 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
Quoted 27 lines · Don Zickus
Quoted 16 lines · On Mon, May 04, 2015 at 04:17:07PM -0700, [email protected] wrote:
From: John Hubbard <[email protected]>
Commit
8fcf2cc768acd845c1fed837bf9cfe2d7106336din linux-next introduced a regression in some configurations. Specifically, withCONFIG_NO_HZ_FULLset, andCONFIG_NO_HZ_FULL_ALL*not* set, the kernel will crash inlockup_detector_init(), due to a NULLtick_nohz_full_maskpointer.This is because the above commit uses
tick_nohz_full_mask(inlockup_detector_init), ifCONFIG_NO_HZ_FULLis set, buttick_nohz_full_maskonly gets allocated if either:a)
CONFIG_NO_HZ_FULL_ALLis set, orQuoted 8 lines
b) Someone passes in nohz_full=<any_value> on the boot args line.
To correct this, change
lockup_detector_initso that it does a runtime check (in addition to the ifdef check). This now matches the way most of the otherCONFIG_NO_HZ_FULLcode does it's checking. This fix is a little simpler than my original proposed fix, thanks to Chris Metcalf for that.
Quoted 6 lines
Hi Chris,
If you are ok with this, I can forward it along.
Cheers,
Don
With the new dynamic test, we don't actually need the ifdef anymore. I asked John if he could respin it without that.
Quoted 33 lines
Quoted 33 lines
Signed-off-by John Hubbard <[email protected]>---
kernel/watchdog.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)kernel/watchdog.c +8
-4@@ -921,10 +921,14 @@ 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
Quoted 27 lines · Chris Metcalf
Quoted 27 lines · Don Zickus
Quoted 24 lines · On Mon, May 04, 2015 at 04:17:07PM -0700, [email protected] wrote:
From: John Hubbard <[email protected]>
Commit
8fcf2cc768acd845c1fed837bf9cfe2d7106336din linux-next introduced a regression in some configurations. Specifically, withCONFIG_NO_HZ_FULLset, andCONFIG_NO_HZ_FULL_ALL*not* set, the kernel will crash inlockup_detector_init(), due to a NULLtick_nohz_full_maskpointer.This is because the above commit uses
tick_nohz_full_mask(inlockup_detector_init), ifCONFIG_NO_HZ_FULLis set, buttick_nohz_full_maskonly gets allocated if either:a)
CONFIG_NO_HZ_FULL_ALLis set, orb) Someone passes in nohz_full=<any_value> on the boot args line.
To correct this, change
lockup_detector_initso that it does a runtime check (in addition to the ifdef check). This now matches the way most of the otherCONFIG_NO_HZ_FULLcode does it's checking. This fix is a little simpler than my original proposed fix, thanks to Chris Metcalf for that.
Quoted 8 lines
Quoted 6 lines
Hi Chris,
If you are ok with this, I can forward it along.
Cheers,
DonWith the new dynamic test, we don't actually need the ifdef anymore. I asked John if he could respin it without that.
Ok, I will wait for the respin. Thanks!
Cheers,
Don
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Signed-off-by John Hubbard <[email protected]>---
kernel/watchdog.c| 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)kernel/watchdog.c +8
-4@@ -921,10 +921,14 @@ 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
PATCH v2 1/1 watchdog: Fix a watchdog crash in some configurations
From: John Hubbard <[email protected]>
Commit 8fcf2cc768acd845c1fed837bf9cfe2d7106336d 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 instead of the ifdef check. This fix is simpler than my original proposed fix, thanks to Chris Metcalf for that.
--- kernel/watchdog.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
kernel/watchdog.c +8 -8
@@ -920,14 +920,14 @@ 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); -#else -cpumask_copy (&watchdog_cpumask, cpu_possible_mask); -#endif +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);if (watchdog_enabled)watchdog_enable_all_cpus ();
Signature · 1 line
2.3.7
Quoted 36 lines · On Tue, 5 May 2015 12:38:11 -0700 [email protected] wrote:
From: John Hubbard <[email protected]>
Commit
8fcf2cc768acd845c1fed837bf9cfe2d7106336din linux-next introduced a regression in some configurations. Specifically, withCONFIG_NO_HZ_FULLset, andCONFIG_NO_HZ_FULL_ALL*not* set, the kernel will crash inlockup_detector_init(), due to a NULLtick_nohz_full_maskpointer.This is because the above commit uses
tick_nohz_full_mask(inlockup_detector_init), ifCONFIG_NO_HZ_FULLis set, buttick_nohz_full_maskonly gets allocated if either:a)
CONFIG_NO_HZ_FULL_ALLis set, orb) Someone passes in nohz_full=<any_value> on the boot args line.
To correct this, change
lockup_detector_initso that it does a runtime check instead of the ifdef check. This fix is simpler than my original proposed fix, thanks to Chris Metcalf for that....
kernel/watchdog.c +0
-6@@ -920,14 +920,14 @@ 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); -#else
kernel/watchdog.c void __init lockup_detector_init(void) · line 930
Quoted 10 lines
kernel/watchdog.c +8
-2-cpumask_copy (&watchdog_cpumask, cpu_possible_mask); -#endif +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);
Breaks x86_64 allmodconfig:
kernel/watchdog.c: In function 'lockup_detector_init':kernel/watchdog.c:924: error: 'tick_nohz_full_mask' undeclared (first use in this function)