git: kernel - Optimize struct uidinfo

Matthew Dillon dillon at
Mon Oct 16 11:30:38 PDT 2017

commit 233a815dcfe9f7d1ecc7c9186718b9389fc821f2
Author: Matthew Dillon <dillon at>
Date:   Sun Oct 15 11:25:21 2017 -0700

    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
    Suggested-by: mjg__

Summary of changes:
 sys/kern/kern_lockf.c    |  13 ++---
 sys/kern/kern_resource.c | 129 +++++++++++++++++++----------------------------
 sys/sys/resourcevar.h    |   2 +-
 3 files changed, 56 insertions(+), 88 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list