lockless file descriptor lookup

John Baldwin jhb at freebsd.org
Wed May 13 14:27:29 UTC 2009

On Monday 11 May 2009 11:32:17 pm Jeff Roberson wrote:
> http://people.freebsd.org/~jeff/locklessfd.diff
> This patch implements a lockless lookup path for file descriptors.  The 
> meat of the algorithm is in fget_unlocked().  This returns a referenced 
> file descriptor, unlike fget_locked().  In the common case this reduces 
> the number of atomics required for fget() while allowing for lookups to 
> proceed concurrently with modifications to the table and preventing 
> preemption from causing context switches.

Looks good.  My only comment would be to not remove the 'hold' comment 
completely from _fget(), but instead say that it always returns a refcount 
that must be dropped.  Basically:

* The file's refcount will be bumped on return.  It should be dropped
* with fdrop().

or something like that in place of the old paragraph about the 'hold' 

John Baldwin

More information about the freebsd-arch mailing list