From 8646d310a9e462525cbb13a453aa6e9d0e97952f Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 17 Dec 2014 15:26:21 +0000 Subject: [PATCH] delete simplelocks --- sys/arch/hppa64/hppa64/pmap.c | 77 ++-------------------------------- sys/arch/hppa64/include/pmap.h | 4 +- 2 files changed, 5 insertions(+), 76 deletions(-) diff --git a/sys/arch/hppa64/hppa64/pmap.c b/sys/arch/hppa64/hppa64/pmap.c index 5c174061dcd..bf427cca192 100644 --- a/sys/arch/hppa64/hppa64/pmap.c +++ b/sys/arch/hppa64/hppa64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.25 2014/11/16 12:30:57 deraadt Exp $ */ +/* $OpenBSD: pmap.c,v 1.26 2014/12/17 15:26:21 deraadt Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -323,10 +323,8 @@ pmap_dump_pv(paddr_t pa) struct pv_entry *pve; pg = PHYS_TO_VM_PAGE(pa); - simple_lock(&pg->mdpage.pvh_lock); for(pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) printf("%x:%lx\n", pve->pv_pmap->pm_space, pve->pv_va); - simple_unlock(&pg->mdpage.pvh_lock); } #endif @@ -400,14 +398,12 @@ pmap_pv_remove(struct vm_page *pg, struct pmap *pmap, vaddr_t va) DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pv_remove(%p, %p, 0x%lx)\n", pg, pmap, va)); - simple_lock(&pg->mdpage.pvh_lock); /* lock pv_head */ for(pv = *(pve = &pg->mdpage.pvh_list); pv; pv = *(pve = &(*pve)->pv_next)) if (pv->pv_pmap == pmap && pv->pv_va == va) { *pve = pv->pv_next; break; } - simple_unlock(&pg->mdpage.pvh_lock); /* unlock, done! */ return (pv); } @@ -633,8 +629,6 @@ pmap_growkernel(vaddr_t kva) va = VM_MIN_KERNEL_ADDRESS + (pmap_nkpdes << PDE_SHIFT); DPRINTF(PDB_PHYS, ("pmap_growkernel: was va 0x%lx\n", va)); if (va < kva) { - simple_lock(&pmap_kernel()->pm_obj.vmobjlock); - for ( ; va < kva ; pmap_nkpdes++, va += 1 << PDE_SHIFT) if (uvm.page_init_done) { if (!pmap_pde_alloc(pmap_kernel(), va, NULL)) @@ -648,8 +642,6 @@ pmap_growkernel(vaddr_t kva) pmap_pde_set(pmap_kernel(), va, pa); pmap_kernel()->pm_stats.resident_count++; } - - simple_unlock(&pmap_kernel()->pm_obj.vmobjlock); } DPRINTF(PDB_PHYS|PDB_VP, ("pmap_growkernel: now va 0x%lx\n", va)); return (va); @@ -710,9 +702,7 @@ pmap_destroy(struct pmap *pmap) DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_destroy(%p)\n", pmap)); - simple_lock(&pmap->pm_lock); refs = --pmap->pm_obj.uo_refs; - simple_unlock(&pmap->pm_lock); if (refs > 0) return; @@ -780,9 +770,7 @@ pmap_reference(struct pmap *pmap) { DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_reference(%p)\n", pmap)); - simple_lock(&pmap->pm_lock); pmap->pm_obj.uo_refs++; - simple_unlock(&pmap->pm_lock); } void @@ -805,14 +793,10 @@ pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) ("pmap_enter(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)\n", pmap, va, pa, prot, flags)); - simple_lock(&pmap->pm_lock); - if (!(pde = pmap_pde_get(pmap->pm_pdir, va)) && !(pde = pmap_pde_alloc(pmap, va, &ptp))) { - if (flags & PMAP_CANFAIL) { - simple_unlock(&pmap->pm_lock); + if (flags & PMAP_CANFAIL) return (ENOMEM); - } panic("pmap_enter: cannot allocate pde"); } @@ -839,10 +823,8 @@ pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)); if (pg != NULL) { - simple_lock(&pg->mdpage.pvh_lock); pve = pmap_pv_remove(pg, pmap, va); pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); - simple_unlock(&pg->mdpage.pvh_lock); } } else { DPRINTF(PDB_ENTER, @@ -857,19 +839,14 @@ pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(pa))) { if (!pve && !(pve = pmap_pv_alloc())) { - if (flags & PMAP_CANFAIL) { - simple_unlock(&pg->mdpage.pvh_lock); - simple_unlock(&pmap->pm_lock); + if (flags & PMAP_CANFAIL) return (ENOMEM); - } panic("pmap_enter: no pv entries available"); } pte |= pmap_prot(pmap, prot); - simple_lock(&pg->mdpage.pvh_lock); if (pmap_check_alias(pg->mdpage.pvh_list, va, pte)) pmap_page_remove(pg); pmap_pv_enter(pg, pve, pmap, va, ptp); - simple_unlock(&pg->mdpage.pvh_lock); } else if (pve) pmap_pv_free(pve); @@ -883,8 +860,6 @@ enter: pte |= PTE_WIRED; pmap_pte_set(pde, va, pte); - simple_unlock(&pmap->pm_lock); - DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_enter: leaving\n")); return (0); @@ -903,8 +878,6 @@ pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva) DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_remove(%p, 0x%lx, 0x%lx)\n", pmap, sva, eva)); - simple_lock(&pmap->pm_lock); - for (batch = 0; sva < eva; sva += PAGE_SIZE) { pdemask = sva & (PDE_MASK|PIE_MASK); if (!(pde = pmap_pde_get(pmap->pm_pdir, sva))) { @@ -936,11 +909,9 @@ pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva) if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - simple_lock(&pg->mdpage.pvh_lock); pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); if ((pve = pmap_pv_remove(pg, pmap, sva))) pmap_pv_free(pve); - simple_unlock(&pg->mdpage.pvh_lock); } else { if (IS_IOPAGE(PTE_PAGE(pte))) { ptp = pmap_pde_ptp(pmap, pde); @@ -951,8 +922,6 @@ pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva) } } - simple_unlock(&pmap->pm_lock); - DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_remove: leaving\n")); } @@ -970,8 +939,6 @@ pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) sva = trunc_page(sva); tlbprot = pmap_prot(pmap, prot); - simple_lock(&pmap->pm_lock); - for (pdemask = 1; sva < eva; sva += PAGE_SIZE) { if (pdemask != (sva & (PDE_MASK|PIE_MASK))) { pdemask = sva & (PDE_MASK|PIE_MASK); @@ -993,11 +960,8 @@ pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) continue; pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)); - if (pg != NULL) { - simple_lock(&pg->mdpage.pvh_lock); + if (pg != NULL) pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); - simple_unlock(&pg->mdpage.pvh_lock); - } pmap_pte_flush(pmap, sva, pte); pte &= ~PTE_ACC_MASK; @@ -1005,8 +969,6 @@ pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) pmap_pte_set(pde, sva, pte); } } - - simple_unlock(&pmap->pm_lock); } void @@ -1019,7 +981,6 @@ pmap_page_remove(struct vm_page *pg) if (pg->mdpage.pvh_list == NULL) return; - simple_lock(&pg->mdpage.pvh_lock); for (pve = pg->mdpage.pvh_list; pve; pve = (ppve = pve)->pv_next, pmap_pv_free(ppve)) { struct pmap *pmap = pve->pv_pmap; @@ -1027,8 +988,6 @@ pmap_page_remove(struct vm_page *pg) volatile pt_entry_t *pde; pt_entry_t pte; - simple_lock(&pmap->pm_lock); - pde = pmap_pde_get(pmap->pm_pdir, va); pte = pmap_pte_get(pde, va); pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); @@ -1039,10 +998,8 @@ pmap_page_remove(struct vm_page *pg) pmap->pm_stats.resident_count--; pmap_pte_set(pde, va, 0); - simple_unlock(&pmap->pm_lock); } pg->mdpage.pvh_list = NULL; - simple_unlock(&pg->mdpage.pvh_lock); DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_page_remove: leaving\n")); @@ -1056,7 +1013,6 @@ pmap_unwire(struct pmap *pmap, vaddr_t va) DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_unwire(%p, 0x%lx)\n", pmap, va)); - simple_lock(&pmap->pm_lock); if ((pde = pmap_pde_get(pmap->pm_pdir, va))) { pte = pmap_pte_get(pde, va); @@ -1066,7 +1022,6 @@ pmap_unwire(struct pmap *pmap, vaddr_t va) pmap_pte_set(pde, va, pte); } } - simple_unlock(&pmap->pm_lock); DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_unwire: leaving\n")); @@ -1085,7 +1040,6 @@ pmap_changebit(struct vm_page *pg, pt_entry_t set, pt_entry_t clear) DPRINTF(PDB_FOLLOW|PDB_BITS, ("pmap_changebit(%p, %lx, %lx)\n", pg, (long)set, (long)clear)); - simple_lock(&pg->mdpage.pvh_lock); res = pg->mdpage.pvh_attrs = 0; for(pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { struct pmap *pmap = pve->pv_pmap; @@ -1093,7 +1047,6 @@ pmap_changebit(struct vm_page *pg, pt_entry_t set, pt_entry_t clear) volatile pt_entry_t *pde; pt_entry_t opte, pte; - simple_lock(&pmap->pm_lock); if ((pde = pmap_pde_get(pmap->pm_pdir, va))) { opte = pte = pmap_pte_get(pde, va); #ifdef PMAPDEBUG @@ -1113,9 +1066,7 @@ pmap_changebit(struct vm_page *pg, pt_entry_t set, pt_entry_t clear) pmap_pte_set(pde, va, pte); } } - simple_unlock(&pmap->pm_lock); } - simple_unlock(&pg->mdpage.pvh_lock); return ((res & (clear | set)) != 0); } @@ -1128,15 +1079,11 @@ pmap_testbit(struct vm_page *pg, pt_entry_t bit) DPRINTF(PDB_FOLLOW|PDB_BITS, ("pmap_testbit(%p, %lx)\n", pg, (long)bit)); - simple_lock(&pg->mdpage.pvh_lock); for(pve = pg->mdpage.pvh_list; !(pg->mdpage.pvh_attrs & bit) && pve; pve = pve->pv_next) { - simple_lock(&pve->pv_pmap->pm_lock); pte = pmap_vp_find(pve->pv_pmap, pve->pv_va); - simple_unlock(&pve->pv_pmap->pm_lock); pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); } - simple_unlock(&pg->mdpage.pvh_lock); return ((pg->mdpage.pvh_attrs & bit) != 0); } @@ -1149,9 +1096,7 @@ pmap_extract(struct pmap *pmap, vaddr_t va, paddr_t *pap) DPRINTF(PDB_FOLLOW|PDB_EXTRACT, ("pmap_extract(%p, %lx)\n", pmap, va)); - simple_lock(&pmap->pm_lock); pte = pmap_vp_find(pmap, va); - simple_unlock(&pmap->pm_lock); if (pte) { if (pap) { @@ -1185,7 +1130,6 @@ pmap_flush_page(struct vm_page *pg, int purge) struct pv_entry *pve; /* purge cache for all possible mappings for the pa */ - simple_lock(&pg->mdpage.pvh_lock); for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { if (purge) pdcache(pve->pv_pmap->pm_space, pve->pv_va, PAGE_SIZE); @@ -1195,7 +1139,6 @@ pmap_flush_page(struct vm_page *pg, int purge) pdtlb(pve->pv_pmap->pm_space, pve->pv_va); pitlb(pve->pv_pmap->pm_space, pve->pv_va); } - simple_unlock(&pg->mdpage.pvh_lock); } void @@ -1236,8 +1179,6 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_kenter_pa(%lx, %lx, %x)\n", va, pa, prot)); - simple_lock(&pmap->pm_lock); - if (!(pde = pmap_pde_get(pmap_kernel()->pm_pdir, va)) && !(pde = pmap_pde_alloc(pmap_kernel(), va, NULL))) panic("pmap_kenter_pa: cannot allocate pde for va=0x%lx", va); @@ -1258,15 +1199,11 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - simple_lock(&pg->mdpage.pvh_lock); if (pmap_check_alias(pg->mdpage.pvh_list, va, pte)) Debugger(); - simple_unlock(&pg->mdpage.pvh_lock); } } #endif - simple_unlock(&pmap->pm_lock); - DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_kenter_pa: leaving\n")); } @@ -1288,8 +1225,6 @@ pmap_kremove(vaddr_t va, vsize_t size) } #endif - simple_lock(&pmap->pm_lock); - for (pdemask = 1, eva = va + size; va < eva; va += PAGE_SIZE) { if (pdemask != (va & (PDE_MASK|PIE_MASK))) { pdemask = va & (PDE_MASK|PIE_MASK); @@ -1309,17 +1244,13 @@ pmap_kremove(vaddr_t va, vsize_t size) pmap_pte_set(pde, va, 0); if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - simple_lock(&pg->mdpage.pvh_lock); pg->mdpage.pvh_attrs |= pmap_pvh_attrs(pte); /* just in case we have enter/kenter mismatch */ if ((pve = pmap_pv_remove(pg, pmap_kernel(), va))) pmap_pv_free(pve); - simple_unlock(&pg->mdpage.pvh_lock); } } - simple_unlock(&pmap->pm_lock); - DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_kremove: leaving\n")); } diff --git a/sys/arch/hppa64/include/pmap.h b/sys/arch/hppa64/include/pmap.h index 073df8ff66f..c9ce9c34661 100644 --- a/sys/arch/hppa64/include/pmap.h +++ b/sys/arch/hppa64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.13 2014/11/16 12:30:57 deraadt Exp $ */ +/* $OpenBSD: pmap.h,v 1.14 2014/12/17 15:26:21 deraadt Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -28,13 +28,11 @@ struct pv_entry; struct vm_page_md { - struct simplelock pvh_lock; /* locks every pv on this list */ struct pv_entry *pvh_list; /* head of list (locked by pvh_lock) */ u_int pvh_attrs; /* to preserve ref/mod */ }; #define VM_MDPAGE_INIT(pg) do { \ - simple_lock_init(&(pg)->mdpage.pvh_lock); \ (pg)->mdpage.pvh_list = NULL; \ (pg)->mdpage.pvh_attrs = 0; \ } while (0) -- 2.20.1