blockgroup_lock: hashed spinlocks for ext2 and ext3
A message that is not in the archive (sent off-list or not yet received): [email protected]
On Sun, 2003-04-13 at 12:00, Linux Kernel Mailing List wrote:
[....]
Quoted 6 lines
These locks are actually fairly generic. However I presented it as something which is specific to ext2 and ext3 so that people wouldn't go using them all over the place. They consume a lot of storage.
Review
Quoted 8 lines
(quoted diff) +8
-0+ +struct bgl_lock { + spinlock_t lock; +} ____cacheline_aligned_in_smp; + +struct blockgroup_lock { + struct bgl_lock locks[NR_BG_LOCKS]; +};
Why don't you use per_cpu data for this ? It can be indexed as well with per_cpu() and it would safe a lot of space because the padding would not be all wasted. If you want more than NR_CPUS locks it could be done using a simple two level index scheme.
-Andi
Quoted 14 lines · Andi Kleen
Review
Quoted 9 lines
(quoted diff) +8
-0+ +struct bgl_lock { + spinlock_t lock; +} ____cacheline_aligned_in_smp; + +struct blockgroup_lock { + struct bgl_lock locks[NR_BG_LOCKS]; +};Why don't you use
per_cpudata for this ? It can be indexed as well withper_cpu()and it would safe a lot of space because the padding would not be all wasted. If you want more thanNR_CPUSlocks it could be done using a simple two level index scheme.
per_cpu data is statically allocated, at compile-time. And it doesn't work for modules.
These hashed locks need to be dynamically allocated (one per filesystem) and they need to work from modules.
And this hashed lock is not a per-cpu thing. (No locks are!) It just uses NR_CPUS to decide how big the hash should be.
Quoted 5 lines
per_cpudata is statically allocated, at compile-time. And it doesn't work for modules.These hashed locks need to be dynamically allocated (one per filesystem) and they need to work from modules.
Ok.
Quoted 3 lines
And this hashed lock is not a per-cpu thing. (No locks are!) It just uses
NR_CPUSto decide how big the hash should be.
Isn't that what the IBM kmalloc_per_cpu() was for ? (I think the patch was from Dipankar)
-Andi
Quoted 7 lines · Andi Kleen
Quoted 4 lines
And this hashed lock is not a per-cpu thing. (No locks are!) It just uses
NR_CPUSto decide how big the hash should be.Isn't that what the IBM
kmalloc_per_cpu()was for ? (I think the patch was from Dipankar)
This is not a per-cpu data structure.
It is a hashed spinlock which uses NR_CPUS as a sizing hint.