• Waiman Long's avatar
    locking/lockdep: Fix debug_locks off performance problem · 117d5fbd
    Waiman Long authored
    [ Upstream commit 9506a742 ]
    
    It was found that when debug_locks was turned off because of a problem
    found by the lockdep code, the system performance could drop quite
    significantly when the lock_stat code was also configured into the
    kernel. For instance, parallel kernel build time on a 4-socket x86-64
    server nearly doubled.
    
    Further analysis into the cause of the slowdown traced back to the
    frequent call to debug_locks_off() from the __lock_acquired() function
    probably due to some inconsistent lockdep states with debug_locks
    off. The debug_locks_off() function did an unconditional atomic xchg
    to write a 0 value into debug_locks which had already been set to 0.
    This led to severe cacheline contention in the cacheline that held
    debug_locks.  As debug_locks is being referenced in quite a few different
    places in the kernel, this greatly slow down the system performance.
    
    To prevent that trashing of debug_locks cacheline...
    117d5fbd
debug_locks.c 1.17 KB