Skip to content

Commit e4955cf

Browse files
heukelumIngo Molnar
authored andcommitted
i386, dumpstack: use x86_64's method to account die_nest_count
oops_begin/oops_end should always be used in pairs. On x86_64 oops_begin increments die_nest_count, and oops_end decrements die_nest_count. Doing this makes oops_begin and oops_end equal to the x86_64 versions. Signed-off-by: Alexander van Heukelum <[email protected]> Acked-by: Neil Horman <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 10b14cb commit e4955cf

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

arch/x86/kernel/dumpstack_32.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,24 @@ static unsigned int die_nest_count;
289289

290290
unsigned __kprobes long oops_begin(void)
291291
{
292+
int cpu;
292293
unsigned long flags;
293294

294295
oops_enter();
295296

296-
if (die_owner != raw_smp_processor_id()) {
297-
console_verbose();
298-
raw_local_irq_save(flags);
299-
__raw_spin_lock(&die_lock);
300-
die_owner = smp_processor_id();
301-
die_nest_count = 0;
302-
bust_spinlocks(1);
303-
} else {
304-
raw_local_irq_save(flags);
297+
/* racy, but better than risking deadlock. */
298+
raw_local_irq_save(flags);
299+
cpu = smp_processor_id();
300+
if (!__raw_spin_trylock(&die_lock)) {
301+
if (cpu == die_owner)
302+
/* nested oops. should stop eventually */;
303+
else
304+
__raw_spin_lock(&die_lock);
305305
}
306306
die_nest_count++;
307+
die_owner = cpu;
308+
console_verbose();
309+
bust_spinlocks(1);
307310
return flags;
308311
}
309312

@@ -315,13 +318,15 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
315318
bust_spinlocks(0);
316319
die_owner = -1;
317320
add_taint(TAINT_DIE);
318-
__raw_spin_unlock(&die_lock);
321+
die_nest_count--;
322+
if (!die_nest_count)
323+
/* Nest count reaches zero, release the lock. */
324+
__raw_spin_unlock(&die_lock);
319325
raw_local_irq_restore(flags);
320-
321326
oops_exit();
327+
322328
if (!signr)
323329
return;
324-
325330
if (in_interrupt())
326331
panic("Fatal exception in interrupt");
327332
if (panic_on_oops)

0 commit comments

Comments
 (0)