From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Kacur <jkacur@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Peter Zijlstra <peterz@infradead.org>,
Clark Williams <clark.williams@gmail.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Ingo Molnar <mingo@kernel.org>
Subject: [RFC][PATCH RT 2/3] locking: Convert trylock spinners over to spin_try_or_boost_lock()
Date: Thu, 03 Sep 2015 21:19:02 -0400 [thread overview]
Message-ID: <20150904012118.361644516@goodmis.org> (raw)
In-Reply-To: 20150904011900.730816481@goodmis.org
[-- Attachment #1: 0002-locking-Convert-trylock-spinners-over-to-spin_try_or.patch --]
[-- Type: text/plain, Size: 2984 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
When trying to take locks in reverse order, it is possible that on
PREEMPT_RT that the running task could have preempted the owner and never
let it run, creating a live lock. This is because spinlocks in PREEMPT_RT
can be preempted.
Currently, this is solved by calling cpu_chill(), which on PREEMPT_RT is
converted into a msleep(1), and we just hopen that the owner will have time
to release the lock, and nobody else will take in when the task wakes up.
By converting these to spin_try_or_boost_lock() which will boost the owners,
the cpu_chill() can be converted into a sched_yield() which will allow the
owners to make immediate progress even if it was preempted by a high
priority task.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
block/blk-ioc.c | 4 ++--
fs/autofs4/expire.c | 2 +-
fs/dcache.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 28f467e636cc..de5eccdc8abb 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -105,7 +105,7 @@ static void ioc_release_fn(struct work_struct *work)
struct io_cq, ioc_node);
struct request_queue *q = icq->q;
- if (spin_trylock(q->queue_lock)) {
+ if (spin_try_or_boost_lock(q->queue_lock)) {
ioc_destroy_icq(icq);
spin_unlock(q->queue_lock);
} else {
@@ -183,7 +183,7 @@ retry:
hlist_for_each_entry(icq, &ioc->icq_list, ioc_node) {
if (icq->flags & ICQ_EXITED)
continue;
- if (spin_trylock(icq->q->queue_lock)) {
+ if (spin_try_or_boost_lock(icq->q->queue_lock)) {
ioc_exit_icq(icq);
spin_unlock(icq->q->queue_lock);
} else {
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index d487fa27add5..025bfc71dc6c 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -148,7 +148,7 @@ again:
}
parent = p->d_parent;
- if (!spin_trylock(&parent->d_lock)) {
+ if (!spin_try_or_boost_lock(&parent->d_lock)) {
spin_unlock(&p->d_lock);
cpu_chill();
goto relock;
diff --git a/fs/dcache.c b/fs/dcache.c
index c1dad92434d5..6b5643ecdf37 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -573,12 +573,12 @@ static struct dentry *dentry_kill(struct dentry *dentry)
struct inode *inode = dentry->d_inode;
struct dentry *parent = NULL;
- if (inode && unlikely(!spin_trylock(&inode->i_lock)))
+ if (inode && unlikely(!spin_try_or_boost_lock(&inode->i_lock)))
goto failed;
if (!IS_ROOT(dentry)) {
parent = dentry->d_parent;
- if (unlikely(!spin_trylock(&parent->d_lock))) {
+ if (unlikely(!spin_try_or_boost_lock(&parent->d_lock))) {
if (inode)
spin_unlock(&inode->i_lock);
goto failed;
@@ -2394,7 +2394,7 @@ again:
inode = dentry->d_inode;
isdir = S_ISDIR(inode->i_mode);
if (dentry->d_lockref.count == 1) {
- if (!spin_trylock(&inode->i_lock)) {
+ if (!spin_try_or_boost_lock(&inode->i_lock)) {
spin_unlock(&dentry->d_lock);
cpu_chill();
goto again;
--
2.4.6
next prev parent reply other threads:[~2015-09-04 1:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 1:19 [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Steven Rostedt
2015-09-04 1:19 ` [RFC][PATCH RT 1/3] locking: Add spin_try_or_boost_lock() infrastructure Steven Rostedt
2015-09-04 1:48 ` Steven Rostedt
2015-09-04 1:19 ` Steven Rostedt [this message]
2015-09-04 1:19 ` [RFC][PATCH RT 3/3] rt: Make cpu_chill() into yield() and add new cpu_rest() as msleep(1) Steven Rostedt
2015-09-05 10:30 ` [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Thomas Gleixner
2015-09-05 12:04 ` Ingo Molnar
2015-09-05 12:26 ` Steven Rostedt
2015-09-07 8:35 ` Thomas Gleixner
2015-09-07 10:10 ` Thomas Gleixner
2015-09-08 7:31 ` Ingo Molnar
2015-09-08 8:09 ` Thomas Gleixner
2015-09-14 9:50 ` Ingo Molnar
2015-09-08 16:59 ` Steven Rostedt
2015-09-08 19:35 ` Steven Rostedt
2015-09-05 12:18 ` Steven Rostedt
2015-09-05 12:27 ` Steven Rostedt
2015-09-05 12:50 ` Steven Rostedt
2015-09-07 9:14 ` Thomas Gleixner
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=20150904012118.361644516@goodmis.org \
--to=rostedt@goodmis.org \
--cc=C.Emde@osadl.org \
--cc=acme@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=clark.williams@gmail.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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