aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2010-02-27 10:55:43 +0000
committerColin Percival <cperciva@FreeBSD.org>2010-02-27 10:55:43 +0000
commit8d0c6fc2265889343804561a37998b02971e6b18 (patch)
tree060d2223f085c91f68c5a747b0a807a5403086ef
parentfbcab568df003324cb5791cfaa44e0b01e5d66e6 (diff)
downloadsrc-8d0c6fc2265889343804561a37998b02971e6b18.tar.gz
src-8d0c6fc2265889343804561a37998b02971e6b18.zip
MFC r197223: Fix a deadlock in the ULE scheduler.
Approved by: so (cperciva) Errata: FreeBSD-EN-10:02.sched_ule
Notes
Notes: svn path=/releng/7.2/; revision=204409
-rw-r--r--UPDATING3
-rw-r--r--sys/conf/newvers.sh2
-rw-r--r--sys/kern/sched_ule.c24
3 files changed, 19 insertions, 10 deletions
diff --git a/UPDATING b/UPDATING
index 4bbe43081a16..f6e94bf83b26 100644
--- a/UPDATING
+++ b/UPDATING
@@ -8,6 +8,9 @@ Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before running
portupgrade.
+20100227: p7 FreeBSD-EN-10:02.sched_ule
+ Fix a deadlock in the ULE scheduler.
+
20100106: p6 FreeBSD-SA-10:01.bind, FreeBSD-SA-10:02.ntpd,
FreeBSD-SA-10:03.zfs
Fix BIND named(8) cache poisoning with DNSSEC validation.
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 873715820898..80aa476f0842 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -32,7 +32,7 @@
TYPE="FreeBSD"
REVISION="7.2"
-BRANCH="RELEASE-p6"
+BRANCH="RELEASE-p7"
if [ "X${BRANCH_OVERRIDE}" != "X" ]; then
BRANCH=${BRANCH_OVERRIDE}
fi
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index a9d4e4470611..0340a35cf9dd 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1822,18 +1822,24 @@ sched_switch_migrate(struct tdq *tdq, struct thread *td, int flags)
*/
spinlock_enter();
thread_block_switch(td); /* This releases the lock on tdq. */
- TDQ_LOCK(tdn);
- tdq_add(tdn, td, flags);
- tdq_notify(td->td_sched);
+
/*
- * After we unlock tdn the new cpu still can't switch into this
- * thread until we've unblocked it in cpu_switch(). The lock
- * pointers may match in the case of HTT cores. Don't unlock here
- * or we can deadlock when the other CPU runs the IPI handler.
+ * Acquire both run-queue locks before placing the thread on the new
+ * run-queue to avoid deadlocks created by placing a thread with a
+ * blocked lock on the run-queue of a remote processor. The deadlock
+ * occurs when a third processor attempts to lock the two queues in
+ * question while the target processor is spinning with its own
+ * run-queue lock held while waiting for the blocked lock to clear.
*/
- if (TDQ_LOCKPTR(tdn) != TDQ_LOCKPTR(tdq)) {
- TDQ_UNLOCK(tdn);
+ if (TDQ_LOCKPTR(tdn) == TDQ_LOCKPTR(tdq)) {
TDQ_LOCK(tdq);
+ tdq_add(tdn, td, flags);
+ tdq_notify(td->td_sched);
+ } else {
+ tdq_lock_pair(tdn, tdq);
+ tdq_add(tdn, td, flags);
+ tdq_notify(td->td_sched);
+ TDQ_UNLOCK(tdn);
}
spinlock_exit();
#endif