From: Gregory Haskins <ghaskins@novell.com>
To: linux-rt-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, dwalker@mvista.com, mingo@elte.hu,
ghaskins@novell.com
Subject: [PATCH] Workaround for rq->lock deadlock
Date: Tue, 07 Aug 2007 11:43:55 -0600 [thread overview]
Message-ID: <20070807173827.3210.85330.stgit@lsg> (raw)
The following patch converts double_lock_balance to a full DP alogorithm to
work around a deadlock in the scheduler when running on an 8-way SMP system.
I think the original algorithm in this function is technically correct. So
really this patch is plastering over another lurking issue. However, it does
fix the observed deadlock on our systems here so I thought I would at least
share the discovery.
The actual problem is probably related to a code path which takes
task_rq_locks without using the balancer code. It might also be a race
between an rq_lock and something else. TBD
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
---
kernel/sched.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 6f2cf6a..e946e3f 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2507,14 +2507,19 @@ static int double_lock_balance(struct rq *this_rq, struct rq *busiest)
BUG_ON(1);
}
if (unlikely(!spin_trylock(&busiest->lock))) {
- if (busiest < this_rq) {
- spin_unlock(&this_rq->lock);
- spin_lock(&busiest->lock);
- spin_lock(&this_rq->lock);
+ struct rq *rq_l = busiest < this_rq ? busiest : this_rq;
+ struct rq *rq_h = busiest > this_rq ? busiest : this_rq;
- return 1;
- } else
- spin_lock(&busiest->lock);
+ spin_unlock(&this_rq->lock);
+
+ while (1) {
+ if (spin_trylock(&rq_l->lock)) {
+ if (spin_trylock(&rq_h->lock))
+ return 1;
+ else
+ spin_unlock(&rq_l->lock);
+ }
+ }
}
return 0;
}
next reply other threads:[~2007-08-07 18:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 17:43 Gregory Haskins [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-08-07 17:46 [PATCH] Workaround for rq->lock deadlock Gregory Haskins
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=20070807173827.3210.85330.stgit@lsg \
--to=ghaskins@novell.com \
--cc=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
/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