From owner-freebsd-current@FreeBSD.ORG Wed Jul 28 17:29:38 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2AC8A16A4CE for ; Wed, 28 Jul 2004 17:29:38 +0000 (GMT) Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id D7DD243D62 for ; Wed, 28 Jul 2004 17:29:35 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 6998 invoked from network); 28 Jul 2004 17:29:35 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 28 Jul 2004 17:29:33 -0000 Received: from 10.50.40.208 (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id i6SHTSCc081080; Wed, 28 Jul 2004 13:29:30 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: current@FreeBSD.org Date: Wed, 28 Jul 2004 13:29:27 -0400 User-Agent: KMail/1.6 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200407281329.27271.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: Peter Wemm Subject: A couple of SMP deadlock patches X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jul 2004 17:29:38 -0000 Included below are two patches for two different potential deadlocks on SMP. The first one I have sent to the list before, but it didn't seem to help anyone. I do believe it is a fix for a possible deadlock though so I'd like some more testing feedback with the aim of committing it. The second patch works around a lock order reversal introduced with the sleep queue code (since sched_lock's scope was reduced) at the expense of increasing the latency between a swapped out thread becoming runnable and the swapper waking up to swap the process back in. Index: i386/i386/pmap.c =================================================================== RCS file: /usr/cvs/src/sys/i386/i386/pmap.c,v retrieving revision 1.488 diff -u -r1.488 pmap.c --- i386/i386/pmap.c 18 Jul 2004 21:19:10 -0000 1.488 +++ i386/i386/pmap.c 19 Jul 2004 17:15:57 -0000 @@ -185,9 +185,6 @@ LIST_HEAD(pmaplist, pmap); static struct pmaplist allpmaps; static struct mtx allpmaps_lock; -#ifdef SMP -static struct mtx lazypmap_lock; -#endif vm_paddr_t avail_end; /* PA of last available physical page */ vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */ @@ -332,9 +329,6 @@ kernel_pmap->pm_active = -1; /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvlist); LIST_INIT(&allpmaps); -#ifdef SMP - mtx_init(&lazypmap_lock, "lazypmap", NULL, MTX_SPIN); -#endif mtx_init(&allpmaps_lock, "allpmaps", NULL, MTX_SPIN); mtx_lock_spin(&allpmaps_lock); LIST_INSERT_HEAD(&allpmaps, kernel_pmap, pm_list); @@ -1303,7 +1297,7 @@ while ((mask = pmap->pm_active) != 0) { spins = 50000000; mask = mask & -mask; /* Find least significant set bit */ - mtx_lock_spin(&lazypmap_lock); + mtx_lock_spin(&smp_tlb_mtx); #ifdef PAE lazyptd = vtophys(pmap->pm_pdpt); #else @@ -1323,7 +1317,7 @@ break; } } - mtx_unlock_spin(&lazypmap_lock); + mtx_unlock_spin(&smp_tlb_mtx); if (spins == 0) printf("pmap_lazyfix: spun for 50000000\n"); } Index: kern/kern_synch.c =================================================================== RCS file: /usr/cvs/src/sys/kern/kern_synch.c,v retrieving revision 1.254 diff -u -r1.254 kern_synch.c --- kern/kern_synch.c 16 Jul 2004 21:04:55 -0000 1.254 +++ kern/kern_synch.c 28 Jul 2004 16:33:45 -0000 @@ -402,7 +402,9 @@ if ((p->p_sflag & PS_INMEM) == 0) { if ((p->p_sflag & PS_SWAPPINGIN) == 0) { p->p_sflag |= PS_SWAPINREQ; +#ifndef SMP wakeup(&proc0); +#endif } } else sched_wakeup(td); -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org