Skip to content
  • Alex Shi's avatar
    rwsem: Implement writer lock-stealing for better scalability · ce6711f3
    Alex Shi authored
    Commit 5a505085 ("mm/rmap: Convert the struct anon_vma::mutex
    to an rwsem") changed struct anon_vma::mutex to an rwsem, which
    caused aim7 fork_test performance to drop by 50%.
    
    Yuanhan Liu did the following excellent analysis:
    
        https://lkml.org/lkml/2013/1/29/84
    
    
    
    and found that the regression is caused by strict, serialized,
    FIFO sequential write-ownership of rwsems. Ingo suggested
    implementing opportunistic lock-stealing for the front writer
    task in the waitqueue.
    
    Yuanhan Liu implemented lock-stealing for spinlock-rwsems,
    which indeed recovered much of the regression - confirming
    the analysis that the main factor in the regression was the
    FIFO writer-fairness of rwsems.
    
    In this patch we allow lock-stealing to happen when the first
    waiter is also writer. With that change in place the
    aim7 fork_test performance is fully recovered on my
    Intel NHM EP, NHM EX, SNB EP 2S and 4S test-machines.
    
    Reported-by: default avatar <lkp@linux.intel.com>
    Reported-by: default avatarYuanhan Liu <yuanhan.liu@linux.intel.com>
    Signed-off-by: default avatarAlex Shi <alex.shi@intel.com>
    Cc: David Howells <dhowells@redhat.com>
    Cc: Michel Lespinasse <walken@google.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Anton Blanchard <anton@samba.org>
    Cc: Arjan van de Ven <arjan@linux.intel.com>
    Cc: paul.gortmaker@windriver.com
    Link: https://lkml.org/lkml/2013/1/29/84
    Link: http://lkml.kernel.org/r/1360069915-31619-1-git-send-email-alex.shi@intel.com
    
    
    [ Small stylistic fixes, updated changelog. ]
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    ce6711f3