[<prev] [next>] [day] [month] [year] [list]
Message-ID: <c8b590a0-3535-51f1-3c7d-a67da4bcfc5e@redhat.com>
Date: Wed, 12 Oct 2022 09:19:53 -0400
From: Waiman Long <longman@...hat.com>
To: Hillf Danton <hdanton@...a.com>,
Mukesh Ojha <quic_mojha@...cinc.com>
Cc: linux-kernel@...r.kernel.org, john.p.donnelly@...cle.com,
linux-mm@...ck.org, Peter Zijlstra <peterz@...radead.org>,
Will Deacon <will@...nel.org>,
Boqun Feng <boqun.feng@...il.com>,
Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH] locking/rwsem: Prevent non-first waiter from spinning in
down_write() slowpath
On 10/12/22 00:04, Hillf Danton wrote:
>> you mean, you want to check and change waiter->handoff_set on every run
>> rwsem_try_write_lock().
>>
> Yes, with RWSEM_FLAG_HANDOFF set, it is too late for non first waiters to
> 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.
Yes, too much spinning is bad if we have RT tasks in the mix, otherwise
it should be fine.
Cheers,
Longman
Powered by blists - more mailing lists