svn commit: r238163 - head/sys/amd64/amd64
Alan Cox
alc at FreeBSD.org
Fri Jul 6 06:42:25 UTC 2012
Author: alc
Date: Fri Jul 6 06:42:25 2012
New Revision: 238163
URL: http://svn.freebsd.org/changeset/base/238163
Log:
Make pmap_enter()'s management of PV entries consistent with the other pmap
functions that manage PV entries. Specifically, remove the PV entry from
the containing PV list only after the corresponding PTE is destroyed.
Update the pmap's wired mapping count in pmap_enter() before the PV list
lock is acquired.
Modified:
head/sys/amd64/amd64/pmap.c
Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c Fri Jul 6 03:56:45 2012 (r238162)
+++ head/sys/amd64/amd64/pmap.c Fri Jul 6 06:42:25 2012 (r238163)
@@ -3517,8 +3517,6 @@ pmap_enter(pmap_t pmap, vm_offset_t va,
goto validate;
}
- pv = NULL;
-
/*
* Mapping has changed, invalidate old range and fall through to
* handle validating new mapping.
@@ -3526,11 +3524,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va,
if (opa) {
if (origpte & PG_W)
pmap->pm_stats.wired_count--;
- if (origpte & PG_MANAGED) {
+ if ((origpte & PG_MANAGED) != 0)
om = PHYS_TO_VM_PAGE(opa);
- CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, om);
- pv = pmap_pvh_remove(&om->md, pmap, va);
- }
if (mpte != NULL) {
mpte->wire_count--;
KASSERT(mpte->wire_count > 0,
@@ -3541,22 +3536,20 @@ pmap_enter(pmap_t pmap, vm_offset_t va,
pmap_resident_count_inc(pmap, 1);
/*
+ * Increment the counters.
+ */
+ if (wired)
+ pmap->pm_stats.wired_count++;
+
+ /*
* Enter on the PV list if part of our managed memory.
*/
if ((newpte & PG_MANAGED) != 0) {
- if (pv == NULL)
- pv = get_pv_entry(pmap, &lock);
- CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, m);
+ pv = get_pv_entry(pmap, &lock);
pv->pv_va = va;
+ CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, pa);
TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list);
- } else if (pv != NULL)
- free_pv_entry(pmap, pv);
-
- /*
- * Increment counters
- */
- if (wired)
- pmap->pm_stats.wired_count++;
+ }
validate:
@@ -3586,9 +3579,11 @@ validate:
if ((newpte & PG_RW) == 0)
invlva = TRUE;
}
- if ((om->aflags & PGA_WRITEABLE) != 0) {
- CHANGE_PV_LIST_LOCK_TO_VM_PAGE(&lock, om);
- if (TAILQ_EMPTY(&om->md.pv_list) &&
+ if (opa != pa && (origpte & PG_MANAGED) != 0) {
+ CHANGE_PV_LIST_LOCK_TO_PHYS(&lock, opa);
+ pmap_pvh_free(&om->md, pmap, va);
+ if ((om->aflags & PGA_WRITEABLE) != 0 &&
+ TAILQ_EMPTY(&om->md.pv_list) &&
((om->flags & PG_FICTITIOUS) != 0 ||
TAILQ_EMPTY(&pa_to_pvh(opa)->pv_list)))
vm_page_aflag_clear(om, PGA_WRITEABLE);
More information about the svn-src-head
mailing list