Fine grain select locking.

Jeff Roberson jroberson at chesapeake.net
Tue Jul 3 06:21:13 UTC 2007


I have a diff which makes the following improvements to select:

1) Per-thread wait channel rather than global select wait channel.
2) Per-thread select lock.
3) Rescan after sleep scans only descriptors which have come active.
4) No exposed select internals.
5) selwakeuppri() works again.
6) No thread_lock()ing in select, no TDF_SELECT required.
7) No more collisions.

This is based on an approach from Alfred with some locking and rescan 
improvements by me.  It only required changing select users in cases where 
they assumed only one thread could select at a time.

The unfortunate cost of this patch is that a descriptor per select fd must 
be allocated to track individual threads.  This is what allows us to know 
which descriptor has fired an event and allows us to use per-thread 
locking etc.

The one thing I haven't fixed is netsmb and netncp which both have some 
wonky select implementation that could be replaced with kern_select(). 
That could be done seperately from this patch but is required for this to 
go in.

http://people.freebsd.org/~jeff/select.diff

Comments and suggestions welcome.

Thanks,
Jeff


More information about the freebsd-arch mailing list