From: Alexander van Heukelum <heukelum@mailshack.com>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: Ingo Molnar <mingo@elte.hu>,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
vgoyal@redhat.com, hbabu@us.ibm.com, ebiederm@xmission.com,
tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
akpm@linux-foundation.org,
Alexander van Heukelum <heukelum@fastmail.fm>
Subject: [PATCH] x86: make oops_begin and oops_end equal
Date: Mon, 20 Oct 2008 17:08:34 +0200 [thread overview]
Message-ID: <20081020150834.GA26018@mailshack.com> (raw)
In-Reply-To: <20081020150731.GA25999@mailshack.com>
Mostly use the x86_64 version of oops_begin() and oops_end() on
i386 too. Changes to the original x86_64 version:
- move add_taint(TAINT_DIE) into oops_end()
- add a conditional crash_kexec() into oops_end()
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
arch/x86/kernel/dumpstack_32.c | 36 +++++++++++++++++++++---------------
arch/x86/kernel/dumpstack_64.c | 4 +++-
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index b361475..e45952b 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -289,35 +289,41 @@ static unsigned int die_nest_count;
unsigned __kprobes long oops_begin(void)
{
+ int cpu;
unsigned long flags;
oops_enter();
- if (die_owner != raw_smp_processor_id()) {
- console_verbose();
- raw_local_irq_save(flags);
- __raw_spin_lock(&die_lock);
- die_owner = smp_processor_id();
- die_nest_count = 0;
- bust_spinlocks(1);
- } else {
- raw_local_irq_save(flags);
+ /* racy, but better than risking deadlock. */
+ raw_local_irq_save(flags);
+ cpu = smp_processor_id();
+ if (!__raw_spin_trylock(&die_lock)) {
+ if (cpu == die_owner)
+ /* nested oops. should stop eventually */;
+ else
+ __raw_spin_lock(&die_lock);
}
die_nest_count++;
+ die_owner = cpu;
+ console_verbose();
+ bust_spinlocks(1);
return flags;
}
void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
{
- bust_spinlocks(0);
die_owner = -1;
+ bust_spinlocks(0);
+ die_nest_count--;
add_taint(TAINT_DIE);
- __raw_spin_unlock(&die_lock);
+ if (!die_nest_count)
+ /* Nest count reaches zero, release the lock. */
+ __raw_spin_unlock(&die_lock);
raw_local_irq_restore(flags);
-
- if (!regs)
+ if (!regs) {
+ oops_exit();
return;
-
+ }
if (kexec_should_crash(current))
crash_kexec(regs);
if (in_interrupt())
@@ -405,6 +411,7 @@ die_nmi(char *str, struct pt_regs *regs, int do_panic)
panic("Non maskable interrupt");
console_silent();
spin_unlock(&nmi_print_lock);
+ bust_spinlocks(0);
/*
* If we are in kernel we are probably nested up pretty bad
@@ -415,7 +422,6 @@ die_nmi(char *str, struct pt_regs *regs, int do_panic)
crash_kexec(regs);
}
- bust_spinlocks(0);
do_exit(SIGSEGV);
}
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 96a5db7..cd7b46b 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -461,6 +461,7 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
die_owner = -1;
bust_spinlocks(0);
die_nest_count--;
+ add_taint(TAINT_DIE);
if (!die_nest_count)
/* Nest count reaches zero, release the lock. */
__raw_spin_unlock(&die_lock);
@@ -469,6 +470,8 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
oops_exit();
return;
}
+ if (kexec_should_crash(current))
+ crash_kexec(regs);
if (in_interrupt())
panic("Fatal exception in interrupt");
if (panic_on_oops)
@@ -496,7 +499,6 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
return 1;
show_registers(regs);
- add_taint(TAINT_DIE);
/* Executive summary in case the oops scrolled away */
printk(KERN_ALERT "RIP ");
printk_address(regs->ip, 1);
--
1.5.4.3
next prev parent reply other threads:[~2008-10-20 15:10 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 21:00 [PATCH] kexec: fix hang on i386 when panic occurs while console_sem is held Neil Horman
2008-10-20 12:13 ` Ingo Molnar
2008-10-20 13:42 ` Neil Horman
2008-10-20 15:07 ` [PATCH] x86, dumpstack: some more unification Alexander van Heukelum
2008-10-20 15:08 ` Alexander van Heukelum [this message]
2008-10-20 15:11 ` [PATCH] x86, dumpstack: make die and die_nmi equal Alexander van Heukelum
2008-10-21 14:59 ` Neil Horman
2008-10-22 10:00 ` [PATCH 0/7] x86, dumpstack: unify oops_begin, oops_end, die_nmi and die Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 1/7] i386, dumpstack: Move crash_kexec before bust_spinlocks(0) in oops_end Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 2/7] x86, dumpstack: let signr=0 signal no do_exit Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 3/7] x86_64, dumpstack: move kexec_crash from __die to oops_end Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 4/7] x86, dumpstack: always call oops_exit from oops_end Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 5/7] i386, dumpstack: use x86_64's method to account die_nest_count Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 6/7] i386, dumpstack: use oops_begin/oops_end in die_nmi Alexander van Heukelum
2008-10-22 10:00 ` [PATCH 7/7] i386, dumpstack: unify die() Alexander van Heukelum
2008-10-22 13:37 ` Neil Horman
2008-10-22 12:36 ` [PATCH 6/7] i386, dumpstack: use oops_begin/oops_end in die_nmi Neil Horman
2008-10-22 11:18 ` [PATCH 5/7] i386, dumpstack: use x86_64's method to account die_nest_count Neil Horman
2008-10-22 11:14 ` [PATCH 4/7] x86, dumpstack: always call oops_exit from oops_end Neil Horman
2008-10-22 11:11 ` [PATCH 3/7] x86_64, dumpstack: move kexec_crash from __die to oops_end Neil Horman
2008-10-22 11:01 ` [PATCH 2/7] x86, dumpstack: let signr=0 signal no do_exit Neil Horman
2008-10-22 10:49 ` [PATCH 1/7] i386, dumpstack: Move crash_kexec before bust_spinlocks(0) in oops_end Neil Horman
2008-10-21 14:45 ` [PATCH] x86: make oops_begin and oops_end equal Neil Horman
2008-10-22 10:18 ` Alexander van Heukelum
2008-10-22 10:45 ` Neil Horman
2008-10-22 12:02 ` Ingo Molnar
2008-10-22 19:19 ` Neil Horman
2008-10-23 9:22 ` Alexander van Heukelum
2008-10-20 16:51 ` [PATCH] x86, dumpstack: some more unification Neil Horman
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=20081020150834.GA26018@mailshack.com \
--to=heukelum@mailshack.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=hbabu@us.ibm.com \
--cc=heukelum@fastmail.fm \
--cc=hpa@zytor.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=nhorman@tuxdriver.com \
--cc=tglx@linutronix.de \
--cc=vgoyal@redhat.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox