[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: locking order between softnet_lock and the kernel lock
- Subject: Re: locking order between softnet_lock and the kernel lock
- From: David Laight <david%l8s.co.uk@localhost>
- Date: Tue, 27 Mar 2012 08:13:22 +0100
On Mon, Mar 26, 2012 at 10:09:17PM -0400, Mouse wrote:
> > Generally speaking, I don't think we require locks to be released in
> > order - though of course it is good practice.
> If you're going to release them all, then, unless the locks themselves
> interact somehow (as someone said was the case with kernel-lock, I
> think), then you can release in whatever order you please - _provided_
> that you release them all without reacquiring any until you've finished
> I do, however, agree that proper nesting is usually a good idea. Just
> not for correctness reasons.
There are some very good reasons to allow locks be released in any order.
Consider some list/hash/tree of items, lookup sequence:
1) take global lock
2) find item
3) lock item
4) release global lock
Otherwise you have to perform a dance with a reference count.
(Or keep everything locked for much longer.)
Clearly you can't reacquire the global lock (eg to remove an item)
but that isn't necessarily a problem as items can just be marked
'deleted' and pruned from the global structure at a later date
(eg on insert).
There are issues with correct restoring of SPL levels. I think netbsd
stores the saved spl in the kernel thread (not the mutex) and restores
it when the last mutex is released - this isn't completely optimal!
David Laight: david%l8s.co.uk@localhost
Main Index |
Thread Index |