[PATCH 2/21] KGDB: Add clocksource_touch_watchdog

From: Jason Wessel
Date: Mon Oct 15 2007 - 14:36:08 EST


Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
clocksource_watchdog.patch

From: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>
CC: tglx@xxxxxxxxxxxxx
Subject: [PATCH] Add clocksource_touch_watchdog

Add a call to the clocksource watchdog API for touching the watchdog
such that the watchdog does not trip on a context resume from a kernel
debugger.

Add in the hooks to KGDB to make use of the API.

Original implementation by Konstantin Baydarov <kbaidarov@xxxxxxxxxxxxx>

Signed-off-by: Konstantin Baydarov <kbaidarov@xxxxxxxxxxxxx>
Signed-off-by: Jason Wessel <jason.wessel@xxxxxxxxxxxxx>

---
include/linux/clocksource.h | 1 +
kernel/kgdb.c | 4 ++++
kernel/time/clocksource.c | 12 ++++++++++++
3 files changed, 17 insertions(+)

--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -218,6 +218,7 @@ extern int clocksource_register(struct c
extern struct clocksource* clocksource_get_next(void);
extern void clocksource_change_rating(struct clocksource *cs, int rating);
extern void clocksource_resume(void);
+extern void clocksource_touch_watchdog(void);

#ifdef CONFIG_GENERIC_TIME_VSYSCALL
extern void update_vsyscall(struct timespec *ts, struct clocksource *c);
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -51,6 +51,7 @@
#include <linux/sched.h>
#include <linux/pid_namespace.h>
#include <asm/byteorder.h>
+#include <linux/clocksource.h>

extern int pid_max;
/* How many times to count all of the waiting CPUs */
@@ -662,6 +663,7 @@ static void kgdb_wait(struct pt_regs *re
/* Signal the master processor that we are done */
atomic_set(&procindebug[processor], 0);
spin_unlock(&slavecpulocks[processor]);
+ clocksource_touch_watchdog();
local_irq_restore(flags);
}
#endif
@@ -1002,6 +1004,7 @@ int kgdb_handle_exception(int ex_vector,
atomic_read(&cpu_doing_single_step) != procid) {
atomic_set(&debugger_active, 0);
atomic_set(&kgdb_sync, -1);
+ clocksource_touch_watchdog();
local_irq_restore(flags);
goto acquirelock;
}
@@ -1549,6 +1552,7 @@ default_handle:
/* Free debugger_active */
atomic_set(&debugger_active, 0);
atomic_set(&kgdb_sync, -1);
+ clocksource_touch_watchdog();
local_irq_restore(flags);

return error;
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -226,6 +226,18 @@ void clocksource_resume(void)
}

/**
+ * clocksource_touch_watchdog - Update watchdog
+ *
+ * Update the watchdog after exception contexts such as kgdb so as not
+ * to incorrectly trip the watchdog.
+ *
+ */
+void clocksource_touch_watchdog(void)
+{
+ clocksource_resume_watchdog();
+}
+
+/**
* clocksource_get_next - Returns the selected clocksource
*
*/