diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-06-21 04:41:22 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-06-21 04:41:22 +0000 |
commit | b1d6462dd2bd74704484a76aad92ca19953dc48b (patch) | |
tree | cbdfbef116d7f5814b4859f55b244c39ceb57a49 | |
parent | 8853e41b7e3ebda92f64465057e72c9f526265f4 (diff) |
Simple optimizations:
- in __pmap_pv_enter, only walk the pv list to search for writeable mappings
if we are ading a readonly mapping.
- im pmap_protect, do not invoke pmap_extract(), instead directly extract
the paddr from the pte we have already computed a few lines above.
-rw-r--r-- | sys/arch/sh/sh/pmap.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c index 05befe18f8d..7bcd4e0644b 100644 --- a/sys/arch/sh/sh/pmap.c +++ b/sys/arch/sh/sh/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.6 2007/03/05 21:48:23 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.7 2007/06/21 04:41:21 miod Exp $ */ /* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */ /*- @@ -441,17 +441,18 @@ __pmap_pv_enter(pmap_t pmap, struct vm_page *pg, vaddr_t va, vm_prot_t prot) int s; int have_writeable = 0; - if (prot & VM_PROT_WRITE) - have_writeable = 1; - s = splvm(); if (SH_HAS_VIRTUAL_ALIAS) { /* Remove all other mapping on this physical page */ pvh = &pg->mdpage; - SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) { - if (pv->pv_prot & VM_PROT_WRITE) { - have_writeable = 1; - break; + if (prot & VM_PROT_WRITE) + have_writeable = 1; + else { + SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) { + if (pv->pv_prot & VM_PROT_WRITE) { + have_writeable = 1; + break; + } } } if (have_writeable != 0) { @@ -665,33 +666,32 @@ pmap_protect(pmap_t pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) if (pmap->pm_asid != -1) sh_tlb_update(pmap->pm_asid, va, entry); - if (pmap_extract(pmap, va, &pa)) { - pg = PHYS_TO_VM_PAGE(pa); - if (pg == NULL) - continue; - pvh = &pg->mdpage; + pa = entry & PG_PPN; + pg = PHYS_TO_VM_PAGE(pa); + if (pg == NULL) + continue; + pvh = &pg->mdpage; - while ((pv = SLIST_FIRST(&pvh->pvh_head)) != NULL) { - if (pv->pv_pmap == pmap && pv->pv_va == va) { - break; - } - pmap_remove(pv->pv_pmap, pv->pv_va, - pv->pv_va + PAGE_SIZE); + while ((pv = SLIST_FIRST(&pvh->pvh_head)) != NULL) { + if (pv->pv_pmap == pmap && pv->pv_va == va) { + break; } - /* the matching pv is first in the list */ - SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) { - if (pv->pv_pmap == pmap && pv->pv_va == va) { - pv->pv_prot = prot; - break; - } + pmap_remove(pv->pv_pmap, pv->pv_va, + pv->pv_va + PAGE_SIZE); + } + /* the matching pv is first in the list */ + SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) { + if (pv->pv_pmap == pmap && pv->pv_va == va) { + pv->pv_prot = prot; + break; } - /* remove the rest of the elements */ - head = SLIST_FIRST(&pvh->pvh_head); - if (head != NULL) - while((pv = SLIST_NEXT(head, pv_link))!= NULL) - pmap_remove(pv->pv_pmap, pv->pv_va, - pv->pv_va + PAGE_SIZE); } + /* remove the rest of the elements */ + head = SLIST_FIRST(&pvh->pvh_head); + if (head != NULL) + while((pv = SLIST_NEXT(head, pv_link))!= NULL) + pmap_remove(pv->pv_pmap, pv->pv_va, + pv->pv_va + PAGE_SIZE); } } |