LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Jason Wessel <jason.wessel@windriver.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
kgdb-bugreport@lists.sourceforge.net
Subject: [PATCH] beautification of debugger_active usage
Date: Wed, 06 Feb 2008 13:15:17 +0100 [thread overview]
Message-ID: <47A9A4D5.4030200@siemens.com> (raw)
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;
next reply other threads:[~2008-02-06 12:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-06 12:15 Jan Kiszka [this message]
2008-02-06 12:25 ` [Kgdb-bugreport] " Jason Wessel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47A9A4D5.4030200@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--subject='Re: [PATCH] beautification of debugger_active usage' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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).