From owner-p4-projects@FreeBSD.ORG Fri Apr 4 18:21:51 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B220D37B404; Fri, 4 Apr 2003 18:21:50 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5130937B401 for ; Fri, 4 Apr 2003 18:21:50 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D468843F93 for ; Fri, 4 Apr 2003 18:21:49 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h352Ln0U094077 for ; Fri, 4 Apr 2003 18:21:49 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h352LntV094074 for perforce@freebsd.org; Fri, 4 Apr 2003 18:21:49 -0800 (PST) Date: Fri, 4 Apr 2003 18:21:49 -0800 (PST) Message-Id: <200304050221.h352LntV094074@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 28131 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Apr 2003 02:21:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=28131 Change 28131 by peter@peter_daintree on 2003/04/04 18:21:12 deep-six SWITCH_OPTIM_STATS and LAZY_SWITCH for now Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#33 edit .. //depot/projects/hammer/sys/x86_64/x86_64/pmap.c#11 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#33 (text+ko) ==== @@ -48,7 +48,6 @@ #include "opt_maxmem.h" #include "opt_msgbuf.h" #include "opt_perfmon.h" -#include "opt_swtch.h" #include "opt_kstack_pages.h" #include @@ -139,43 +138,6 @@ struct user *proc0uarea; /* address of proc 0 uarea space */ vm_offset_t proc0kstack; /* address of proc 0 kstack space */ -#if defined(SWTCH_OPTIM_STATS) -int stupid_switch; -SYSCTL_INT(_debug, OID_AUTO, stupid_switch, - CTLFLAG_RW, &stupid_switch, 0, ""); -int swtch_optim_stats; -SYSCTL_INT(_debug, OID_AUTO, swtch_optim_stats, - CTLFLAG_RW, &swtch_optim_stats, 0, ""); -int tlb_flush_count; -SYSCTL_INT(_debug, OID_AUTO, tlb_flush_count, - CTLFLAG_RW, &tlb_flush_count, 0, ""); -int lazy_flush_count; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_count, - CTLFLAG_RW, &lazy_flush_count, 0, ""); -int lazy_flush_fixup; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_fixup, - CTLFLAG_RW, &lazy_flush_fixup, 0, ""); -#ifdef SMP -int lazy_flush_smpfixup; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_smpfixup, - CTLFLAG_RW, &lazy_flush_smpfixup, 0, ""); -int lazy_flush_smpipi; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_smpipi, - CTLFLAG_RW, &lazy_flush_smpipi, 0, ""); -int lazy_flush_smpbadcr3; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_smpbadcr3, - CTLFLAG_RW, &lazy_flush_smpbadcr3, 0, ""); -int lazy_flush_smpmiss; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_smpmiss, - CTLFLAG_RW, &lazy_flush_smpmiss, 0, ""); -#endif -#endif -#ifdef LAZY_SWITCH -int lazy_flush_enable = 1; -SYSCTL_INT(_debug, OID_AUTO, lazy_flush_enable, - CTLFLAG_RW, &lazy_flush_enable, 0, ""); -#endif - int cold = 1; long Maxmem = 0; ==== //depot/projects/hammer/sys/x86_64/x86_64/pmap.c#11 (text+ko) ==== @@ -102,7 +102,6 @@ #include "opt_pmap.h" #include "opt_msgbuf.h" #include "opt_kstack_pages.h" -#include "opt_swtch.h" #include #include @@ -176,9 +175,6 @@ LIST_HEAD(pmaplist, pmap); static struct pmaplist allpmaps; static struct mtx allpmaps_lock; -#if defined(SMP) && defined(LAZY_SWITCH) -static struct mtx lazypmap_lock; -#endif vm_paddr_t avail_start; /* PA of first available physical page */ vm_paddr_t avail_end; /* PA of last available physical page */ @@ -328,9 +324,6 @@ kernel_pmap->pm_active = -1; /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvlist); LIST_INIT(&allpmaps); -#if defined(SMP) && defined(LAZY_SWITCH) - 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); @@ -1346,121 +1339,6 @@ * 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 u_int 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); -#ifdef SWTCH_OPTIM_STATS - atomic_add_int(&lazy_flush_smpfixup, 1); - } else { - if (*lazymask & mymask) - lazy_flush_smpbadcr3++; - else - lazy_flush_smpmiss++; -#endif - } - 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); -#ifdef SWTCH_OPTIM_STATS - lazy_flush_fixup++; - } else { - if (*lazymask & mymask) - lazy_flush_smpbadcr3++; - else - lazy_flush_smpmiss++; -#endif - } - 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); -#ifdef PAE - lazyptd = vtophys(pmap->pm_pdpt); -#else - lazyptd = vtophys(pmap->pm_pdir); -#endif - if (mask == mymask) { - lazymask = &pmap->pm_active; - pmap_lazyfix_self(mymask); - } else { - atomic_store_rel_int((u_int *)&lazymask, - (u_int)&pmap->pm_active); - atomic_store_rel_int(&lazywait, 0); - ipi_selected(mask, IPI_LAZYPMAP); - while (lazywait == 0) { - ia32_pause(); - if (--spins == 0) - break; - } -#ifdef SWTCH_OPTIM_STATS - lazy_flush_smpipi++; -#endif - } - 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_int cr3; - - cr3 = vtophys(pmap->pm_pdir); - if (cr3 == rcr3()) { - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - pmap->pm_active &= ~(PCPU_GET(cpumask)); -#ifdef SWTCH_OPTIM_STATS - lazy_flush_fixup++; -#endif - } -} -#endif /* SMP */ -#endif /* LAZY_SWITCH */ - /* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. @@ -1482,9 +1360,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); @@ -3226,9 +3101,6 @@ td->td_pcb->pcb_cr3 = cr3; } load_cr3(cr3); -#ifdef SWTCH_OPTIM_STATS - tlb_flush_count++; -#endif critical_exit(); }