• S
    lockdep: Print a nicer description for irq lock inversions · 3003eba3
    Steven Rostedt 提交于
    Locking order inversion due to interrupts is a subtle problem.
    
    When an irq lockiinversion discovered by lockdep it currently
    reports something like:
    
    [ INFO: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected ]
    
    ... and then prints out the locks that are involved, as back traces.
    
    Judging by lkml feedback developers were routinely confused by what
    a HARDIRQ->safe to unsafe issue is all about, and sometimes even
    blew it off as a bug in lockdep.
    
    It is not obvious when lockdep prints this message about a lock that
    is never taken in interrupt context.
    
    After explaining the problems that lockdep is reporting, I
    decided to add a description of the problem in visual form. Now
    the following is shown:
    
     ---
    other info that might help us debug this:
    
     Possible interrupt unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock(lockA);
                                   local_irq_disable();
                                   lock(&rq->lock);
                                   lock(lockA);
      <Interrupt>
        lock(&rq->lock);
    
     *** DEADLOCK ***
    
     ---
    
    The above is the case when the unsafe lock is taken while
    holding a lock taken in irq context. But when a lock is taken
    that also grabs a unsafe lock, the call chain is shown:
    
     ---
    other info that might help us debug this:
    
    Chain exists of:
      &rq->lock --> lockA --> lockC
    
     Possible interrupt unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock(lockC);
                                   local_irq_disable();
                                   lock(&rq->lock);
                                   lock(lockA);
      <Interrupt>
        lock(&rq->lock);
    
     *** DEADLOCK ***
    Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
    Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20110421014259.132728798@goodmis.orgSigned-off-by: NIngo Molnar <mingo@elte.hu>
    3003eba3
lockdep.c 93.4 KB