Date: Wed, 24 Mar 2004 17:31:51 -0800 (PST) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 49647 for review Message-ID: <200403250131.i2P1Vpnc046289@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=49647 Change 49647 by peter@peter_wannabe on 2004/03/24 17:31:27 Kill off the lazy context switch code. It doesn't help either of the two implementations of amd64 out there. There are better ways of avoiding a TLB hit than adding almost-too-late recovery code. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/apic_vector.S#16 edit .. //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#23 edit .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#59 edit .. //depot/projects/hammer/sys/amd64/amd64/pmap.c#59 edit .. //depot/projects/hammer/sys/amd64/amd64/trap.c#45 edit .. //depot/projects/hammer/sys/amd64/include/apicvar.h#19 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/apic_vector.S#16 (text+ko) ==== @@ -325,19 +325,4 @@ movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */ POP_FRAME /* Why not doreti? */ iretq - -#ifdef LAZY_SWITCH -/* - * Clean up when we lose out on the lazy context switch optimization. - * ie: when we are about to release a PTD but a cpu is still borrowing it. - */ - SUPERALIGN_TEXT -IDTVEC(lazypmap) - PUSH_FRAME - call pmap_lazyfix_action - movq lapic, %rax - movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */ - POP_FRAME /* Why not doreti? */ - iretq -#endif #endif /* SMP */ ==== //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#23 (text+ko) ==== @@ -168,10 +168,6 @@ /* switch address space */ movq PCB_CR3(%r8),%rdx -#ifdef LAZY_SWITCH - cmpq %rdx,KPML4phys /* Kernel address space? */ - je sw1 -#endif movq %cr3,%rax cmpq %rdx,%rax /* Same address space? */ je sw1 ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#59 (text+ko) ==== @@ -303,11 +303,6 @@ /* Install an inter-CPU IPI for forwarding statclock() */ setidt(IPI_STATCLOCK, IDTVEC(statclock), SDT_SYSIGT, SEL_KPL, 0); -#ifdef LAZY_SWITCH - /* Install an inter-CPU IPI for lazy pmap release */ - setidt(IPI_LAZYPMAP, IDTVEC(lazypmap), SDT_SYSIGT, SEL_KPL, 0); -#endif - /* Install an inter-CPU IPI for all-CPU rendezvous */ setidt(IPI_RENDEZVOUS, IDTVEC(rendezvous), SDT_SYSIGT, SEL_KPL, 0); ==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#59 (text+ko) ==== @@ -163,11 +163,6 @@ LIST_HEAD(pmaplist, pmap); static struct pmaplist allpmaps; static struct mtx allpmaps_lock; -#ifdef LAZY_SWITCH -#ifdef SMP -static struct mtx lazypmap_lock; -#endif -#endif vm_paddr_t avail_start; /* PA of first available physical page */ vm_paddr_t avail_end; /* PA of last available physical page */ @@ -475,11 +470,6 @@ kernel_pmap->pm_active = -1; /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvlist); LIST_INIT(&allpmaps); -#ifdef LAZY_SWITCH -#ifdef SMP - mtx_init(&lazypmap_lock, "lazypmap", NULL, MTX_SPIN); -#endif -#endif mtx_init(&allpmaps_lock, "allpmaps", NULL, MTX_SPIN); mtx_lock_spin(&allpmaps_lock); LIST_INSERT_HEAD(&allpmaps, kernel_pmap, pm_list); @@ -1296,94 +1286,7 @@ * Pmap allocation/deallocation routines. ***************************************************/ -#ifdef LAZY_SWITCH -#ifdef SMP -/* - * Deal with a SMP shootdown of other users of the pmap that we are - * trying to dispose of. This can be a bit hairy. - */ -static u_int *lazymask; -static register_t lazyptd; -static volatile u_int lazywait; - -void pmap_lazyfix_action(void); - -void -pmap_lazyfix_action(void) -{ - u_int mymask = PCPU_GET(cpumask); - - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); - atomic_store_rel_int(&lazywait, 1); -} - -static void -pmap_lazyfix_self(u_int mymask) -{ - - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); -} - - -static void -pmap_lazyfix(pmap_t pmap) -{ - u_int mymask = PCPU_GET(cpumask); - u_int mask; - register u_int spins; - - while ((mask = pmap->pm_active) != 0) { - spins = 50000000; - mask = mask & -mask; /* Find least significant set bit */ - mtx_lock_spin(&lazypmap_lock); - lazyptd = vtophys(pmap->pm_pml4); - if (mask == mymask) { - lazymask = &pmap->pm_active; - pmap_lazyfix_self(mymask); - } else { - atomic_store_rel_long((u_long *)&lazymask, - (u_long)&pmap->pm_active); - atomic_store_rel_int(&lazywait, 0); - ipi_selected(mask, IPI_LAZYPMAP); - while (lazywait == 0) { - ia32_pause(); - if (--spins == 0) - break; - } - } - mtx_unlock_spin(&lazypmap_lock); - if (spins == 0) - printf("pmap_lazyfix: spun for 50000000\n"); - } -} - -#else /* SMP */ - /* - * Cleaning up on uniprocessor is easy. For various reasons, we're - * unlikely to have to even execute this code, including the fact - * that the cleanup is deferred until the parent does a wait(2), which - * means that another userland process has run. - */ -static void -pmap_lazyfix(pmap_t pmap) -{ - u_long cr3; - - cr3 = vtophys(pmap->pm_pml4); - if (cr3 == rcr3()) { - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - pmap->pm_active &= ~(PCPU_GET(cpumask)); - } -} -#endif /* SMP */ -#endif - -/* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. * Should only be called if the map contains no valid mappings. @@ -1397,9 +1300,6 @@ ("pmap_release: pmap resident count %ld != 0", pmap->pm_stats.resident_count)); -#ifdef LAZY_SWITCH - pmap_lazyfix(pmap); -#endif mtx_lock_spin(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); ==== //depot/projects/hammer/sys/amd64/amd64/trap.c#45 (text+ko) ==== ==== //depot/projects/hammer/sys/amd64/include/apicvar.h#19 (text+ko) ==== @@ -93,7 +93,6 @@ #define IPI_INVLTLB (APIC_IPI_INTS + 1) /* TLB Shootdown IPIs */ #define IPI_INVLPG (APIC_IPI_INTS + 2) #define IPI_INVLRNG (APIC_IPI_INTS + 3) -#define IPI_LAZYPMAP (APIC_IPI_INTS + 4) /* Lazy pmap release. */ #define IPI_HARDCLOCK (APIC_IPI_INTS + 8) /* Inter-CPU clock handling. */ #define IPI_STATCLOCK (APIC_IPI_INTS + 9) #define IPI_RENDEZVOUS (APIC_IPI_INTS + 10) /* Inter-CPU rendezvous. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403250131.i2P1Vpnc046289>