LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] beautification of debugger_active usage
@ 2008-02-06 12:15 Jan Kiszka
  2008-02-06 12:25 ` [Kgdb-bugreport] " Jason Wessel
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2008-02-06 12:15 UTC (permalink / raw)
  To: Jason Wessel, Linux Kernel Mailing List, kgdb-bugreport

Just a beautification of using debugger_active for checking the debugger
state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

---
 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Kgdb-bugreport] [PATCH] beautification of debugger_active usage
  2008-02-06 12:15 [PATCH] beautification of debugger_active usage Jan Kiszka
@ 2008-02-06 12:25 ` Jason Wessel
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wessel @ 2008-02-06 12:25 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Linux Kernel Mailing List, kgdb-bugreport

Jan Kiszka wrote:
> Just a beautification of using debugger_active for checking the debugger
> state.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>
> ---
>  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(-)
>
>   
committed to:
http://git.kernel.org/?p=linux/kernel/git/jwessel/linux-2.6-kgdb.git;a=shortlog;h=kgdb_2.6.25

Jason.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-06 12:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-06 12:15 [PATCH] beautification of debugger_active usage Jan Kiszka
2008-02-06 12:25 ` [Kgdb-bugreport] " Jason Wessel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).