Re: [PATCH v8 15/19] locking/rwsem: Adaptive disabling of reader optimistic spinning
From: Waiman Long
Date: Wed Jun 05 2019 - 14:17:51 EST
On 6/4/19 2:21 PM, Waiman Long wrote:
> On 6/4/19 2:14 PM, Peter Zijlstra wrote:
>>> I worked on this owner merging patch mainly to alleviate the need to use
>>> cmpxchg for reader lock. cmpxchg_double() is certainly one possible
>>> solution though it won't work on older CPUs. We can have a config option
>>> to use cmpxchg_double as it may increase the size of other structures
>>> that embedded rwsem and impose additional alignment constraint.
>> cmpxchg8b was introduced with the Pentium (for PAE IIRC, it enabled
>> atomic 64bit PTEs, but Linux never used it for that) and every Intel/AMD
>> thereafter has had it. AFAIK there's no x86_64 chip without cmpxchg16b.
> Thank for the clarification. I actually didn't check when cmpxch8b was
> introduced. I know it is a bit slower than regular cmpxchg. So we may
> still need to do some performance analysis to see how it compares with
> my current approach.
Using cmpxchg_double is actually more risky than I thought. I have been
trying to try to use cmpxchg_double for down_write, but I kept getting
kernel panics because the rwsem wasn't 16b-aligned. As rwsem is embedded
in quite a large number of structures, they all have to align properly
to make that work or the kernel will panic. That does seem too risky to
me. So I am dropping the idea of trying to use it.