locking, tsx: Add generic support for stateful rwsem
In principle lock elision allows readers to speculate independently
(that is not check if any other reader took the lock).
It only needs to check for locked writers.
However the usual trick of checking the lock free to decide
whether the lock is eliding or not doesn't work
We can handle this by passing an explicit elision state around.
The state has be passed from lock to unlock. Any stateful lock
has to be matched with a stateful unlock, but other users
of the same lock can use non stateful accesses.
We still have to read the r/w count to check for writers,
so parallel lockers or unlockers may still abort, if their
time window overlaps.
This patch adds the generic interface to do this for reader sems.
The actual code is enabled in the architecture.
The primary target is mmap_sem.
Without lock elision this is a nop.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
3 files changed