Skip to contentSkip to conversation

watchdog: Force console verbose when reporting lockups

PATCH Applied Tzung-Bi Shih 5 participants 5 messages Oct 7 – Oct 26

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: Force console verbose when reporting lockups

When a hard or soft lockup is detected, the watchdog prints a header at KERN_EMERG (<0>), followed by diagnostic details (modules, registers, and backtraces) at KERN_WARNING/KERN_DEFAULT (<4>) and KERN_INFO (<6>). If console_loglevel is quiet (<= 4), the console skips those <4>/<6> diagnostic messages before vpanic() has a chance to call console_verbose(). With the buddy detector, this leaves only the detector CPU's panic stack on the console and nothing about the locked CPU:

  <0>[ 1535.991833][    C6] watchdog: Watchdog detected hard LOCKUP on cpu 7
  <0>[ 1535.995960][    C6] Kernel panic - not syncing: Hard LOCKUP
  <4>[ 1535.995970][    C6] CPU: 6 UID: 0 PID: 0 Comm: swapper/6 ...
  <4>[ 1535.995997][    C6] Call trace:
  ...
  <4>[ 1535.996063][    C6]  watchdog_hardlockup_check+0x1e0/0x288
  <4>[ 1535.996075][    C6]  watchdog_buddy_check_hardlockup+0xb4/0xc0

Similar to commit 168e06f7937d ("kernel/hung_task.c: force console verbose before panic"), call console_verbose() before printing the lockup report so the diagnostic output is not suppressed.

---
 kernel/watchdog.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/watchdog.c +7 -1
index e5134ad7b663..64da2e500144 100644
@@ -255,6 +255,9 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 			return;
 	}
 
+	if (hardlockup_panic)
+		console_verbose();
+
 	/*
 	 * NOTE: we call printk_cpu_sync_get_irqsave() after printing
 	 * the lockup message. While it would be nice to serialize
@@ -880,6 +883,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
 		/* Start period for the next softlockup warning. */
 		update_report_ts();
 
+		thresh_count = duration / get_softlockup_thresh();
+		if (softlockup_panic && thresh_count >= softlockup_panic)
+			console_verbose();
+
 		printk_cpu_sync_get_irqsave(flags);
 		pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
 			smp_processor_id(), duration,
@@ -901,7 +908,6 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
 
 		add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
 		sys_info(softlockup_si_mask & ~SYS_INFO_ALL_BT);
-		thresh_count = duration / get_softlockup_thresh();
 
 		if (softlockup_panic && thresh_count >= softlockup_panic)
 			panic("softlockup: hung tasks");
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Tzung-Bi Shih

When a hard or soft lockup is detected, the watchdog prints a header at KERN_EMERG (<0>), followed by diagnostic details (modules, registers, and backtraces) at KERN_WARNING/KERN_DEFAULT (<4>) and KERN_INFO (<6>). If console_loglevel is quiet (<= 4), the console skips those <4>/<6> diagnostic messages before vpanic() has a chance to call console_verbose(). With the buddy detector, this leaves only the detector CPU's panic stack on the console and nothing about the locked CPU:

 <0>[ 1535.991833][    C6] watchdog: Watchdog detected hard LOCKUP on cpu 7
 <0>[ 1535.995960][    C6] Kernel panic - not syncing: Hard LOCKUP
 <4>[ 1535.995970][    C6] CPU: 6 UID: 0 PID: 0 Comm: swapper/6 ...
 <4>[ 1535.995997][    C6] Call trace:
 ...
 <4>[ 1535.996063][    C6]  watchdog_hardlockup_check+0x1e0/0x288
 <4>[ 1535.996075][    C6]  watchdog_buddy_check_hardlockup+0xb4/0xc0
Quoted 4 lines

Similar to commit 168e06f7937d ("kernel/hung_task.c: force console verbose before panic"), call console_verbose() before printing the lockup report so the diagnostic output is not suppressed.

I personally love this patch, it's like incredibly useful:

I tested it on two machines:

Quoted 20 lines

---
kernel/watchdog.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
kernel/watchdog.c +3 -0
index e5134ad7b663..64da2e500144 100644
@@ -255,6 +255,9 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
 			return;
 	}
 
+	if (hardlockup_panic)
+		console_verbose();
+
 	/*
 	 * NOTE: we call printk_cpu_sync_get_irqsave() after printing
 	 * the lockup message. While it would be nice to serialize

kernel/watchdog.c static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) · line 888

Quoted 6 lines
kernel/watchdog.c +3 -0
@@ -880,6 +883,10 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
 		/* Start period for the next softlockup warning. */
 		update_report_ts();
 
+		thresh_count = duration / get_softlockup_thresh();
+		if (softlockup_panic && thresh_count >= softlockup_panic)
+			console_verbose();

Makes sense.

kernel/watchdog.c static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer) · line 913

