What about separating locks and data?
Posted Jan 4, 2013 17:04 UTC (Fri) by corbet
In reply to: What about separating locks and data?
Parent article: Improving ticket spinlocks
I'd pondered that a bit as I was writing the article. It would be painful.
If you move the lock out of the structure it is protecting, you have to allocate it in a separate step. The allocation could maybe be hidden in spin_lock_init(), but the freeing would require explicit action (in vast numbers of call sites) or some severe magic. Probably don't want to do that.
Regardless of whether the lock is relocated or not, the only way to avoid cache problems with surrounding data is to expand the lock to fill an entire cache line. That would bloat spinlocks considerably, and there are a lot of spinlocks in a running kernel. That overhead would hurt; among other things, the bloat, alone, would slow things by causing additional cache utilization.
Maybe I'm missing something (I often do), but, from what I can tell, trying to isolate the locks isn't really a viable solution.
to post comments)