Index: sched_ule.c =================================================================== --- sched_ule.c (revision 197110) +++ sched_ule.c (working copy) @@ -1821,19 +1821,17 @@ * not holding either run-queue lock. */ 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. - */ - if (TDQ_LOCKPTR(tdn) != TDQ_LOCKPTR(tdq)) { - TDQ_UNLOCK(tdn); + thread_block_switch(td); + + 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