Re: [PATCH] locking/rwsem: Allow slowpath writer to ignore handoff bit if not set by first waiter

From: John Donnelly
Date: Wed Apr 27 2022 - 20:32:58 EST


On 4/27/22 18:56, Waiman Long wrote:
On 4/27/22 19:16, John Donnelly wrote:
On 4/27/22 12:31 PM, Waiman Long wrote:
With commit d257cc8cb8d5 ("locking/rwsem: Make handoff bit handling more
consistent"), the writer that sets the handoff bit can be interrupted
out without clearing the bit if the wait queue isn't empty. This disables
reader and writer optimistic lock spinning and stealing.

Now if a non-first writer in the queue is somehow woken up or first
entering the waiting loop, it can't acquire the lock.  This is not
the case before that commit as the writer that set the handoff bit
will clear it when exiting out via the out_nolock path. This is less
efficient as the busy rwsem stays in an unlock state for a longer time.

This patch allows a non-first writer to ignore the handoff bit if it
is not originally set or initiated by the first waiter.

Fixes: d257cc8cb8d5 ("locking/rwsem: Make handoff bit handling more consistent")

Hi Waiman,

1. You likely need :

Cc: <stable@xxxxxxxxxxxxxxx>

Since d257cc8cb8d5 has been migrated to other LTS threads (5.15.y for sure) .

Since the commit has a fixes tag, the stable will automatically pick it up.


2. I had posted this earlier:

[PATCH 5.15 1/1] Revert "locking/rwsem: Make handoff bit handling more consistent"

That is likely not needed now.
Right. The patch was created to fix a problem reported by another user. So reverting it may not the right move.



Thanks for the quick follow up.




3. Please add :

Reported-by: Jorge Lopez <jorge.jo.lopez@xxxxxxxxxx>

We can likely test this, but I can't give a ETA when that will happen.


Signed-off-by: Waiman Long <longman@xxxxxxxxxx>

Acked-by: John Donnelly <john.p.donnelly@xxxxxxxxxx>

Will add the that when I send out the next version.

Cheers,
Longman