From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <longman@redhat.com>
Cc: "Hillf Danton" <hdanton@sina.com>, 马振华 <mazhenhua@xiaomi.com>,
mingo <mingo@redhat.com>, will <will@kernel.org>,
"boqun.feng" <boqun.feng@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG]locking/rwsem: only clean RWSEM_FLAG_HANDOFF when already set
Date: Thu, 11 Nov 2021 21:39:42 +0100 [thread overview]
Message-ID: <20211111203942.GJ174730@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20211111203500.GI174703@worktop.programming.kicks-ass.net>
On Thu, Nov 11, 2021 at 09:35:00PM +0100, Peter Zijlstra wrote:
> On Thu, Nov 11, 2021 at 02:36:52PM -0500, 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.
>
> Ah, but the mutex does an actual hand-off, it hands the lock to a
> specific waiting task. That is, unlock() sets owner, as opposed to
> trylock().
>
> The rwsem code doesn't, it just forces a phase change. Once a waiter has
> been blocked too long, the handoff bit is set, causing new readers to be
> blocked. Then we wait for existing readers to complete. At that point,
> any next waiter (most likely a writer) should really get the lock (and
> in that regards the rwsem code is a bit funny).
And this is I think the thing you tried in your earlier inherit patch.
Keep the quescent state and simply let whatever next waiter is in line
have a go.
I suspect that change is easier now. But I've not tried.
next prev parent reply other threads:[~2021-11-11 20:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4fafad133b074f279dbab1aa3642e23f@xiaomi.com>
2021-11-07 3:25 ` [BUG]locking/rwsem: only clean RWSEM_FLAG_HANDOFF when already set Waiman Long
2021-11-07 3:28 ` Waiman Long
[not found] ` <20211107090131.1535-1-hdanton@sina.com>
2021-11-07 15:24 ` Waiman Long
2021-11-07 19:52 ` Waiman Long
2021-11-10 21:38 ` Peter Zijlstra
2021-11-11 2:42 ` Maria Yu
2021-11-11 15:08 ` Peter Zijlstra
2021-11-11 19:14 ` Waiman Long
2021-11-11 19:20 ` Peter Zijlstra
2021-11-11 19:36 ` Waiman Long
2021-11-11 19:52 ` Waiman Long
2021-11-11 20:26 ` Peter Zijlstra
2021-11-11 21:01 ` Waiman Long
2021-11-11 21:25 ` Waiman Long
2021-11-11 21:53 ` Peter Zijlstra
2021-11-11 21:55 ` Waiman Long
2021-11-11 22:00 ` Waiman Long
2021-11-11 21:38 ` Peter Zijlstra
2021-11-11 21:46 ` Waiman Long
2021-11-11 20:35 ` Peter Zijlstra
2021-11-11 20:39 ` Peter Zijlstra [this message]
2021-11-11 20:45 ` Waiman Long
2021-11-11 21:27 ` Peter Zijlstra
2021-11-11 21:54 ` Waiman Long
2021-11-11 20:50 ` Peter Zijlstra
2021-11-11 21:09 ` 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=20211111203942.GJ174730@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=boqun.feng@gmail.com \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mazhenhua@xiaomi.com \
--cc=mingo@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.