From owner-svn-src-all@FreeBSD.ORG Sat Feb 27 10:55:44 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27D051065672; Sat, 27 Feb 2010 10:55:44 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14FC38FC16; Sat, 27 Feb 2010 10:55:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1RAthJE038606; Sat, 27 Feb 2010 10:55:43 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1RAthdA038599; Sat, 27 Feb 2010 10:55:43 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201002271055.o1RAthdA038599@svn.freebsd.org> From: Colin Percival Date: Sat, 27 Feb 2010 10:55:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204409 - in releng: 7.1 7.1/sys/conf 7.1/sys/kern 7.2 7.2/sys/conf 7.2/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2010 10:55:44 -0000 Author: cperciva Date: Sat Feb 27 10:55:43 2010 New Revision: 204409 URL: http://svn.freebsd.org/changeset/base/204409 Log: MFC r197223: Fix a deadlock in the ULE scheduler. Approved by: so (cperciva) Errata: FreeBSD-EN-10:02.sched_ule Modified: releng/7.1/UPDATING releng/7.1/sys/conf/newvers.sh releng/7.1/sys/kern/sched_ule.c releng/7.2/UPDATING releng/7.2/sys/conf/newvers.sh releng/7.2/sys/kern/sched_ule.c Modified: releng/7.1/UPDATING ============================================================================== --- releng/7.1/UPDATING Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.1/UPDATING Sat Feb 27 10:55:43 2010 (r204409) @@ -8,6 +8,9 @@ Items affecting the ports and packages s /usr/ports/UPDATING. Please read that file before running portupgrade. +20100227: p11 FreeBSD-EN-10:02.sched_ule + Fix a deadlock in the ULE scheduler. + 20100106: p10 FreeBSD-SA-10:01.bind, FreeBSD-SA-10:02.ntpd, FreeBSD-SA-10:03.zfs Fix BIND named(8) cache poisoning with DNSSEC validation. Modified: releng/7.1/sys/conf/newvers.sh ============================================================================== --- releng/7.1/sys/conf/newvers.sh Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.1/sys/conf/newvers.sh Sat Feb 27 10:55:43 2010 (r204409) @@ -32,7 +32,7 @@ TYPE="FreeBSD" REVISION="7.1" -BRANCH="RELEASE-p10" +BRANCH="RELEASE-p11" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi Modified: releng/7.1/sys/kern/sched_ule.c ============================================================================== --- releng/7.1/sys/kern/sched_ule.c Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.1/sys/kern/sched_ule.c Sat Feb 27 10:55:43 2010 (r204409) @@ -1822,18 +1822,24 @@ sched_switch_migrate(struct tdq *tdq, st */ 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 Modified: releng/7.2/UPDATING ============================================================================== --- releng/7.2/UPDATING Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.2/UPDATING Sat Feb 27 10:55:43 2010 (r204409) @@ -8,6 +8,9 @@ Items affecting the ports and packages s /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. Modified: releng/7.2/sys/conf/newvers.sh ============================================================================== --- releng/7.2/sys/conf/newvers.sh Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.2/sys/conf/newvers.sh Sat Feb 27 10:55:43 2010 (r204409) @@ -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 Modified: releng/7.2/sys/kern/sched_ule.c ============================================================================== --- releng/7.2/sys/kern/sched_ule.c Sat Feb 27 10:41:30 2010 (r204408) +++ releng/7.2/sys/kern/sched_ule.c Sat Feb 27 10:55:43 2010 (r204409) @@ -1822,18 +1822,24 @@ sched_switch_migrate(struct tdq *tdq, st */ 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