Re: Read/write locks

Linus Torvalds (torvalds@transmeta.com)
21 Sep 1997 20:57:28 GMT


In article <199709210831.EAA29808@jenolan.rutgers.edu>,
David S. Miller <davem@jenolan.rutgers.edu> wrote:
>
>Anyways, with that I still have one final gripe with the upgrader
>scheme. It makes the locks fatter, and Linux already blows the L2
>cache to shreds on most platforms as it is...

No, for spinlocks, the upgrade lock doesn't get any fatter at all, it
should fit right in with the current write-lock scheme (which I still
consider extremely clever of me, I haven't seen others do it that way).

I _think_ the only thing you'd need to do to distinguish a write lock
from an update lock is that the update-lock doesn't need to wait for
readers to go away (you do that only if/when you decide to really
upgrade to a real write lock).

That approach would make the update lock lock out any new readers, but
at least it is a very simple implementation, and to some degree it can
be considered a feature (we'd prioritize updaters over readers -
something that may or may not be what we want to do anyway).

I don't know how many places would actually benefit from an update
spinlock, but if it really is as simple as it looks to be I wouldn't
need much reason to implement them.

Linus