[PATCH] Warn when smp_call_function() is called with interrupts disabled
authorAndrew Morton <akpm@osdl.org>
Mon, 10 May 2004 07:04:03 +0000 (00:04 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 10 May 2004 07:04:03 +0000 (00:04 -0700)
commit43653667122796412010fc148891954d54812705
tree1fdf0a0b1454680660ffa3e183e22a176303603e
parent5805ad402642142b5a769e1553c4e45a52653efe
[PATCH] Warn when smp_call_function() is called with interrupts disabled

From: Keith Owens <kaos@sgi.com>

Almost every architecture has a comment above smp_call_function()

 * You must not call this function with disabled interrupts or from a
 * hardware interrupt handler or from a bottom half handler.

I have not seen any problems with calling smp_call_function() from a bottom
half handler, but calling it with interrupts disabled can definitely
deadlock.  This bug is hard to reproduce and even harder to debug.

CPU A                               CPU B
Disable interrupts
                                    smp_call_function()
                                    Take call_lock
                                    Send IPIs
                                    Wait for all cpus to acknowledge IPI
                                    CPU A has not responded, spin waiting
                                    for cpu A to respond, holding call_lock
smp_call_function()
Spin waiting for call_lock
Deadlock                            Deadlock

Change all smp_call_function() to WARN_ON(irqs_disabled()).  It should be
BUG_ON() but some buggy code like SCSI sg will break with BUG_ON, so just
warn for now.  Change it to BUG_ON after the buggy code has been fixed.
13 files changed:
arch/alpha/kernel/smp.c
arch/i386/kernel/smp.c
arch/i386/mach-voyager/voyager_smp.c
arch/ia64/kernel/smp.c
arch/mips/kernel/smp.c
arch/parisc/kernel/smp.c
arch/ppc/kernel/smp.c
arch/ppc64/kernel/smp.c
arch/s390/kernel/smp.c
arch/sh/kernel/smp.c
arch/sparc64/kernel/smp.c
arch/um/kernel/smp.c
arch/x86_64/kernel/smp.c