PERFORCE change 28131 for review
Peter Wemm
peter at FreeBSD.org
Fri Apr 4 18:21:51 PST 2003
http://perforce.freebsd.org/chv.cgi?CH=28131
Change 28131 by peter at 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 <sys/param.h>
@@ -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 <sys/param.h>
#include <sys/systm.h>
@@ -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();
}
More information about the p4-projects
mailing list