[RFC] sysctl locking

Suleiman Souhlal ssouhlal at FreeBSD.org
Wed Oct 13 14:02:01 PDT 2004


Hi,

On Oct 11, 2004, at 3:30 PM, Don Lewis wrote:
> There seems to be a lot of locking/unlocking overhead in the oid lookup
> and oid tree manipulation code.  Doing the traversals at each level of
> the tree without holding a lock for the entire time makes me nervous,
> though I can't point to any specific problem.  It might be better to
> just hold a single lock across then entire lookup, insertion, or
> deletion operation.

Thanks for your reply! I think you are right. It would also make the 
locking much simpler. However, there is the problem that sysctl 
handlers can sleep, so we shouldn't be holding a mutex when calling 
them..

> What happens if:
> 	thread A owns an oid
>
> 	thread B, which wants to delete the oid, goes to sleep to wait
> 	for the oid
>
> 	thread C wants the oid and goes to sleep
>
> 	thread A releases the oid and wakes up thread B
>
> 	thread B deletes the oid
>
> 	thread C does ???

I didn't think of this possibility. I guess I'll have to rethink the 
whole thing, whenever I find some time.

--
Suleiman Souhlal     | ssouhlal at vt.edu
The FreeBSD Project  | ssouhlal at FreeBSD.org



More information about the freebsd-arch mailing list