Re: [BUG]locking/rwsem: only clean RWSEM_FLAG_HANDOFF when already set

From: Waiman Long
Date: Thu Nov 11 2021 - 14:52:36 EST



On 11/11/21 14:36, Waiman Long wrote:

On 11/11/21 14:20, Peter Zijlstra wrote:
On Thu, Nov 11, 2021 at 02:14:48PM -0500, Waiman Long wrote:
As for the PHASE_CHANGE name, we have to be consistent in both rwsem and
mutex. Maybe a follow up patch if you think we should change the
terminology.
Well, that's exactly the point, they do radically different things.
Having the same name for two different things is confusing.

Anyway, let me go read that patch you sent.

My understanding of handoff is to disable optimistic spinning to let waiters in the wait queue have an opportunity to acquire the lock. There are difference in details on how to do that in mutex and rwsem, though.

BTW, I have decided that we should further simply the trylock for loop in rwsem_down_write_slowpath() to make it easier to read. That is the only difference in the attached v2 patch compared with the previous one.

My bad, I forgot to initialize waiter.handoff_set in rwsem_down_write_slowpath(). I will send out an updated version once you have finished your review.

Cheers,
Longman