kernel - Optimize struct uidinfo
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 15 Oct 2017 18:25:21 +0000 (11:25 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 16 Oct 2017 18:30:23 +0000 (11:30 -0700)
commit233a815dcfe9f7d1ecc7c9186718b9389fc821f2
treeaaa1a470ae0b7d59ee06b73ad9eace4a1610a2ca
parent08abdbfcc7c1f8d3e9dcb8464b0cb6be3054bfa0
kernel - Optimize struct uidinfo

* Refactor struct uidinfo.  Use atomic ops for ui_posixlocks
  and ui_proccnt.  They were already being used for ui_openfiles
  and ui_ref.

* Refactor ui_ref a bit to improve the drop code.  Use a cute
  trick for the transition.  When we transition to 0 we allow
  ui_ref to actually go to 0, and then do an independent lookup
  of the uid with the hash table spinlock to conditionally free
  it if it remains 0.

  This allows us to completely avoid using atomic_cmpset_int(),
  which can be seriously inefficient due to races in SMP
  environments.

Suggested-by: mjg__
sys/kern/kern_lockf.c
sys/kern/kern_resource.c
sys/sys/resourcevar.h