git: kernel - Spiff up locks a bit

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Dec 5 15:13:20 PST 2016


commit cff27badea2d316c1dd7581302d824e7a49fa9f3
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Dec 5 15:07:43 2016 -0800

    kernel - Spiff up locks a bit
    
    * Do a little optimization of _spin_lock_contested().  The critical path
      is able to avoid two atomic ops in the initialization portion of the
      contested path.
    
    * Optimize _spin_lock_shared_contested() to use atomic_fetchadd_long()
      to add a shared-lock count instead of atomic_cmpset_long().  Shared
      spinlocks are used heavily and this will prevent a lot of unnecessary
      spinning when many cpus are using the same lock at the same time.
    
    * Hold fdp->fd_spin across fdp->fd_cdir and fdp->fd_ncdir modifications.
      This completes other work which caches fdp->fd_ncdir and avoids having
      to obtain the spin-lock when the cache matches.
    
    Discussed-with: Mateusz Guzik (mjg_)

Summary of changes:
 sys/kern/kern_spinlock.c | 13 ++++++++-----
 sys/kern/lwkt_token.c    |  7 +++----
 sys/kern/vfs_syscalls.c  |  8 ++++++--
 sys/sys/spinlock2.h      | 13 ++++++++-----
 4 files changed, 25 insertions(+), 16 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/cff27badea2d316c1dd7581302d824e7a49fa9f3


-- 
DragonFly BSD source repository


More information about the Commits mailing list