[PATCH] beautification of debugger_active usage
From: Jan Kiszka
Date: Wed Feb 06 2008 - 07:15:59 EST
Just a beautification of using debugger_active for checking the debugger
state.
Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
arch/x86/kernel/kgdb.c | 6 +++---
include/linux/kgdb.h | 7 ++++++-
kernel/kgdb.c | 8 ++++----
kernel/sched.c | 7 +------
4 files changed, 14 insertions(+), 14 deletions(-)
Index: b/arch/x86/kernel/kgdb.c
===================================================================
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -442,14 +442,14 @@ static int kgdb_notify(struct notifier_b
switch (cmd) {
case DIE_NMI:
- if (atomic_read(&debugger_active)) {
+ if (kgdb_active()) {
/* KGDB CPU roundup */
kgdb_nmihook(raw_smp_processor_id(), regs);
return NOTIFY_STOP;
}
return NOTIFY_DONE;
case DIE_NMI_IPI:
- if (atomic_read(&debugger_active)) {
+ if (kgdb_active()) {
/* KGDB CPU roundup */
if (kgdb_nmihook(raw_smp_processor_id(), regs))
return NOTIFY_DONE;
@@ -457,7 +457,7 @@ static int kgdb_notify(struct notifier_b
}
return NOTIFY_DONE;
case DIE_NMIWATCHDOG:
- if (atomic_read(&debugger_active)) {
+ if (kgdb_active()) {
/* KGDB CPU roundup */
kgdb_nmihook(raw_smp_processor_id(), regs);
return NOTIFY_STOP;
Index: b/include/linux/kgdb.h
===================================================================
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -285,8 +285,13 @@ int kgdb_nmihook(int cpu, void *regs);
extern int debugger_step;
extern atomic_t debugger_active;
+static inline int kgdb_active(void)
+{
+ return (atomic_read(&debugger_active) != 0);
+}
+
#else /* !CONFIG_KGDB */
-static const atomic_t debugger_active = ATOMIC_INIT(0);
+#define kgdb_active() 0
#endif /* !CONFIG_KGDB */
#endif /* _KGDB_H_ */
Index: b/kernel/kgdb.c
===================================================================
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -774,7 +774,7 @@ static void kgdb_wait(struct pt_regs *re
* gaurd in case the master CPU had not been selected if
* this was an entry via nmi.
*/
- while (!atomic_read(&debugger_active))
+ while (!kgdb_active())
cpu_relax();
/* Wait till master CPU goes completely into the debugger. */
@@ -1901,7 +1901,7 @@ int kgdb_nmihook(int cpu, void *regs)
static int
kgdb_panic_notify(struct notifier_block *self, unsigned long cmd, void *ptr)
{
- if (atomic_read(&debugger_active) != 0) {
+ if (kgdb_active()) {
printk(KERN_ERR "KGDB: Cannot handle panic while"
"debugger active\n");
dump_stack();
@@ -1923,7 +1923,7 @@ void kgdb_console_write(struct console *
/* If we're debugging, or KGDB has not connected, don't try
* and print. */
- if (!kgdb_connected || atomic_read(&debugger_active) != 0)
+ if (!kgdb_connected || kgdb_active())
return;
local_irq_save(flags);
@@ -2104,7 +2104,7 @@ kgdb_notify_reboot(struct notifier_block
* If we're debugging, or KGDB has not connected, don't try
* and print:
*/
- if (!kgdb_connected || atomic_read(&debugger_active) != 0)
+ if (!kgdb_connected || kgdb_active())
return 0;
if (code == SYS_RESTART || code == SYS_HALT || code == SYS_POWER_OFF) {
Index: b/kernel/sched.c
===================================================================
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7264,12 +7264,7 @@ void __might_sleep(char *file, int line)
#ifdef in_atomic
static unsigned long prev_jiffy; /* ratelimiting */
-#ifdef CONFIG_KGDB
- if (atomic_read(&debugger_active))
- return;
-#endif
-
- if ((in_atomic() || irqs_disabled()) &&
+ if ((in_atomic() || irqs_disabled()) && !kgdb_active() &&
system_state == SYSTEM_RUNNING && !oops_in_progress) {
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
return;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/