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 _at__at_ -185,9 +185,6 _at__at_ 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) */ _at__at_ -332,9 +329,6 _at__at_ 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); _at__at_ -1303,7 +1297,7 _at__at_ 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 _at__at_ -1323,7 +1317,7 _at__at_ 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 _at__at_ -402,7 +402,9 _at__at_ 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_at_FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.orgReceived on Wed Jul 28 2004 - 15:29:38 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:03 UTC