Quoted 13 lines
kernel/watchdog.c +1 -1
+
 		printk_cpu_sync_get_irqsave(flags);
 		pr_emerg("BUG: soft lockup - CPU#%d stuck for %us! [%s:%d]\n",
 			smp_processor_id(), duration,
@@ -901,7 +908,6 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
 
 		add_taint(TAINT_SOFTLOCKUP, LOCKDEP_STILL_OK);
 		sys_info(softlockup_si_mask & ~SYS_INFO_ALL_BT);
-		thresh_count = duration / get_softlockup_thresh();
 
 		if (softlockup_panic && thresh_count >= softlockup_panic)
 			panic("softlockup: hung tasks");

--- Thanks!
"I'm not a very positive person" - Linus torvalds

Reviewed-by on v1 1/1
#2 lore raw
In reply to Tzung-Bi Shih

Hi,

Quoted 18 lines · Tzung-Bi Shih

When a hard or soft lockup is detected, the watchdog prints a header at KERN_EMERG (<0>), followed by diagnostic details (modules, registers, and backtraces) at KERN_WARNING/KERN_DEFAULT (<4>) and KERN_INFO (<6>). If console_loglevel is quiet (<= 4), the console skips those <4>/<6> diagnostic messages before vpanic() has a chance to call console_verbose(). With the buddy detector, this leaves only the detector CPU's panic stack on the console and nothing about the locked CPU:

  <0>[ 1535.991833][    C6] watchdog: Watchdog detected hard LOCKUP on cpu 7
  <0>[ 1535.995960][    C6] Kernel panic - not syncing: Hard LOCKUP
  <4>[ 1535.995970][    C6] CPU: 6 UID: 0 PID: 0 Comm: swapper/6 ...
  <4>[ 1535.995997][    C6] Call trace:
  ...
  <4>[ 1535.996063][    C6]  watchdog_hardlockup_check+0x1e0/0x288
  <4>[ 1535.996075][    C6]  watchdog_buddy_check_hardlockup+0xb4/0xc0
Quoted 8 lines

Similar to commit 168e06f7937d ("kernel/hung_task.c: force console verbose before panic"), call console_verbose() before printing the lockup report so the diagnostic output is not suppressed.

---
 kernel/watchdog.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Reviewed-by on v1 1/1
#3 lore raw
In reply to Tzung-Bi Shih
Quoted 17 lines · Tzung-Bi Shih

When a hard or soft lockup is detected, the watchdog prints a header at KERN_EMERG (<0>), followed by diagnostic details (modules, registers, and backtraces) at KERN_WARNING/KERN_DEFAULT (<4>) and KERN_INFO (<6>). If console_loglevel is quiet (<= 4), the console skips those <4>/<6> diagnostic messages before vpanic() has a chance to call console_verbose(). With the buddy detector, this leaves only the detector CPU's panic stack on the console and nothing about the locked CPU:

  <0>[ 1535.991833][    C6] watchdog: Watchdog detected hard LOCKUP on cpu 7
  <0>[ 1535.995960][    C6] Kernel panic - not syncing: Hard LOCKUP
  <4>[ 1535.995970][    C6] CPU: 6 UID: 0 PID: 0 Comm: swapper/6 ...
  <4>[ 1535.995997][    C6] Call trace:
  ...
  <4>[ 1535.996063][    C6]  watchdog_hardlockup_check+0x1e0/0x288
  <4>[ 1535.996075][    C6]  watchdog_buddy_check_hardlockup+0xb4/0xc0
Quoted 5 lines

Similar to commit 168e06f7937d ("kernel/hung_task.c: force console verbose before panic"), call console_verbose() before printing the lockup report so the diagnostic output is not suppressed.

Looks good to me.

FWIW,

Reviewed-by on v1 1/1
#4 lore raw
In reply to Tzung-Bi Shih
Quoted 17 lines · Tzung-Bi Shih

When a hard or soft lockup is detected, the watchdog prints a header at KERN_EMERG (<0>), followed by diagnostic details (modules, registers, and backtraces) at KERN_WARNING/KERN_DEFAULT (<4>) and KERN_INFO (<6>). If console_loglevel is quiet (<= 4), the console skips those <4>/<6> diagnostic messages before vpanic() has a chance to call console_verbose(). With the buddy detector, this leaves only the detector CPU's panic stack on the console and nothing about the locked CPU:

  <0>[ 1535.991833][    C6] watchdog: Watchdog detected hard LOCKUP on cpu 7
  <0>[ 1535.995960][    C6] Kernel panic - not syncing: Hard LOCKUP
  <4>[ 1535.995970][    C6] CPU: 6 UID: 0 PID: 0 Comm: swapper/6 ...
  <4>[ 1535.995997][    C6] Call trace:
  ...
  <4>[ 1535.996063][    C6]  watchdog_hardlockup_check+0x1e0/0x288
  <4>[ 1535.996075][    C6]  watchdog_buddy_check_hardlockup+0xb4/0xc0
Quoted 5 lines

Similar to commit 168e06f7937d ("kernel/hung_task.c: force console verbose before panic"), call console_verbose() before printing the lockup report so the diagnostic output is not suppressed.

Just for record, this looks good to me:

Best Regards,
Petr