Date: Wed, 28 Jul 2004 13:29:27 -0400 From: John Baldwin <jhb@FreeBSD.org> To: current@FreeBSD.org Cc: Peter Wemm <peter@FreeBSD.org> Subject: A couple of SMP deadlock patches Message-ID: <200407281329.27271.jhb@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
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 <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407281329.27271.jhb>
