kernel - Spiff up locks a bit
commitcff27badea2d316c1dd7581302d824e7a49fa9f3
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 5 Dec 2016 23:07:43 +0000 (5 15:07 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 5 Dec 2016 23:07:43 +0000 (5 15:07 -0800)
tree0a1c535b8001c7f0997b4fcc5cdc79cecc64c01c
parent43fdf49008ec87f6742547d87923237e86fa3b56
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_)
sys/kern/kern_spinlock.c
sys/kern/lwkt_token.c
sys/kern/vfs_syscalls.c
sys/sys/spinlock2.h