lkml.org 
[lkml]   [2021]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [BUG]locking/rwsem: only clean RWSEM_FLAG_HANDOFF when already set
From

On 11/11/21 16:01, Waiman Long wrote:
>
> On 11/11/21 15:26, Peter Zijlstra wrote:
>> On Thu, Nov 11, 2021 at 02:36:52PM -0500, Waiman Long wrote:
>>
>>> @@ -434,6 +430,7 @@ static void rwsem_mark_wake(struct rw_semaphore
>>> *sem,
>>>               if (!(oldcount & RWSEM_FLAG_HANDOFF) &&
>>>                   time_after(jiffies, waiter->timeout)) {
>>>                   adjustment -= RWSEM_FLAG_HANDOFF;
>>> +                waiter->handoff_set = true;
>>>                   lockevent_inc(rwsem_rlock_handoff);
>>>               }
>> Do we really need this flag? Wouldn't it be the same as waiter-is-first
>> AND sem-has-handoff ?
> That is true. The only downside is that we have to read the count
> first in rwsem_out_nolock_clear_flags(). Since this is not a fast
> path, it should be OK to do that.

I just realize that I may still need this flag for writer to determine
if it should spin after failing to acquire the lock. Or I will have to
do extra read of count value in the loop. I don't need to use it for
writer now.

Cheers,
Longman

\
 
 \ /
  Last update: 2021-11-11 22:26    [W:2.105 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site