you mean, you want to check and change waiter->handoff_set on every runYes, with RWSEM_FLAG_HANDOFF set, it is too late for non first waiters to
rwsem_try_write_lock().
spin, and with both RWSEM_LOCK_MASK and RWSEM_FLAG_HANDOFF set, the rivals
in the RWSEM_LOCK_MASK have an uphand over the first waiter wrt acquiring
the lock, and it is not a bad option for the first waiter to take a step
back off.
if (count & RWSEM_LOCK_MASK) {
if (has_handoff || (!rt_task(waiter->task) &&
!time_after(jiffies, waiter->timeout)))
return false;
new |= RWSEM_FLAG_HANDOFF;
} else {
But does it break optimistic spinning ? @waiman ?Waiters spin for acquiring lock instead of lockup and your report shows
spinning too much makes trouble. The key is stop spinning neither too
late nor too early. My proposal is a simple one with as few heuristics
added as possible.