PERFORCE change 31442 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sun May 18 13:49:04 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=31442
Change 31442 by marcel at marcel_nfs on 2003/05/18 13:48:17
Remove the PMAP tweaks from this branch. The branch
is now officially dead and identical to it's parent
(the ia64 branch).
Affected files ...
.. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#17 edit
Differences ...
==== //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#17 (text+ko) ====
@@ -249,16 +249,16 @@
* VHPT instrumentation.
*/
static int pmap_vhpt_inserts;
-static int pmap_vhpt_removals;
-static int pmap_vhpt_updates;
+static int pmap_vhpt_collisions;
+static int pmap_vhpt_resident;
SYSCTL_DECL(_vm_stats);
SYSCTL_NODE(_vm_stats, OID_AUTO, vhpt, CTLFLAG_RD, 0, "");
SYSCTL_INT(_vm_stats_vhpt, OID_AUTO, inserts, CTLFLAG_RD,
- &pmap_vhpt_inserts, 0, "VHPT insertion counter");
-SYSCTL_INT(_vm_stats_vhpt, OID_AUTO, removals, CTLFLAG_RD,
- &pmap_vhpt_removals, 0, "VHPT removal counter");
-SYSCTL_INT(_vm_stats_vhpt, OID_AUTO, updates, CTLFLAG_RD,
- &pmap_vhpt_updates, 0, "VHPT update counter");
+ &pmap_vhpt_inserts, 0, "");
+SYSCTL_INT(_vm_stats_vhpt, OID_AUTO, collisions, CTLFLAG_RD,
+ &pmap_vhpt_collisions, 0, "");
+SYSCTL_INT(_vm_stats_vhpt, OID_AUTO, resident, CTLFLAG_RD,
+ &pmap_vhpt_resident, 0, "");
static PMAP_INLINE void free_pv_entry(pv_entry_t pv);
static pv_entry_t get_pv_entry(void);
@@ -968,8 +968,12 @@
struct ia64_lpte *vhpte;
pmap_vhpt_inserts++;
+ pmap_vhpt_resident++;
- vhpte = (struct ia64_lpte *)ia64_thash(va);
+ vhpte = (struct ia64_lpte *) ia64_thash(va);
+
+ if (vhpte->pte_chain)
+ pmap_vhpt_collisions++;
pte->pte_chain = vhpte->pte_chain;
vhpte->pte_chain = ia64_tpa((vm_offset_t) pte);
@@ -988,14 +992,11 @@
{
struct ia64_lpte *vhpte;
- pmap_vhpt_updates++;
+ vhpte = (struct ia64_lpte *) ia64_thash(va);
- vhpte = (struct ia64_lpte *)ia64_thash(va);
-
- if ((!vhpte->pte_p || vhpte->pte_tag == pte->pte_tag) && pte->pte_p)
+ if ((!vhpte->pte_p || vhpte->pte_tag == pte->pte_tag)
+ && pte->pte_p)
pmap_install_pte(vhpte, pte);
-
- ia64_ptc_g(va, pte->pte_ps << 2);
}
/*
@@ -1036,15 +1037,11 @@
}
}
- pmap_vhpt_removals++;
-
- /* Snip this pv_entry out of the collision chain. */
+ /*
+ * Snip this pv_entry out of the collision chain.
+ */
lpte->pte_chain = pte->pte_chain;
- /* Invalidate the entry and purge the TLB. */
- pte->pte_p = 0;
- ia64_ptc_g(va, pte->pte_ps << 2);
-
/*
* If the VHPTE matches as well, change it to map the first
* element from the chain if there is one.
@@ -1060,6 +1057,7 @@
}
}
+ pmap_vhpt_resident--;
error = 0;
done:
return error;
@@ -1188,9 +1186,9 @@
pmap_find_kpte(vm_offset_t va)
{
KASSERT((va >> 61) == 5,
- ("kernel mapping 0x%lx not in region 5", va));
+ ("kernel mapping 0x%lx not in region 5", va));
KASSERT(IA64_RR_MASK(va) < (nkpt * PAGE_SIZE * NKPTEPG),
- ("kernel mapping 0x%lx out of range", va));
+ ("kernel mapping 0x%lx out of range", va));
return (&ia64_kptdir[KPTE_DIR_INDEX(va)][KPTE_PTE_INDEX(va)]);
}
@@ -1268,6 +1266,19 @@
}
/*
+ * If a pte contains a valid mapping, clear it and update the VHPT.
+ */
+static void
+pmap_clear_pte(struct ia64_lpte *pte, vm_offset_t va)
+{
+ if (pte->pte_p) {
+ pmap_remove_vhpt(va);
+ ia64_ptc_g(va, PAGE_SHIFT << 2);
+ pte->pte_p = 0;
+ }
+}
+
+/*
* Remove the (possibly managed) mapping represented by pte from the
* given pmap.
*/
@@ -1288,6 +1299,11 @@
if (error)
return error;
+ /*
+ * Make sure pmap_set_pte() knows it isn't in the VHPT.
+ */
+ pte->pte_p = 0;
+
if (pte->pte_ig & PTE_IG_WIRED)
pmap->pm_stats.wired_count -= 1;
@@ -1357,9 +1373,13 @@
for (i = 0; i < count; i++) {
vm_offset_t tva = va + i * PAGE_SIZE;
+ int wasvalid;
pte = pmap_find_kpte(tva);
- pmap_set_pte(pte, tva, VM_PAGE_TO_PHYS(m[i]), 0, PTE_PL_KERN,
- PTE_AR_RWX);
+ wasvalid = pte->pte_p;
+ pmap_set_pte(pte, tva, VM_PAGE_TO_PHYS(m[i]),
+ 0, PTE_PL_KERN, PTE_AR_RWX);
+ if (wasvalid)
+ ia64_ptc_g(tva, PAGE_SHIFT << 2);
}
}
@@ -1375,9 +1395,8 @@
for (i = 0; i < count; i++) {
pte = pmap_find_kpte(va);
- if (pte->pte_p)
- pmap_remove_vhpt(va);
- va += PAGE_SIZE;
+ pmap_clear_pte(pte, va);
+ va += PAGE_SIZE;
}
}
@@ -1388,9 +1407,13 @@
pmap_kenter(vm_offset_t va, vm_offset_t pa)
{
struct ia64_lpte *pte;
+ int wasvalid;
pte = pmap_find_kpte(va);
+ wasvalid = pte->pte_p;
pmap_set_pte(pte, va, pa, 0, PTE_PL_KERN, PTE_AR_RWX);
+ if (wasvalid)
+ ia64_ptc_g(va, PAGE_SHIFT << 2);
}
/*
@@ -1402,8 +1425,7 @@
struct ia64_lpte *pte;
pte = pmap_find_kpte(va);
- if (pte->pte_p)
- pmap_remove_vhpt(va);
+ pmap_clear_pte(pte, va);
}
/*
@@ -1609,6 +1631,7 @@
}
pmap_pte_set_prot(pte, newprot);
pmap_update_vhpt(pte, sva);
+ pmap_invalidate_page(pmap, sva);
}
sva += PAGE_SIZE;
@@ -1729,7 +1752,7 @@
* adds the pte to the VHPT if necessary.
*/
pmap_set_pte(pte, va, pa, managed | (wired ? PTE_IG_WIRED : 0),
- pte_prot_pl(pmap, prot), pte_prot_ar(pmap, prot));
+ pte_prot_pl(pmap, prot), pte_prot_ar(pmap, prot));
/*
* if the mapping or permission bits are different, we need
@@ -1777,8 +1800,9 @@
/*
* Initialise PTE with read-only protection and enter into VHPT.
*/
- pmap_set_pte(pte, va, VM_PAGE_TO_PHYS(m), PTE_IG_MANAGED, PTE_PL_USER,
- PTE_AR_R);
+ pmap_set_pte(pte, va, VM_PAGE_TO_PHYS(m),
+ PTE_IG_MANAGED,
+ PTE_PL_USER, PTE_AR_R);
pmap_install(oldpmap);
}
@@ -2223,6 +2247,7 @@
pte = pmap_find_vhpt(pv->pv_va);
pmap_pte_set_prot(pte, newprot);
pmap_update_vhpt(pte, pv->pv_va);
+ pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
pmap_install(oldpmap);
}
vm_page_flag_clear(m, PG_WRITEABLE);
@@ -2260,6 +2285,7 @@
count++;
pte->pte_a = 0;
pmap_update_vhpt(pte, pv->pv_va);
+ pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
}
pmap_install(oldpmap);
}
@@ -2336,6 +2362,7 @@
if (pte->pte_d) {
pte->pte_d = 0;
pmap_update_vhpt(pte, pv->pv_va);
+ pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
}
pmap_install(oldpmap);
}
@@ -2360,6 +2387,7 @@
if (pte->pte_a) {
pte->pte_a = 0;
pmap_update_vhpt(pte, pv->pv_va);
+ pmap_invalidate_page(pv->pv_pmap, pv->pv_va);
}
pmap_install(oldpmap);
}
More information about the p4-projects
mailing list