From: Will Deacon <will.deacon@arm.com>
To: Waiman Long <Waiman.Long@hp.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Scott J Norton <scott.norton@hp.com>,
Douglas Hatch <doug.hatch@hp.com>
Subject: Re: [PATCH v2 1/2] locking/qrwlock: Fix bug in interrupt handling code
Date: Thu, 11 Jun 2015 15:21:40 +0100 [thread overview]
Message-ID: <20150611142139.GB29425@arm.com> (raw)
In-Reply-To: <1433863153-30722-2-git-send-email-Waiman.Long@hp.com>
Hi Waiman,
On Tue, Jun 09, 2015 at 04:19:12PM +0100, Waiman Long wrote:
> The qrwlock is fair in the process context, but becoming unfair when
> in the interrupt context to support use cases like the tasklist_lock.
> However, the unfair code in the interrupt context has problem that
> may cause deadlock.
>
> The fast path increments the reader count. In the interrupt context,
> the reader in the slowpath will wait until the writer release the
> lock. However, if other readers have the lock and the writer is just
> in the waiting mode. It will never get the write lock because the
> that interrupt context reader has increment the count. This will
> cause deadlock.
I'm probably just being thick here, but I'm struggling to understand the
deadlock case.
If a reader enters the slowpath in interrupt context, we spin while
(cnts & _QW_WMASK) == _QW_LOCKED. Consequently, if there is a writer in
the waiting state, that won't hold up the reader and so forward progress
is ensured. When the reader unlocks, the reader count is decremented and
the writer can take the lock.
The only problematic case I can think of is if you had a steady stream of
readers in interrupt context, but that doesn't seem likely (and I don't
think this patch deals with that anyway).
What am I missing?
Will
next prev parent reply other threads:[~2015-06-11 14:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 15:19 [PATCH 0/2 v2] locking/qrwlock: Fix interrupt handling problem Waiman Long
2015-06-09 15:19 ` [PATCH v2 1/2] locking/qrwlock: Fix bug in interrupt handling code Waiman Long
2015-06-11 14:21 ` Will Deacon [this message]
2015-06-13 3:16 ` Waiman Long
2015-06-09 15:19 ` [PATCH v2 2/2] locking/qrwlock: Don't contend with readers when setting _QW_WAITING Waiman Long
2015-06-10 7:35 ` Ingo Molnar
2015-06-10 16:28 ` Waiman Long
2015-06-12 8:45 ` Ingo Molnar
2015-06-12 22:58 ` Waiman Long
2015-06-19 17:59 ` [tip:locking/core] locking/qrwlock: Don' t " tip-bot for 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=20150611142139.GB29425@arm.com \
--to=will.deacon@arm.com \
--cc=Waiman.Long@hp.com \
--cc=arnd@arndb.de \
--cc=doug.hatch@hp.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=scott.norton@hp.com \
/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