Skip to contentSkip to conversation

KGDB: Soft lockup fixes to kgdb core

PATCH In review Jason Wessel 1 participant 1 message Oct 15, 2007 KGDB / KDB /debug_core

lore
Share & tools
lore

Jason Wessel

author maintainer
#0 lore raw

PATCH 3/21 KGDB: Soft lockup fixes to kgdb core

softlockup.patch

From: Jason Wessel <[email protected]>
Subject: [PATCH] Soft lockup fixes to kgdb core

Modify the softlockup code not to trap when the debugger exits after having had the system running with the interrupts off for more than the number of cycles that trip the softlockup detection.

---
 include/linux/kgdb.h |    1 +
 kernel/kgdb.c        |    4 ++++
 kernel/softlockup.c  |    9 +++++++++
 3 files changed, 14 insertions(+)
include/linux/kgdb.h +1 -0
@@ -45,6 +45,7 @@ extern struct tasklet_struct kgdb_taskle
 
 extern atomic_t kgdb_setting_breakpoint;
 extern atomic_t cpu_doing_single_step;
+extern int kgdb_softlock_skip[NR_CPUS];
 
 extern struct task_struct *kgdb_usethread, *kgdb_contthread;
 
kernel/kgdb.c +4 -0
@@ -136,6 +136,7 @@ struct debuggerinfo_struct {
 
 /* to keep track of the CPU which is doing the single stepping*/
 atomic_t cpu_doing_single_step = ATOMIC_INIT(-1);
+int kgdb_softlock_skip[NR_CPUS];
 
 /* reboot notifier block */
 static struct notifier_block kgdb_reboot_notifier = {
@@ -664,6 +665,7 @@ static void kgdb_wait(struct pt_regs *re
 	atomic_set(&procindebug[processor], 0);
 	spin_unlock(&slavecpulocks[processor]);
 	clocksource_touch_watchdog();
+	kgdb_softlock_skip[processor] = 1;
 	local_irq_restore(flags);
 }
 #endif
@@ -1005,6 +1007,7 @@ int kgdb_handle_exception(int ex_vector,
 		atomic_set(&debugger_active, 0);
 		atomic_set(&kgdb_sync, -1);
 		clocksource_touch_watchdog();
+		kgdb_softlock_skip[procid] = 1;
 		local_irq_restore(flags);
 		goto acquirelock;
 	}
@@ -1553,6 +1556,7 @@ default_handle:
 	atomic_set(&debugger_active, 0);
 	atomic_set(&kgdb_sync, -1);
 	clocksource_touch_watchdog();
+	kgdb_softlock_skip[processor] = 1;
 	local_irq_restore(flags);
 
 	return error;
kernel/softlockup.c +9 -0
@@ -14,6 +14,7 @@
 #include <linux/kthread.h>
 #include <linux/notifier.h>
 #include <linux/module.h>
+#include <linux/kgdb.h>
 
 static DEFINE_SPINLOCK(print_lock);
 
@@ -47,6 +48,10 @@ static unsigned long get_timestamp(void)
 
 void touch_softlockup_watchdog(void)
 {
+#ifdef CONFIG_KGDB
+	if (unlikely(kgdb_softlock_skip[smp_processor_id()]))
+		kgdb_softlock_skip[smp_processor_id()] = 0;
+#endif
 	__raw_get_cpu_var(touch_timestamp) = get_timestamp();
 }
 EXPORT_SYMBOL(touch_softlockup_watchdog);
@@ -99,6 +104,10 @@ void softlockup_tick(void)
 
 	/* Warn about unreasonable 10+ seconds delays: */
 	if (now > (touch_timestamp + 10)) {
+#ifdef CONFIG_KGDB
+		if (unlikely(kgdb_softlock_skip[this_cpu]))
+			return;
+#endif
 		per_cpu(print_timestamp, this_cpu) = touch_timestamp;
 
 		spin_lock(&print_lock);