From: Waiman Long <longman@redhat.com>
To: Hillf Danton <hdanton@sina.com>, Mukesh Ojha <quic_mojha@quicinc.com>
Cc: linux-kernel@vger.kernel.org, john.p.donnelly@oracle.com,
linux-mm@kvack.org, Peter Zijlstra <peterz@infradead.org>,
Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] locking/rwsem: Prevent non-first waiter from spinning in down_write() slowpath
Date: Wed, 12 Oct 2022 09:19:53 -0400 [thread overview]
Message-ID: <c8b590a0-3535-51f1-3c7d-a67da4bcfc5e@redhat.com> (raw)
In-Reply-To: <20221012040410.403-1-hdanton@sina.com>
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
next prev parent reply other threads:[~2022-10-12 13:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <7cbf49c9-d122-30e6-68b3-c61eca63e5dc@quicinc.com>
2022-10-11 10:46 ` Hillf Danton
2022-10-11 13:16 ` Mukesh Ojha
2022-10-12 4:04 ` Hillf Danton
2022-10-12 13:19 ` Waiman Long [this message]
2022-10-12 13:42 ` Mukesh Ojha
2022-10-12 13:16 ` Waiman Long
2022-10-12 13:14 ` Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8b590a0-3535-51f1-3c7d-a67da4bcfc5e@redhat.com \
--to=longman@redhat.com \
--cc=boqun.feng@gmail.com \
--cc=hdanton@sina.com \
--cc=john.p.donnelly@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=quic_mojha@quicinc.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox