Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc Maintain pmap resident count as pages are map...
details: https://anonhg.NetBSD.org/src/rev/27e34ec43438
branches: trunk
changeset: 565295:27e34ec43438
user: pk <pk%NetBSD.org@localhost>
date: Sat Apr 03 23:11:14 2004 +0000
description:
Maintain pmap resident count as pages are mapped and unmapped instead
of traversing the page tables each time it's needed.
diffstat:
sys/arch/sparc/include/pmap.h | 5 +--
sys/arch/sparc/sparc/pmap.c | 50 ++++++++++++++++++------------------------
2 files changed, 23 insertions(+), 32 deletions(-)
diffs (223 lines):
diff -r 3c7b68700823 -r 27e34ec43438 sys/arch/sparc/include/pmap.h
--- a/sys/arch/sparc/include/pmap.h Sat Apr 03 22:16:27 2004 +0000
+++ b/sys/arch/sparc/include/pmap.h Sat Apr 03 23:11:14 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.h,v 1.70 2003/08/16 19:21:23 pk Exp $ */
+/* $NetBSD: pmap.h,v 1.71 2004/04/03 23:11:14 pk Exp $ */
/*
* Copyright (c) 1996
@@ -242,7 +242,7 @@
daddr_t));
#define pmap_kernel() (&kernel_pmap_store)
-#define pmap_resident_count(pmap) pmap_count_ptes(pmap)
+#define pmap_resident_count(pm) ((pm)->pm_stats.resident_count)
#define PMAP_PREFER(fo, ap) pmap_prefer((fo), (ap))
@@ -253,7 +253,6 @@
void pmap_activate __P((struct lwp *));
void pmap_deactivate __P((struct lwp *));
void pmap_bootstrap __P((int nmmu, int nctx, int nregion));
-int pmap_count_ptes __P((struct pmap *));
void pmap_prefer __P((vaddr_t, vaddr_t *));
int pmap_pa_exists __P((paddr_t));
void pmap_unwire __P((pmap_t, vaddr_t));
diff -r 3c7b68700823 -r 27e34ec43438 sys/arch/sparc/sparc/pmap.c
--- a/sys/arch/sparc/sparc/pmap.c Sat Apr 03 22:16:27 2004 +0000
+++ b/sys/arch/sparc/sparc/pmap.c Sat Apr 03 23:11:14 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.276 2004/02/13 11:36:18 wiz Exp $ */
+/* $NetBSD: pmap.c,v 1.277 2004/04/03 23:11:14 pk Exp $ */
/*
* Copyright (c) 1996
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.276 2004/02/13 11:36:18 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.277 2004/04/03 23:11:14 pk Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -1595,6 +1595,7 @@
case SRMMU_TEPTE:
sp->sg_npte++;
setpgt4m(&sp->sg_pte[i], te | PPROT_U2S_OMASK);
+ pmap_kernel()->pm_stats.resident_count++;
break;
case SRMMU_TEPTD:
panic("mmu_setup4m_L3: PTD found in L3 page table");
@@ -3474,6 +3475,7 @@
npte = ++scookie < zseg ? NPTESG : lastpage;
sp->sg_npte = npte;
sp->sg_nwired = npte;
+ pmap_kernel()->pm_stats.resident_count += npte;
rp->rg_nsegmap += 1;
for (i = 0; i < npte; i++)
sp->sg_pte[i] = getpte4(p + i * NBPG) | PG_WIRED;
@@ -3599,6 +3601,7 @@
sp = &rp->rg_segmap[VA_VSEG(p)];
sp->sg_nwired--;
sp->sg_npte--;
+ pmap_kernel()->pm_stats.resident_count--;
sp->sg_pte[VA_VPG(p)] = 0;
setpte4(p, 0);
}
@@ -3911,6 +3914,7 @@
pte |= PPROT_WRITE;
setpgt4m(ptep, pte);
+ pmap_kernel()->pm_stats.resident_count++;
}
if ((cpuinfo.flags & CPUFLG_CACHEPAGETABLES) == 0) {
@@ -4750,6 +4754,7 @@
if (inmmu)
setpte4(va, 0);
*ptep = 0;
+ pm->pm_stats.resident_count--;
}
#ifdef DIAGNOSTIC
@@ -4822,6 +4827,7 @@
}
setpgt4m_va(va, &sp->sg_pte[VA_SUN4M_VPG(va)],
SRMMU_TEINVALID, 1, 0, CPUSET_ALL);
+ pm->pm_stats.resident_count--;
nleft--;
#ifdef DIAGNOSTIC
if (nleft < 0)
@@ -4925,6 +4931,7 @@
if (pte & PG_WIRED)
sp->sg_nwired--;
*ptep = 0;
+ pm->pm_stats.resident_count--;
}
#ifdef DIAGNOSTIC
@@ -5016,6 +5023,7 @@
#endif
setpgt4m_va(va, &pte0[VA_SUN4M_VPG(va)], SRMMU_TEINVALID,
pm->pm_ctx != NULL, pm->pm_ctxnum, PMAP_CPUSET(pm));
+ pm->pm_stats.resident_count--;
}
/*
@@ -5136,6 +5144,7 @@
}
*ptep = 0;
+ pm->pm_stats.resident_count--;
if (nleft == 0)
pgt_lvl23_remove4_4c(pm, rp, sp, vr, vs);
npv = pv->pv_next;
@@ -5425,6 +5434,8 @@
setpgt4m_va(va, &sp->sg_pte[VA_SUN4M_VPG(va)], SRMMU_TEINVALID,
pm->pm_ctx != NULL, pm->pm_ctxnum, PMAP_CPUSET(pm));
+ pm->pm_stats.resident_count--;
+
if ((tpte & SRMMU_TETYPE) != SRMMU_TEPTE)
panic("pmap_page_protect !PG_V: pg %p va %lx", pg, va);
@@ -5729,6 +5740,7 @@
}
if (pte & PG_WIRED)
sp->sg_nwired--;
+ pm->pm_stats.resident_count--;
} else {
/* adding new entry */
if (sp->sg_npte++ == 0) {
@@ -5754,6 +5766,7 @@
*ptep = pteproto;
if (pteproto & PG_WIRED)
sp->sg_nwired++;
+ pm->pm_stats.resident_count++;
#ifdef DIAGNOSTIC
if (sp->sg_nwired > sp->sg_npte || sp->sg_nwired < 0)
@@ -5914,6 +5927,7 @@
}
if (pte & PG_WIRED)
sp->sg_nwired--;
+ pm->pm_stats.resident_count--;
} else {
/* adding new entry */
sp->sg_npte++;
@@ -5934,6 +5948,7 @@
*ptep = pteproto;
if (pteproto & PG_WIRED)
sp->sg_nwired++;
+ pm->pm_stats.resident_count++;
#ifdef DIAGNOSTIC
if (sp->sg_nwired > sp->sg_npte || sp->sg_nwired < 0)
@@ -6344,6 +6359,7 @@
setpgt4m_va(va, &sp->sg_pte[VA_SUN4M_VPG(va)],
SRMMU_TEINVALID, pm->pm_ctx != NULL,
pm->pm_ctxnum, PMAP_CPUSET(pm));
+ pm->pm_stats.resident_count--;
} else {
/* adding new entry */
sp->sg_npte++;
@@ -6360,6 +6376,7 @@
}
setpgt4m(&sp->sg_pte[VA_SUN4M_VPG(va)], pteproto);
+ pm->pm_stats.resident_count++;
out:
simple_unlock(&pm->pm_lock);
PMAP_MAP_TO_HEAD_UNLOCK();
@@ -6536,6 +6553,7 @@
setpgt4m_va(va, &sp->sg_pte[VA_SUN4M_VPG(va)],
SRMMU_TEINVALID, pm->pm_ctx != NULL,
pm->pm_ctxnum, PMAP_CPUSET(pm));
+ pm->pm_stats.resident_count--;
} else {
/* adding new entry */
sp->sg_npte++;
@@ -6562,6 +6580,7 @@
* Update PTEs, flush TLB as necessary.
*/
setpgt4m(&sp->sg_pte[VA_SUN4M_VPG(va)], pteproto);
+ pm->pm_stats.resident_count++;
out:
simple_unlock(&pm->pm_lock);
@@ -7496,33 +7515,6 @@
#endif
}
-int
-pmap_count_ptes(pm)
- struct pmap *pm;
-{
- int idx, vs, total;
- struct regmap *rp;
- struct segmap *sp;
-
- if (pm == pmap_kernel()) {
- rp = &pm->pm_regmap[NUREG];
- idx = NKREG;
- } else {
- rp = pm->pm_regmap;
- idx = NUREG;
- }
- for (total = 0; idx;) {
- if ((sp = rp[--idx].rg_segmap) == NULL) {
- continue;
- }
- for (vs = 0; vs < NSEGRG; vs++) {
- total += sp[vs].sg_npte;
- }
- }
- pm->pm_stats.resident_count = total;
- return (total);
-}
-
/*
* Find first virtual address >= *va that is
* least likely to cause cache aliases.
Home |
Main Index |
Thread Index |
Old Index