diff options
author | alc <alc@FreeBSD.org> | 2004-06-20 20:57:06 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2004-06-20 20:57:06 +0000 |
commit | 1450b79b4f3a246082640543e67b20df10d1555d (patch) | |
tree | be32fd28aa6840b45d8a14c8387a13a4593d3dbf | |
parent | 37de53b718eb83f819ac08c8402081716846103f (diff) | |
download | FreeBSD-src-1450b79b4f3a246082640543e67b20df10d1555d.zip FreeBSD-src-1450b79b4f3a246082640543e67b20df10d1555d.tar.gz |
- Simplify pmap_remove_pages(), eliminating unnecessary indirection.
- Simplify the locking of pmap_is_modified() by converting control flow to
data flow.
-rw-r--r-- | sys/amd64/amd64/pmap.c | 24 | ||||
-rw-r--r-- | sys/i386/i386/pmap.c | 25 |
2 files changed, 24 insertions, 25 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index d974c88..81b2669 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -2461,7 +2461,7 @@ pmap_remove_pages(pmap, sva, eva) #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY pte = vtopte(pv->pv_va); #else - pte = pmap_pte(pv->pv_pmap, pv->pv_va); + pte = pmap_pte(pmap, pv->pv_va); #endif tpte = *pte; @@ -2487,7 +2487,7 @@ pmap_remove_pages(pmap, sva, eva) KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %#jx", (uintmax_t)tpte)); - pv->pv_pmap->pm_stats.resident_count--; + pmap->pm_stats.resident_count--; pte_clear(pte); @@ -2499,15 +2499,14 @@ pmap_remove_pages(pmap, sva, eva) } npv = TAILQ_NEXT(pv, pv_plist); - TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); + TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); m->md.pv_list_count--; TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - if (TAILQ_FIRST(&m->md.pv_list) == NULL) { + if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_flag_clear(m, PG_WRITEABLE); - } - pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem); + pmap_unuse_pt(pmap, pv->pv_va, pv->pv_ptem); free_pv_entry(pv); } pmap_invalidate_all(pmap); @@ -2525,9 +2524,11 @@ pmap_is_modified(vm_page_t m) { pv_entry_t pv; pt_entry_t *pte; + boolean_t rv; + rv = FALSE; if (!pmap_initialized || (m->flags & PG_FICTITIOUS)) - return FALSE; + return (rv); mtx_assert(&vm_page_queue_mtx, MA_OWNED); TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { @@ -2546,13 +2547,12 @@ pmap_is_modified(vm_page_t m) #endif PMAP_LOCK(pv->pv_pmap); pte = pmap_pte(pv->pv_pmap, pv->pv_va); - if (*pte & PG_M) { - PMAP_UNLOCK(pv->pv_pmap); - return TRUE; - } + rv = (*pte & PG_M) != 0; PMAP_UNLOCK(pv->pv_pmap); + if (rv) + break; } - return (FALSE); + return (rv); } /* diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index f9027db..97cd380 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -2533,7 +2533,7 @@ pmap_remove_pages(pmap, sva, eva) #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY pte = vtopte(pv->pv_va); #else - pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va); + pte = pmap_pte_quick(pmap, pv->pv_va); #endif tpte = *pte; @@ -2559,7 +2559,7 @@ pmap_remove_pages(pmap, sva, eva) KASSERT(m < &vm_page_array[vm_page_array_size], ("pmap_remove_pages: bad tpte %#jx", (uintmax_t)tpte)); - pv->pv_pmap->pm_stats.resident_count--; + pmap->pm_stats.resident_count--; pte_clear(pte); @@ -2571,15 +2571,14 @@ pmap_remove_pages(pmap, sva, eva) } npv = TAILQ_NEXT(pv, pv_plist); - TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); + TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); m->md.pv_list_count--; TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - if (TAILQ_FIRST(&m->md.pv_list) == NULL) { + if (TAILQ_EMPTY(&m->md.pv_list)) vm_page_flag_clear(m, PG_WRITEABLE); - } - pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem); + pmap_unuse_pt(pmap, pv->pv_va, pv->pv_ptem); free_pv_entry(pv); } sched_unpin(); @@ -2598,9 +2597,11 @@ pmap_is_modified(vm_page_t m) { pv_entry_t pv; pt_entry_t *pte; + boolean_t rv; + rv = FALSE; if (!pmap_initialized || (m->flags & PG_FICTITIOUS)) - return FALSE; + return (rv); sched_pin(); mtx_assert(&vm_page_queue_mtx, MA_OWNED); @@ -2620,15 +2621,13 @@ pmap_is_modified(vm_page_t m) #endif PMAP_LOCK(pv->pv_pmap); pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va); - if (*pte & PG_M) { - sched_unpin(); - PMAP_UNLOCK(pv->pv_pmap); - return TRUE; - } + rv = (*pte & PG_M) != 0; PMAP_UNLOCK(pv->pv_pmap); + if (rv) + break; } sched_unpin(); - return (FALSE); + return (rv); } /* |