Re: [PATCH v3 4/5] locking/rwsem: Enable direct rwsem lock handoff

From: Waiman Long
Date: Wed Oct 19 2022 - 11:10:05 EST


On 10/19/22 03:05, Hillf Danton wrote:
On 18 Oct 2022 22:49:02 -0400 Waiman Long <longman@xxxxxxxxxx>
On 10/18/22 22:29, Hillf Danton wrote:
If handoff grants rwsem to a read waiter then the read fast path may revive.
I don't quite understand what you mean by "read fast path may revive".
Subsequent readers may take rwsem without going the slow path after a
read waiter is granted.
That may not be true. As long as there are still waiters in the wait queue, a reader has to go into the slow path and queued up in the wait queue. This is is to prevent a continuous stream of readers from starving writers in the wait queue.

OTOH even after the check for single BIAS, another reader may come in
and add its BIAS to count, which builds the same count as multiple
readers came in before the check.

That is true, but hopefully we will eventually run out reader trying to get a read lock on a given rwsem.

Cheers,
Longman