• P
    sched/core: Fix DEBUG_SPINLOCK annotation for rq->lock · 269d5992
    Peter Zijlstra 提交于
    Mark noticed that he had sporadic "spinlock recursion" warnings from
    the DEBUG_SPINLOCK code. Now rq->lock is special in that the owner
    changes in the middle of a context switch.
    
    It so happens that we fix up the lock.owner too late, @prev can run
    (remotely) the moment prev->on_cpu is cleared, this then allows @prev
    to again try and acquire this rq->lock and trigger this warning.
    
    So we have to switch lock.owner before clearing prev->on_cpu.
    
    Do this by moving the DEBUG_SPINLOCK annotation from after switch_to()
    to before switch_to() and collect all lockdep annotations there into
    prepare_lock_switch() to mirror the existing finish_lock_switch().
    Debugged-by: NMark Rutland <mark.rutland@arm.com>
    Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: NMark Rutland <mark.rutland@arm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: NIngo Molnar <mingo@kernel.org>
    269d5992
core.c 172.7 KB