• Andrew Morton's avatar
    [PATCH] Warn when smp_call_function() is called with interrupts disabled · 43653667
    Andrew Morton authored
    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.
    43653667
smp.c 10 KB