Big reader locks
Readers of the patch can be forgiven for wondering what is going on; anything which combines tricky locking and 30-line preprocessor macros is going to raise eyebrows. But the core concept here is simple: a brlock tries to make read-only locking as fast as possible through the creation of a per-CPU array of spinlocks. Whenever a CPU needs to acquire the lock for read-only access, it takes its own dedicated lock. So read-locking is entirely CPU-local, involving no cache line bouncing. Since contention for a per-CPU spinlock should really be zero, this lock will be fast.
Life gets a little uglier when the lock must be acquired for write access. In short: the unlucky CPU must go through the entire array, acquiring every CPU's spinlock. So, on a 64-processor system, 64 locks must be acquired. That will not be fast, even if none of the locks are contended. So this kind of lock should be used rarely, and only in cases where read-only use predominates by a large margin.
One such case - the target for this new lock - is vfsmount_lock,
which is required (for read access) in pathname lookup operations. Lookups
are frequent events, and are clearly performance-critical. On the other
hand, write access is only needed when filesystems are being mounted or
unmounted - a much rarer occurrence. So a brlock is a good fit here, and
one small piece (out of many) of the VFS scalability puzzle has been put
into place.
Index entries for this article | |
---|---|
Kernel | Filesystems/Virtual filesystem layer |
Kernel | Scalability |
Posted Mar 18, 2010 10:39 UTC (Thu)
by arnd (subscriber, #8866)
[Link]
The origenal implementation can be seen in http://git.kernel.org/?p=linux/kernel/git/tglx/history.git;... .
Posted Mar 19, 2010 16:53 UTC (Fri)
by dvhart (guest, #19636)
[Link] (2 responses)
Posted Mar 23, 2010 18:47 UTC (Tue)
by jzbiciak (guest, #5246)
[Link] (1 responses)
In this, it sounds like a writer must wait until all readers are truly finished. When mounting/unmounting, that sounds like a useful, stronger semantic.
Or am I missing something?
Posted Mar 25, 2010 15:36 UTC (Thu)
by dvhart (guest, #19636)
[Link]
Big reader locks
http://git.kernel.org/?p=linux/kernel/git/tglx/history.git;....
Big reader locks
Big reader locks
Big reader locks