Index: src/sys/amd64/amd64/mp_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/amd64/amd64/mp_machdep.c,v retrieving revision 1.242 diff -u -r1.242 mp_machdep.c --- src/sys/amd64/amd64/mp_machdep.c 13 Aug 2004 22:30:55 -0000 1.242 +++ src/sys/amd64/amd64/mp_machdep.c 22 Aug 2004 21:53:54 -0000 @@ -103,7 +103,6 @@ vm_offset_t smp_tlb_addr1; vm_offset_t smp_tlb_addr2; volatile int smp_tlb_wait; -struct mtx smp_tlb_mtx; extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32); @@ -319,8 +318,6 @@ /* Install an inter-CPU IPI for CPU stop/restart */ setidt(IPI_STOP, IDTVEC(cpustop), SDT_SYSIGT, SEL_KPL, 0); - mtx_init(&smp_tlb_mtx, "tlb", NULL, MTX_SPIN); - /* Set boot_cpu_id if needed. */ if (boot_cpu_id == -1) { boot_cpu_id = PCPU_GET(apic_id); @@ -711,7 +708,7 @@ ncpu = mp_ncpus - 1; /* does not shootdown self */ if (ncpu < 1) return; /* no other cpus */ - mtx_assert(&smp_tlb_mtx, MA_OWNED); + mtx_assert(&smp_rv_mtx, MA_OWNED); smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); @@ -797,7 +794,7 @@ if (ncpu < 1) return; } - mtx_assert(&smp_tlb_mtx, MA_OWNED); + mtx_assert(&smp_rv_mtx, MA_OWNED); smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); Index: src/sys/amd64/amd64/pmap.c =================================================================== RCS file: /home/ncvs/src/sys/amd64/amd64/pmap.c,v retrieving revision 1.491 diff -u -r1.491 pmap.c --- src/sys/amd64/amd64/pmap.c 8 Aug 2004 00:31:58 -0000 1.491 +++ src/sys/amd64/amd64/pmap.c 22 Aug 2004 21:53:54 -0000 @@ -631,7 +631,7 @@ if (smp_started) { if (!(read_rflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -652,7 +652,7 @@ smp_masked_invlpg(pmap->pm_active & other_cpus, va); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } @@ -667,7 +667,7 @@ if (smp_started) { if (!(read_rflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -691,7 +691,7 @@ sva, eva); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } @@ -705,7 +705,7 @@ if (smp_started) { if (!(read_rflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -726,7 +726,7 @@ smp_masked_invltlb(pmap->pm_active & other_cpus); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } Index: src/sys/i386/i386/mp_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/mp_machdep.c,v retrieving revision 1.235 diff -u -r1.235 mp_machdep.c --- src/sys/i386/i386/mp_machdep.c 15 Aug 2004 19:57:14 -0000 1.235 +++ src/sys/i386/i386/mp_machdep.c 22 Aug 2004 21:53:54 -0000 @@ -177,7 +177,6 @@ vm_offset_t smp_tlb_addr1; vm_offset_t smp_tlb_addr2; volatile int smp_tlb_wait; -struct mtx smp_tlb_mtx; /* * Local data and functions. @@ -387,7 +386,6 @@ setidt(IPI_STOP, IDTVEC(cpustop), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); - mtx_init(&smp_tlb_mtx, "tlb", NULL, MTX_SPIN); /* Set boot_cpu_id if needed. */ if (boot_cpu_id == -1) { @@ -912,7 +910,7 @@ ncpu = mp_ncpus - 1; /* does not shootdown self */ if (ncpu < 1) return; /* no other cpus */ - mtx_assert(&smp_tlb_mtx, MA_OWNED); + mtx_assert(&smp_rv_mtx, MA_OWNED); smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); @@ -998,7 +996,7 @@ if (ncpu < 1) return; } - mtx_assert(&smp_tlb_mtx, MA_OWNED); + mtx_assert(&smp_rv_mtx, MA_OWNED); smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); Index: src/sys/i386/i386/pmap.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/pmap.c,v retrieving revision 1.494 diff -u -r1.494 pmap.c --- src/sys/i386/i386/pmap.c 8 Aug 2004 00:31:58 -0000 1.494 +++ src/sys/i386/i386/pmap.c 22 Aug 2004 21:53:54 -0000 @@ -582,7 +582,7 @@ if (smp_started) { if (!(read_eflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -603,7 +603,7 @@ smp_masked_invlpg(pmap->pm_active & other_cpus, va); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } @@ -618,7 +618,7 @@ if (smp_started) { if (!(read_eflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -642,7 +642,7 @@ sva, eva); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } @@ -656,7 +656,7 @@ if (smp_started) { if (!(read_eflags() & PSL_I)) panic("%s: interrupts disabled", __func__); - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); } else critical_enter(); /* @@ -677,7 +677,7 @@ smp_masked_invltlb(pmap->pm_active & other_cpus); } if (smp_started) - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); else critical_exit(); } @@ -1301,7 +1301,7 @@ while ((mask = pmap->pm_active) != 0) { spins = 50000000; mask = mask & -mask; /* Find least significant set bit */ - mtx_lock_spin(&smp_tlb_mtx); + mtx_lock_spin(&smp_rv_mtx); #ifdef PAE lazyptd = vtophys(pmap->pm_pdpt); #else @@ -1321,7 +1321,7 @@ break; } } - mtx_unlock_spin(&smp_tlb_mtx); + mtx_unlock_spin(&smp_rv_mtx); if (spins == 0) printf("pmap_lazyfix: spun for 50000000\n"); } Index: src/sys/kern/subr_smp.c =================================================================== RCS file: /home/ncvs/src/sys/kern/subr_smp.c,v retrieving revision 1.188 diff -u -r1.188 subr_smp.c --- src/sys/kern/subr_smp.c 13 Aug 2004 00:57:43 -0000 1.188 +++ src/sys/kern/subr_smp.c 22 Aug 2004 21:53:54 -0000 @@ -102,7 +102,14 @@ static void (*smp_rv_teardown_func)(void *arg); static void *smp_rv_func_arg; static volatile int smp_rv_waiters[2]; -static struct mtx smp_rv_mtx; + +/* + * Shared mutex to restrict busywaits between smp_rendezvous() and + * smp(_targeted)_tlb_shootdown(). A deadlock occurs if both of these + * functions trigger at once and cause multiple CPUs to busywait with + * interrupts disabled. + */ +struct mtx smp_rv_mtx; /* * Let the MD SMP code initialize mp_maxid very early if it can. Index: src/sys/sys/smp.h =================================================================== RCS file: /home/ncvs/src/sys/sys/smp.h,v retrieving revision 1.77 diff -u -r1.77 smp.h --- src/sys/sys/smp.h 27 Mar 2004 18:21:24 -0000 1.77 +++ src/sys/sys/smp.h 22 Aug 2004 21:53:54 -0000 @@ -95,6 +95,7 @@ int restart_cpus(cpumask_t); int stop_cpus(cpumask_t); void smp_rendezvous_action(void); +extern struct mtx smp_rv_mtx; #endif /* SMP */ void smp_rendezvous(void (*)(void *), void (*)(void *),