diff options
-rw-r--r-- | sys/uvm/uvm.h | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_amap.c | 15 | ||||
-rw-r--r-- | sys/uvm/uvm_anon.c | 50 | ||||
-rw-r--r-- | sys/uvm/uvm_anon.h | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_aobj.c | 43 | ||||
-rw-r--r-- | sys/uvm/uvm_device.c | 10 | ||||
-rw-r--r-- | sys/uvm/uvm_fault.c | 28 | ||||
-rw-r--r-- | sys/uvm/uvm_km.c | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_map.c | 22 | ||||
-rw-r--r-- | sys/uvm/uvm_map.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 8 | ||||
-rw-r--r-- | sys/uvm/uvm_object.c | 9 | ||||
-rw-r--r-- | sys/uvm/uvm_object.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_page.h | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_pager.c | 43 | ||||
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 67 | ||||
-rw-r--r-- | sys/uvm/uvm_swap.c | 43 | ||||
-rw-r--r-- | sys/uvm/uvm_vnode.c | 44 |
19 files changed, 21 insertions, 394 deletions
diff --git a/sys/uvm/uvm.h b/sys/uvm/uvm.h index 14dac14dde2..5a68492a528 100644 --- a/sys/uvm/uvm.h +++ b/sys/uvm/uvm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm.h,v 1.48 2013/05/29 22:23:01 tedu Exp $ */ +/* $OpenBSD: uvm.h,v 1.49 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */ /* @@ -80,7 +80,6 @@ struct uvm { struct pglist page_inactive_swp;/* pages inactive (reclaim or free) */ struct pglist page_inactive_obj;/* pages inactive (reclaim or free) */ /* Lock order: object lock, pageqlock, then fpageqlock. */ - simple_lock_data_t pageqlock; /* lock for active/inactive page q */ struct mutex fpageqlock; /* lock for free page q + pdaemon */ boolean_t page_init_done; /* TRUE if uvm_page_init() finished */ boolean_t page_idle_zero; /* TRUE if we should try to zero @@ -98,14 +97,10 @@ struct uvm { /* static kernel map entry pool */ vm_map_entry_t kentry_free; /* free page pool */ - simple_lock_data_t kentry_lock; /* aio_done is locked by uvm.aiodoned_lock. */ TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */ - /* swap-related items */ - simple_lock_data_t swap_data_lock; - /* kernel object: to support anonymous pageable kernel memory */ struct uvm_object *kernel_object; }; diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index 73184c14ded..0433096ccbe 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.47 2013/05/23 01:42:59 tedu Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.48 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -509,10 +509,7 @@ amap_wipeout(struct vm_amap *amap) if (anon == NULL || anon->an_ref == 0) panic("amap_wipeout: corrupt amap"); - simple_lock(&anon->an_lock); /* lock anon */ - refs = --anon->an_ref; - simple_unlock(&anon->an_lock); if (refs == 0) { /* * we had the last reference to a vm_anon. free it. @@ -633,9 +630,7 @@ amap_copy(struct vm_map *map, struct vm_map_entry *entry, int waitf, srcamap->am_anon[entry->aref.ar_pageoff + lcv]; if (amap->am_anon[lcv] == NULL) continue; - simple_lock(&amap->am_anon[lcv]->an_lock); amap->am_anon[lcv]->an_ref++; - simple_unlock(&amap->am_anon[lcv]->an_lock); amap->am_bckptr[lcv] = amap->am_nused; amap->am_slots[amap->am_nused] = lcv; amap->am_nused++; @@ -715,7 +710,6 @@ ReStart: slot = amap->am_slots[lcv]; anon = amap->am_anon[slot]; - simple_lock(&anon->an_lock); pg = anon->an_page; /* @@ -765,10 +759,8 @@ ReStart: * we can't ... */ if (nanon) { - simple_lock(&nanon->an_lock); uvm_anfree(nanon); } - simple_unlock(&anon->an_lock); uvm_wait("cownowpage"); goto ReStart; } @@ -793,7 +785,6 @@ ReStart: uvm_unlock_pageq(); } - simple_unlock(&anon->an_lock); /* * done with this anon, next ...! */ @@ -999,9 +990,7 @@ amap_wiperange(struct vm_amap *amap, int slotoff, int slots) /* * drop anon reference count */ - simple_lock(&anon->an_lock); refs = --anon->an_ref; - simple_unlock(&anon->an_lock); if (refs == 0) { /* * we just eliminated the last reference to an anon. @@ -1054,11 +1043,9 @@ amap_swap_off(int startslot, int endslot) slot = am->am_slots[i]; anon = am->am_anon[slot]; - simple_lock(&anon->an_lock); swslot = anon->an_swslot; if (swslot < startslot || endslot <= swslot) { - simple_unlock(&anon->an_lock); continue; } diff --git a/sys/uvm/uvm_anon.c b/sys/uvm/uvm_anon.c index fb2b01d27f3..0c6e176f161 100644 --- a/sys/uvm/uvm_anon.c +++ b/sys/uvm/uvm_anon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_anon.c,v 1.35 2011/07/03 18:34:14 oga Exp $ */ +/* $OpenBSD: uvm_anon.c,v 1.36 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_anon.c,v 1.10 2000/11/25 06:27:59 chs Exp $ */ /* @@ -70,11 +70,9 @@ uvm_analloc(void) anon = pool_get(&uvm_anon_pool, PR_NOWAIT); if (anon) { - simple_lock_init(&anon->an_lock); anon->an_ref = 1; anon->an_page = NULL; anon->an_swslot = 0; - simple_lock(&anon->an_lock); } return(anon); } @@ -125,7 +123,6 @@ uvm_anfree(struct vm_anon *anon) pg->loan_count--; pg->uanon = NULL; uvm_unlock_pageq(); - simple_unlock(&pg->uobject->vmobjlock); } else { /* @@ -150,10 +147,8 @@ uvm_anfree(struct vm_anon *anon) } if (pg == NULL && anon->an_swslot != 0) { /* this page is no longer only in swap. */ - simple_lock(&uvm.swap_data_lock); KASSERT(uvmexp.swpgonly > 0); uvmexp.swpgonly--; - simple_unlock(&uvm.swap_data_lock); } /* @@ -208,7 +203,6 @@ struct vm_page * uvm_anon_lockloanpg(struct vm_anon *anon) { struct vm_page *pg; - boolean_t locked = FALSE; /* * loop while we have a resident page that has a non-zero loan count. @@ -221,44 +215,6 @@ uvm_anon_lockloanpg(struct vm_anon *anon) while (((pg = anon->an_page) != NULL) && pg->loan_count != 0) { - /* - * quickly check to see if the page has an object before - * bothering to lock the page queues. this may also produce - * a false positive result, but that's ok because we do a real - * check after that. - * - * XXX: quick check -- worth it? need volatile? - */ - - if (pg->uobject) { - - uvm_lock_pageq(); - if (pg->uobject) { /* the "real" check */ - locked = - simple_lock_try(&pg->uobject->vmobjlock); - } else { - /* object disowned before we got PQ lock */ - locked = TRUE; - } - uvm_unlock_pageq(); - - /* - * if we didn't get a lock (try lock failed), then we - * toggle our anon lock and try again - */ - - if (!locked) { - simple_unlock(&anon->an_lock); - - /* - * someone locking the object has a chance to - * lock us right now - */ - - simple_lock(&anon->an_lock); - continue; - } - } /* * if page is un-owned [i.e. the object dropped its ownership], @@ -350,9 +306,5 @@ uvm_anon_pagein(struct vm_anon *anon) * unlock the anon and we're done. */ - simple_unlock(&anon->an_lock); - if (uobj) { - simple_unlock(&uobj->vmobjlock); - } return FALSE; } diff --git a/sys/uvm/uvm_anon.h b/sys/uvm/uvm_anon.h index a2f927f24e1..effb7f4657a 100644 --- a/sys/uvm/uvm_anon.h +++ b/sys/uvm/uvm_anon.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_anon.h,v 1.15 2010/06/14 10:05:37 thib Exp $ */ +/* $OpenBSD: uvm_anon.h,v 1.16 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_anon.h,v 1.13 2000/12/27 09:17:04 chs Exp $ */ /* @@ -53,8 +53,6 @@ struct vm_anon { * PG_BUSY] */ int an_swslot; - - simple_lock_data_t an_lock; }; /* diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index e6e0f7f15b1..f668980602d 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_aobj.c,v 1.55 2012/04/12 14:59:26 ariane Exp $ */ +/* $OpenBSD: uvm_aobj.c,v 1.56 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */ /* @@ -382,8 +382,6 @@ static void uao_free(struct uvm_aobj *aobj) { - simple_unlock(&aobj->u_obj.vmobjlock); - if (UAO_USES_SWHASH(aobj)) { int i, hashbuckets = aobj->u_swhashmask + 1; @@ -411,9 +409,7 @@ uao_free(struct uvm_aobj *aobj) * this page is no longer * only in swap. */ - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly--; - simple_unlock(&uvm.swap_data_lock); } next = LIST_NEXT(elt, list); @@ -435,9 +431,7 @@ uao_free(struct uvm_aobj *aobj) uvm_swap_free(slot, 1); /* this page is no longer only in swap. */ - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly--; - simple_unlock(&uvm.swap_data_lock); } } free(aobj->u_swslots, M_UVMAOBJ); @@ -575,9 +569,7 @@ uao_init(void) void uao_reference(struct uvm_object *uobj) { - simple_lock(&uobj->vmobjlock); uao_reference_locked(uobj); - simple_unlock(&uobj->vmobjlock); } /* @@ -612,7 +604,6 @@ uao_reference_locked(struct uvm_object *uobj) void uao_detach(struct uvm_object *uobj) { - simple_lock(&uobj->vmobjlock); uao_detach_locked(uobj); } @@ -635,13 +626,11 @@ uao_detach_locked(struct uvm_object *uobj) * detaching from kernel_object is a noop. */ if (UVM_OBJ_IS_KERN_OBJECT(uobj)) { - simple_unlock(&uobj->vmobjlock); return; } uobj->uo_refs--; /* drop ref! */ if (uobj->uo_refs) { /* still more refs? */ - simple_unlock(&uobj->vmobjlock); return; } @@ -664,7 +653,6 @@ uao_detach_locked(struct uvm_object *uobj) uvm_unlock_pageq(); UVM_UNLOCK_AND_WAIT(pg, &uobj->vmobjlock, 0, "uao_det", 0); - simple_lock(&uobj->vmobjlock); uvm_lock_pageq(); continue; } @@ -747,7 +735,6 @@ uao_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags) atomic_setbits_int(&pp->pg_flags, PG_WANTED); UVM_UNLOCK_AND_WAIT(pp, &uobj->vmobjlock, 0, "uaoflsh", 0); - simple_lock(&uobj->vmobjlock); curoff -= PAGE_SIZE; continue; } @@ -971,9 +958,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, /* out of RAM? */ if (ptmp == NULL) { - simple_unlock(&uobj->vmobjlock); uvm_wait("uao_getpage"); - simple_lock(&uobj->vmobjlock); /* goto top of pps while loop */ continue; } @@ -996,7 +981,6 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, atomic_setbits_int(&ptmp->pg_flags, PG_WANTED); UVM_UNLOCK_AND_WAIT(ptmp, &uobj->vmobjlock, FALSE, "uao_get", 0); - simple_lock(&uobj->vmobjlock); continue; /* goto top of pps while loop */ } @@ -1038,9 +1022,7 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, * page in the swapped-out page. * unlock object for i/o, relock when done. */ - simple_unlock(&uobj->vmobjlock); rv = uvm_swap_get(ptmp, swslot, PGO_SYNCIO); - simple_lock(&uobj->vmobjlock); /* * I/O done. check for errors. @@ -1067,7 +1049,6 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, uvm_pagefree(ptmp); uvm_unlock_pageq(); - simple_unlock(&uobj->vmobjlock); return (rv); } } @@ -1094,7 +1075,6 @@ uao_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, * finally, unlock object and return. */ - simple_unlock(&uobj->vmobjlock); return(VM_PAGER_OK); } @@ -1132,7 +1112,6 @@ uao_swap_off(int startslot, int endslot) * walk the list of all aobjs. */ -restart: mtx_enter(&uao_list_lock); for (aobj = LIST_FIRST(&uao_list); @@ -1141,21 +1120,6 @@ restart: boolean_t rv; /* - * try to get the object lock, - * start all over if we fail. - * most of the time we'll get the aobj lock, - * so this should be a rare case. - */ - if (!simple_lock_try(&aobj->u_obj.vmobjlock)) { - mtx_leave(&uao_list_lock); - if (prevaobj) { - uao_detach_locked(&prevaobj->u_obj); - prevaobj = NULL; - } - goto restart; - } - - /* * add a ref to the aobj so it doesn't disappear * while we're working. */ @@ -1302,11 +1266,6 @@ uao_pagein_page(struct uvm_aobj *aobj, int pageidx) &pg, &npages, 0, VM_PROT_READ|VM_PROT_WRITE, 0, 0); /* unlocked: aobj */ - /* - * relock and finish up. - */ - simple_lock(&aobj->u_obj.vmobjlock); - switch (rv) { case VM_PAGER_OK: break; diff --git a/sys/uvm/uvm_device.c b/sys/uvm/uvm_device.c index 2cb3aa00c3f..a32bc5cefca 100644 --- a/sys/uvm/uvm_device.c +++ b/sys/uvm/uvm_device.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_device.c,v 1.40 2011/07/03 18:34:14 oga Exp $ */ +/* $OpenBSD: uvm_device.c,v 1.41 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_device.c,v 1.30 2000/11/25 06:27:59 chs Exp $ */ /* @@ -180,9 +180,7 @@ udv_attach(void *arg, vm_prot_t accessprot, voff_t off, vsize_t size) * bump reference count, unhold, return. */ - simple_lock(&lcv->u_obj.vmobjlock); lcv->u_obj.uo_refs++; - simple_unlock(&lcv->u_obj.vmobjlock); mtx_enter(&udv_lock); if (lcv->u_flags & UVM_DEVICE_WANTED) @@ -251,9 +249,7 @@ static void udv_reference(struct uvm_object *uobj) { - simple_lock(&uobj->vmobjlock); uobj->uo_refs++; - simple_unlock(&uobj->vmobjlock); } /* @@ -273,10 +269,8 @@ udv_detach(struct uvm_object *uobj) * loop until done */ again: - simple_lock(&uobj->vmobjlock); if (uobj->uo_refs > 1) { uobj->uo_refs--; - simple_unlock(&uobj->vmobjlock); return; } KASSERT(uobj->uo_npages == 0 && RB_EMPTY(&uobj->memt)); @@ -292,7 +286,6 @@ again: * lock interleaving. -- this is ok in this case since the * locks are both IPL_NONE */ - simple_unlock(&uobj->vmobjlock); msleep(udv, &udv_lock, PVM | PNORELOCK, "udv_detach", 0); goto again; } @@ -305,7 +298,6 @@ again: if (udv->u_flags & UVM_DEVICE_WANTED) wakeup(udv); mtx_leave(&udv_lock); - simple_unlock(&uobj->vmobjlock); free(udv, M_TEMP); } diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index ed0c2cf4202..b7d53d31197 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_fault.c,v 1.65 2012/04/12 11:55:43 ariane Exp $ */ +/* $OpenBSD: uvm_fault.c,v 1.66 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */ /* @@ -199,7 +199,6 @@ uvmfault_anonflush(struct vm_anon **anons, int n) for (lcv = 0 ; lcv < n ; lcv++) { if (anons[lcv] == NULL) continue; - simple_lock(&anons[lcv]->an_lock); pg = anons[lcv]->an_page; if (pg && (pg->pg_flags & PG_BUSY) == 0 && pg->loan_count == 0) { uvm_lock_pageq(); @@ -213,7 +212,6 @@ uvmfault_anonflush(struct vm_anon **anons, int n) } uvm_unlock_pageq(); } - simple_unlock(&anons[lcv]->an_lock); } } @@ -405,8 +403,6 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, */ locked = uvmfault_relock(ufi); - if (locked || we_own) - simple_lock(&anon->an_lock); /* * if we own the page (i.e. we set PG_BUSY), then we need @@ -437,7 +433,6 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, */ if (pg->pg_flags & PG_RELEASED) { pmap_page_protect(pg, VM_PROT_NONE); - simple_unlock(&anon->an_lock); uvm_anfree(anon); /* frees page for us */ if (locked) uvmfault_unlockall(ufi, amap, NULL, @@ -473,8 +468,6 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, if (locked) uvmfault_unlockall(ufi, amap, NULL, anon); - else - simple_unlock(&anon->an_lock); return (VM_PAGER_ERROR); } @@ -486,8 +479,6 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, uvm_lock_pageq(); uvm_pageactivate(pg); uvm_unlock_pageq(); - if (!locked) - simple_unlock(&anon->an_lock); } /* @@ -768,10 +759,8 @@ ReFault: /* flush object? */ if (uobj) { uoff = (startva - ufi.entry->start) + ufi.entry->offset; - simple_lock(&uobj->vmobjlock); (void) uobj->pgops->pgo_flush(uobj, uoff, uoff + (nback << PAGE_SHIFT), PGO_DEACTIVATE); - simple_unlock(&uobj->vmobjlock); } /* now forget about the backpages */ @@ -822,7 +811,6 @@ ReFault: continue; } anon = anons[lcv]; - simple_lock(&anon->an_lock); /* ignore loaned pages */ if (anon->an_page && anon->an_page->loan_count == 0 && (anon->an_page->pg_flags & (PG_RELEASED|PG_BUSY)) == 0) { @@ -844,7 +832,6 @@ ReFault: PMAP_CANFAIL | (VM_MAPENT_ISWIRED(ufi.entry) ? PMAP_WIRED : 0)); } - simple_unlock(&anon->an_lock); pmap_update(ufi.orig_map->pmap); } @@ -868,8 +855,6 @@ ReFault: */ if (uobj && shadowed == FALSE && uobj->pgops->pgo_fault != NULL) { - simple_lock(&uobj->vmobjlock); - /* locked: maps(read), amap (if there), uobj */ result = uobj->pgops->pgo_fault(&ufi, startva, pages, npages, centeridx, fault_type, access_type, @@ -896,8 +881,6 @@ ReFault: */ if (uobj && shadowed == FALSE) { - simple_lock(&uobj->vmobjlock); - /* locked (!shadowed): maps(read), amap (if there), uobj */ /* * the following call to pgo_get does _not_ change locking state @@ -1018,7 +1001,6 @@ ReFault: */ anon = anons[centeridx]; - simple_lock(&anon->an_lock); /* locked: maps(read), amap, anon */ @@ -1130,7 +1112,6 @@ ReFault: uvm_pageactivate(pg); uvm_unlock_pageq(); if (uobj) { - simple_unlock(&uobj->vmobjlock); uobj = NULL; } @@ -1353,7 +1334,6 @@ Case2: */ locked = uvmfault_relock(&ufi); - simple_lock(&uobj->vmobjlock); /* locked(locked): maps(read), amap(if !null), uobj, uobjpage */ /* locked(!locked): uobj, uobjpage */ @@ -1387,7 +1367,6 @@ Case2: atomic_clearbits_int(&uobjpage->pg_flags, PG_BUSY|PG_WANTED); UVM_PAGE_OWN(uobjpage, NULL); - simple_unlock(&uobj->vmobjlock); goto ReFault; } @@ -1599,7 +1578,6 @@ Case2: uvm_lock_pageq(); uvm_pageactivate(uobjpage); uvm_unlock_pageq(); - simple_unlock(&uobj->vmobjlock); uobj = NULL; } else { uvmexp.flt_przero++; @@ -1830,10 +1808,6 @@ uvmfault_unlockall(struct uvm_faultinfo *ufi, struct vm_amap *amap, struct uvm_object *uobj, struct vm_anon *anon) { - if (anon) - simple_unlock(&anon->an_lock); - if (uobj) - simple_unlock(&uobj->vmobjlock); uvmfault_unlockmaps(ufi, FALSE); } diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c index 3131053ecc9..2c8af0aa25d 100644 --- a/sys/uvm/uvm_km.c +++ b/sys/uvm/uvm_km.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_km.c,v 1.108 2012/11/10 11:18:45 kettenis Exp $ */ +/* $OpenBSD: uvm_km.c,v 1.109 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_km.c,v 1.42 2001/01/14 02:10:01 thorpej Exp $ */ /* @@ -282,7 +282,6 @@ uvm_km_pgremove(struct uvm_object *uobj, vaddr_t start, vaddr_t end) atomic_setbits_int(&pp->pg_flags, PG_WANTED); UVM_UNLOCK_AND_WAIT(pp, &uobj->vmobjlock, 0, "km_pgrm", 0); - simple_lock(&uobj->vmobjlock); curoff -= PAGE_SIZE; /* loop back to us */ continue; } @@ -295,9 +294,7 @@ uvm_km_pgremove(struct uvm_object *uobj, vaddr_t start, vaddr_t end) uvm_pagefree(pp); uvm_unlock_pageq(); } else if (slot != 0) { - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly--; - simple_unlock(&uvm.swap_data_lock); } } } @@ -522,14 +519,12 @@ uvm_km_alloc1(struct vm_map *map, vsize_t size, vsize_t align, boolean_t zeroit) loopva = kva; while (size) { - simple_lock(&uvm.kernel_object->vmobjlock); /* allocate ram */ pg = uvm_pagealloc(uvm.kernel_object, offset, NULL, 0); if (pg) { atomic_clearbits_int(&pg->pg_flags, PG_BUSY); UVM_PAGE_OWN(pg, NULL); } - simple_unlock(&uvm.kernel_object->vmobjlock); if (__predict_false(pg == NULL)) { if (curproc == uvm.pagedaemon_proc) { /* diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index e5496f4e0ee..af0aa631469 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.161 2013/04/17 23:22:42 tedu Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.162 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -491,9 +491,7 @@ uvm_mapent_addr_remove(struct vm_map *map, struct vm_map_entry *entry) */ #define uvm_map_reference(_map) \ do { \ - simple_lock(&map->ref_lock); \ map->ref_count++; \ - simple_unlock(&map->ref_lock); \ } while (0) /* @@ -1521,7 +1519,6 @@ uvm_mapent_alloc(struct vm_map *map, int flags) if (map->flags & VM_MAP_INTRSAFE || cold) { s = splvm(); - simple_lock(&uvm.kentry_lock); me = uvm.kentry_free; if (me == NULL) { ne = km_alloc(PAGE_SIZE, &kv_page, &kp_dirty, @@ -1542,7 +1539,6 @@ uvm_mapent_alloc(struct vm_map *map, int flags) } uvm.kentry_free = RB_LEFT(me, daddrs.addr_entry); uvmexp.kmapent++; - simple_unlock(&uvm.kentry_lock); splx(s); me->flags = UVM_MAP_STATIC; } else if (map == kernel_map) { @@ -1581,11 +1577,9 @@ uvm_mapent_free(struct vm_map_entry *me) if (me->flags & UVM_MAP_STATIC) { s = splvm(); - simple_lock(&uvm.kentry_lock); RB_LEFT(me, daddrs.addr_entry) = uvm.kentry_free; uvm.kentry_free = me; uvmexp.kmapent--; - simple_unlock(&uvm.kentry_lock); splx(s); } else if (me->flags & UVM_MAP_KMEM) { splassert(IPL_NONE); @@ -2295,7 +2289,6 @@ uvm_map_setup(struct vm_map *map, vaddr_t min, vaddr_t max, int flags) map->flags = flags; map->timestamp = 0; rw_init(&map->lock, "vmmaplk"); - simple_lock_init(&map->ref_lock); /* * Configure the allocators. @@ -2680,7 +2673,6 @@ uvm_map_init(void) * now set up static pool of kernel map entries ... */ - simple_lock_init(&uvm.kentry_lock); uvm.kentry_free = NULL; for (lcv = 0 ; lcv < MAX_KMAPENT ; lcv++) { RB_LEFT(&kernel_map_entry[lcv], daddrs.addr_entry) = @@ -3788,9 +3780,7 @@ uvm_map_deallocate(vm_map_t map) int c; struct uvm_map_deadq dead; - simple_lock(&map->ref_lock); c = --map->ref_count; - simple_unlock(&map->ref_lock); if (c > 0) { return; } @@ -4169,11 +4159,8 @@ uvm_map_clean(struct vm_map *map, vaddr_t start, vaddr_t end, int flags) if (anon == NULL) continue; - simple_lock(&anon->an_lock); /* XXX */ - pg = anon->an_page; if (pg == NULL) { - simple_unlock(&anon->an_lock); continue; } @@ -4191,7 +4178,6 @@ deactivate_it: /* skip the page if it's loaned or wired */ if (pg->loan_count != 0 || pg->wire_count != 0) { - simple_unlock(&anon->an_lock); break; } @@ -4205,7 +4191,6 @@ deactivate_it: if ((pg->pg_flags & PQ_ANON) == 0) { KASSERT(pg->uobject == NULL); uvm_unlock_pageq(); - simple_unlock(&anon->an_lock); break; } KASSERT(pg->uanon == anon); @@ -4217,7 +4202,6 @@ deactivate_it: uvm_pagedeactivate(pg); uvm_unlock_pageq(); - simple_unlock(&anon->an_lock); break; case PGO_FREE: @@ -4231,13 +4215,11 @@ deactivate_it: /* XXX skip the page if it's wired */ if (pg->wire_count != 0) { - simple_unlock(&anon->an_lock); break; } amap_unadd(&entry->aref, cp_start - entry->start); refs = --anon->an_ref; - simple_unlock(&anon->an_lock); if (refs == 0) uvm_anfree(anon); break; @@ -4262,11 +4244,9 @@ flush_object: ((flags & PGO_FREE) == 0 || ((entry->max_protection & VM_PROT_WRITE) != 0 && (entry->etype & UVM_ET_COPYONWRITE) == 0))) { - simple_lock(&uobj->vmobjlock); rv = uobj->pgops->pgo_flush(uobj, cp_start - entry->start + entry->offset, cp_end - entry->start + entry->offset, flags); - simple_unlock(&uobj->vmobjlock); if (rv == FALSE) error = EFAULT; diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index 9cf6827b609..236a533c46c 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.h,v 1.48 2012/04/11 11:23:22 ariane Exp $ */ +/* $OpenBSD: uvm_map.h,v 1.49 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */ /* @@ -297,7 +297,6 @@ struct vm_map { vsize_t size; /* virtual size */ int ref_count; /* Reference count */ - simple_lock_data_t ref_lock; /* Lock for ref_count field */ int flags; /* flags */ unsigned int timestamp; /* Version number */ diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 25c1306b87e..8ad58fb4501 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.91 2012/07/21 06:46:58 matthew Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.92 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -258,9 +258,6 @@ sys_mincore(struct proc *p, void *v, register_t *retval) amap = entry->aref.ar_amap; /* top layer */ uobj = entry->object.uvm_obj; /* bottom layer */ - if (uobj != NULL) - simple_lock(&uobj->vmobjlock); - for (/* nothing */; start < lim; start += PAGE_SIZE, pgi++) { *pgi = 0; if (amap != NULL) { @@ -290,9 +287,6 @@ sys_mincore(struct proc *p, void *v, register_t *retval) } } } - - if (uobj != NULL) - simple_unlock(&uobj->vmobjlock); } out: diff --git a/sys/uvm/uvm_object.c b/sys/uvm/uvm_object.c index ffd76a259e5..e6844f08c52 100644 --- a/sys/uvm/uvm_object.c +++ b/sys/uvm/uvm_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_object.c,v 1.6 2010/05/01 13:13:10 oga Exp $ */ +/* $OpenBSD: uvm_object.c,v 1.7 2013/05/30 15:17:59 tedu Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -73,7 +73,6 @@ uvm_objwire(struct uvm_object *uobj, off_t start, off_t end, left = (end - start) >> PAGE_SHIFT; - simple_lock(&uobj->vmobjlock); while (left) { npages = MIN(FETCH_PAGECOUNT, left); @@ -87,7 +86,6 @@ uvm_objwire(struct uvm_object *uobj, off_t start, off_t end, if (error) goto error; - simple_lock(&uobj->vmobjlock); for (i = 0; i < npages; i++) { KASSERT(pgs[i] != NULL); @@ -101,9 +99,7 @@ uvm_objwire(struct uvm_object *uobj, off_t start, off_t end, while (pgs[i]->loan_count) { pg = uvm_loanbreak(pgs[i]); if (!pg) { - simple_unlock(&uobj->vmobjlock); uvm_wait("uobjwirepg"); - simple_lock(&uobj->vmobjlock); continue; } } @@ -133,7 +129,6 @@ uvm_objwire(struct uvm_object *uobj, off_t start, off_t end, left -= npages; offset += npages << PAGE_SHIFT; } - simple_unlock(&uobj->vmobjlock); return 0; @@ -156,7 +151,6 @@ uvm_objunwire(struct uvm_object *uobj, off_t start, off_t end) struct vm_page *pg; off_t offset; - simple_lock(&uobj->vmobjlock); uvm_lock_pageq(); for (offset = start; offset < end; offset += PAGE_SIZE) { pg = uvm_pagelookup(uobj, offset); @@ -167,6 +161,5 @@ uvm_objunwire(struct uvm_object *uobj, off_t start, off_t end) uvm_pageunwire(pg); } uvm_unlock_pageq(); - simple_unlock(&uobj->vmobjlock); } #endif /* !SMALL_KERNEL */ diff --git a/sys/uvm/uvm_object.h b/sys/uvm/uvm_object.h index 65ae4445f81..83085701bdb 100644 --- a/sys/uvm/uvm_object.h +++ b/sys/uvm/uvm_object.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_object.h,v 1.18 2011/07/07 14:25:15 sobrado Exp $ */ +/* $OpenBSD: uvm_object.h,v 1.19 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_object.h,v 1.11 2001/03/09 01:02:12 chs Exp $ */ /* @@ -47,7 +47,6 @@ */ struct uvm_object { - simple_lock_data_t vmobjlock; /* lock on memt */ struct uvm_pagerops *pgops; /* pager ops */ RB_HEAD(uvm_objtree, vm_page) memt; /* pages in object */ int uo_npages; /* # of pages in memt */ diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 29a7fe92186..cdce265a4d0 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.123 2013/03/27 02:02:23 tedu Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.124 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -203,7 +203,6 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) TAILQ_INIT(&uvm.page_active); TAILQ_INIT(&uvm.page_inactive_swp); TAILQ_INIT(&uvm.page_inactive_obj); - simple_lock_init(&uvm.pageqlock); mtx_init(&uvm.fpageqlock, IPL_VM); uvm_pmr_init(); diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h index 9ab6f1481c7..428f82e3a5f 100644 --- a/sys/uvm/uvm_page.h +++ b/sys/uvm/uvm_page.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.h,v 1.48 2011/05/30 22:25:24 oga Exp $ */ +/* $OpenBSD: uvm_page.h,v 1.49 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */ /* @@ -299,8 +299,8 @@ int vm_physseg_find(paddr_t, int *); * macros */ -#define uvm_lock_pageq() simple_lock(&uvm.pageqlock) -#define uvm_unlock_pageq() simple_unlock(&uvm.pageqlock) +#define uvm_lock_pageq() /* lock */ +#define uvm_unlock_pageq() /* unlock */ #define uvm_lock_fpageq() mtx_enter(&uvm.fpageqlock); #define uvm_unlock_fpageq() mtx_leave(&uvm.fpageqlock); diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c index 389ab19725c..84ef7cf5e88 100644 --- a/sys/uvm/uvm_pager.c +++ b/sys/uvm/uvm_pager.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pager.c,v 1.60 2011/07/03 18:34:14 oga Exp $ */ +/* $OpenBSD: uvm_pager.c,v 1.61 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_pager.c,v 1.36 2000/11/27 18:26:41 chs Exp $ */ /* @@ -567,9 +567,6 @@ ReTry: * drop cluster and relock object (only if I/O is * not pending) */ - if (uobj) - /* required for dropcluster */ - simple_lock(&uobj->vmobjlock); if (*npages > 1 || pg == NULL) uvm_pager_dropcluster(uobj, pg, ppsp, npages, PGO_PDFREECLUST); @@ -586,9 +583,6 @@ ReTry: */ if (*npages > 1 || pg == NULL) { - if (uobj) { - simple_lock(&uobj->vmobjlock); - } uvm_pager_dropcluster(uobj, pg, ppsp, npages, PGO_REALLOCSWAP); /* @@ -602,15 +596,11 @@ ReTry: /* XXX daddr64_t -> int */ int nswblk = (result == VM_PAGER_AGAIN) ? swblk : 0; if (pg->pg_flags & PQ_ANON) { - simple_lock(&pg->uanon->an_lock); pg->uanon->an_swslot = nswblk; - simple_unlock(&pg->uanon->an_lock); } else { - simple_lock(&pg->uobject->vmobjlock); uao_set_swslot(pg->uobject, pg->offset >> PAGE_SHIFT, nswblk); - simple_unlock(&pg->uobject->vmobjlock); } } if (result == VM_PAGER_AGAIN) { @@ -653,8 +643,6 @@ ReTry: * to worry about. */ - if (uobj && (flags & PGO_PDFREECLUST) != 0) - simple_lock(&uobj->vmobjlock); return(result); } @@ -704,12 +692,10 @@ uvm_pager_dropcluster(struct uvm_object *uobj, struct vm_page *pg, */ if (!uobj) { if (ppsp[lcv]->pg_flags & PQ_ANON) { - simple_lock(&ppsp[lcv]->uanon->an_lock); if (flags & PGO_REALLOCSWAP) /* zap swap block */ ppsp[lcv]->uanon->an_swslot = 0; } else { - simple_lock(&ppsp[lcv]->uobject->vmobjlock); if (flags & PGO_REALLOCSWAP) uao_set_swslot(ppsp[lcv]->uobject, ppsp[lcv]->offset >> PAGE_SHIFT, 0); @@ -730,7 +716,6 @@ uvm_pager_dropcluster(struct uvm_object *uobj, struct vm_page *pg, PG_BUSY); UVM_PAGE_OWN(ppsp[lcv], NULL); - simple_unlock(&ppsp[lcv]->uanon->an_lock); /* kills anon and frees pg */ uvm_anfree(ppsp[lcv]->uanon); @@ -754,14 +739,6 @@ uvm_pager_dropcluster(struct uvm_object *uobj, struct vm_page *pg, pmap_clear_modify(ppsp[lcv]); atomic_setbits_int(&ppsp[lcv]->pg_flags, PG_CLEAN); } - - /* if anonymous cluster, unlock object and move on */ - if (!uobj) { - if (ppsp[lcv]->pg_flags & PQ_ANON) - simple_unlock(&ppsp[lcv]->uanon->an_lock); - else - simple_unlock(&ppsp[lcv]->uobject->vmobjlock); - } } } @@ -826,17 +803,9 @@ uvm_aio_aiodone(struct buf *bp) swap = (pg->pg_flags & PQ_SWAPBACKED) != 0; if (!swap) { uobj = pg->uobject; - simple_lock(&uobj->vmobjlock); } } KASSERT(swap || pg->uobject == uobj); - if (swap) { - if (pg->pg_flags & PQ_ANON) { - simple_lock(&pg->uanon->an_lock); - } else { - simple_lock(&pg->uobject->vmobjlock); - } - } /* * if this is a read and we got an error, mark the pages @@ -860,18 +829,8 @@ uvm_aio_aiodone(struct buf *bp) atomic_setbits_int(&pgs[i]->pg_flags, PG_CLEAN); atomic_clearbits_int(&pgs[i]->pg_flags, PG_FAKE); } - if (swap) { - if (pg->pg_flags & PQ_ANON) { - simple_unlock(&pg->uanon->an_lock); - } else { - simple_unlock(&pg->uobject->vmobjlock); - } - } } uvm_page_unbusy(pgs, npages); - if (!swap) { - simple_unlock(&uobj->vmobjlock); - } #ifdef UVM_SWAP_ENCRYPT freed: diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index d1ecf3e7284..aadaa598b72 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.62 2013/02/07 17:29:31 beck Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.63 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -465,10 +465,6 @@ uvmpd_scan_inactive(struct pglist *pglst) if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) { anon = p->uanon; KASSERT(anon != NULL); - if (!simple_lock_try(&anon->an_lock)) { - /* lock failed, skip this page */ - continue; - } /* * if the page is ownerless, claim it in the @@ -483,7 +479,6 @@ uvmpd_scan_inactive(struct pglist *pglst) /* anon now owns it */ } if (p->pg_flags & PG_BUSY) { - simple_unlock(&anon->an_lock); uvmexp.pdbusy++; /* someone else owns page, skip it */ continue; @@ -492,12 +487,7 @@ uvmpd_scan_inactive(struct pglist *pglst) } else { uobj = p->uobject; KASSERT(uobj != NULL); - if (!simple_lock_try(&uobj->vmobjlock)) { - /* lock failed, skip this page */ - continue; - } if (p->pg_flags & PG_BUSY) { - simple_unlock(&uobj->vmobjlock); uvmexp.pdbusy++; /* someone else owns page, skip it */ continue; @@ -514,9 +504,7 @@ uvmpd_scan_inactive(struct pglist *pglst) if (p->pg_flags & PG_CLEAN) { if (p->pg_flags & PQ_SWAPBACKED) { /* this page now lives only in swap */ - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly++; - simple_unlock(&uvm.swap_data_lock); } /* zap all mappings with pmap_page_protect... */ @@ -535,11 +523,6 @@ uvmpd_scan_inactive(struct pglist *pglst) /* remove from object */ anon->an_page = NULL; - simple_unlock(&anon->an_lock); - } else { - /* pagefree has already removed the - * page from the object */ - simple_unlock(&uobj->vmobjlock); } continue; } @@ -550,11 +533,6 @@ uvmpd_scan_inactive(struct pglist *pglst) */ if (free + uvmexp.paging > uvmexp.freetarg << 2) { - if (anon) { - simple_unlock(&anon->an_lock); - } else { - simple_unlock(&uobj->vmobjlock); - } continue; } @@ -570,11 +548,6 @@ uvmpd_scan_inactive(struct pglist *pglst) uvmexp.swpgonly == uvmexp.swpages) { dirtyreacts++; uvm_pageactivate(p); - if (anon) { - simple_unlock(&anon->an_lock); - } else { - simple_unlock(&uobj->vmobjlock); - } continue; } @@ -650,12 +623,6 @@ uvmpd_scan_inactive(struct pglist *pglst) &p->pg_flags, PG_BUSY); UVM_PAGE_OWN(p, NULL); - if (anon) - simple_unlock( - &anon->an_lock); - else - simple_unlock( - &uobj->vmobjlock); continue; } swcpages = 0; /* cluster is empty */ @@ -692,11 +659,6 @@ uvmpd_scan_inactive(struct pglist *pglst) if (swap_backed) { if (p) { /* if we just added a page to cluster */ - if (anon) - simple_unlock(&anon->an_lock); - else - simple_unlock(&uobj->vmobjlock); - /* cluster not full yet? */ if (swcpages < swnpages) continue; @@ -823,14 +785,6 @@ uvmpd_scan_inactive(struct pglist *pglst) /* relock p's object: page queues not lock yet, so * no need for "try" */ - /* !swap_backed case: already locked... */ - if (swap_backed) { - if (anon) - simple_lock(&anon->an_lock); - else - simple_lock(&uobj->vmobjlock); - } - #ifdef DIAGNOSTIC if (result == VM_PAGER_UNLOCK) panic("pagedaemon: pageout returned " @@ -856,7 +810,6 @@ uvmpd_scan_inactive(struct pglist *pglst) anon->an_page = NULL; p->uanon = NULL; - simple_unlock(&anon->an_lock); uvm_anfree(anon); /* kills anon */ pmap_page_protect(p, VM_PROT_NONE); anon = NULL; @@ -891,11 +844,6 @@ uvmpd_scan_inactive(struct pglist *pglst) * true for active queue]). */ - if (anon) - simple_unlock(&anon->an_lock); - else if (uobj) - simple_unlock(&uobj->vmobjlock); - if (nextpg && (nextpg->pg_flags & PQ_INACTIVE) == 0) { nextpg = TAILQ_FIRST(pglst); /* reload! */ } @@ -1009,8 +957,6 @@ uvmpd_scan(void) /* is page anon owned or ownerless? */ if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) { KASSERT(p->uanon != NULL); - if (!simple_lock_try(&p->uanon->an_lock)) - continue; /* take over the page? */ if ((p->pg_flags & PQ_ANON) == 0) { @@ -1018,9 +964,6 @@ uvmpd_scan(void) p->loan_count--; atomic_setbits_int(&p->pg_flags, PQ_ANON); } - } else { - if (!simple_lock_try(&p->uobject->vmobjlock)) - continue; } /* @@ -1028,10 +971,6 @@ uvmpd_scan(void) */ if ((p->pg_flags & PG_BUSY) != 0) { - if (p->pg_flags & PQ_ANON) - simple_unlock(&p->uanon->an_lock); - else - simple_unlock(&p->uobject->vmobjlock); continue; } @@ -1071,9 +1010,5 @@ uvmpd_scan(void) uvmexp.pddeact++; inactive_shortage--; } - if (p->pg_flags & PQ_ANON) - simple_unlock(&p->uanon->an_lock); - else - simple_unlock(&p->uobject->vmobjlock); } } diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index cf377792e29..54be0771b3d 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap.c,v 1.113 2013/05/03 13:57:46 florian Exp $ */ +/* $OpenBSD: uvm_swap.c,v 1.114 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */ /* @@ -92,9 +92,6 @@ * - swap_syscall_lock (sleep lock): this lock serializes the swapctl * system call and prevents the swap priority list from changing * while we are in the middle of a system call (e.g. SWAP_STATS). - * - uvm.swap_data_lock (simple_lock): this lock protects all swap data - * structures including the priority list, the swapdev structures, - * and the swapmap extent. * * each swap device has the following info: * - swap device in use (could be disabled, preventing future use) @@ -285,7 +282,6 @@ uvm_swap_init(void) LIST_INIT(&swap_priority); uvmexp.nswapdev = 0; - simple_lock_init(&uvm.swap_data_lock); if (!swapdev_vp && bdevvp(swapdev, &swapdev_vp)) panic("uvm_swap_init: can't get vnode for swap device"); @@ -330,7 +326,6 @@ uvm_swap_initcrypt_all(void) struct swappri *spp; int npages; - simple_lock(&uvm.swap_data_lock); LIST_FOREACH(spp, &swap_priority, spi_swappri) { CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) @@ -340,7 +335,6 @@ uvm_swap_initcrypt_all(void) uvm_swap_initcrypt(sdp, npages); } } - simple_unlock(&uvm.swap_data_lock); } void @@ -455,8 +449,6 @@ uvm_swap_finicrypt_all(void) struct swap_key *key; unsigned int nkeys; - simple_lock(&uvm.swap_data_lock); - LIST_FOREACH(spp, &swap_priority, spi_swappri) { CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) { if (sdp->swd_decrypt == NULL) @@ -470,7 +462,6 @@ uvm_swap_finicrypt_all(void) } while (key-- != sdp->swd_keys); } } - simple_unlock(&uvm.swap_data_lock); } #endif /* UVM_SWAP_ENCRYPT */ @@ -751,14 +742,12 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) */ priority = SCARG(uap, misc); spp = malloc(sizeof *spp, M_VMSWAP, M_WAITOK); - simple_lock(&uvm.swap_data_lock); if ((sdp = swaplist_find(vp, 1)) == NULL) { error = ENOENT; } else { swaplist_insert(sdp, spp, priority); swaplist_trim(); } - simple_unlock(&uvm.swap_data_lock); if (error) free(spp, M_VMSWAP); break; @@ -773,10 +762,8 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) */ priority = SCARG(uap, misc); - simple_lock(&uvm.swap_data_lock); if ((sdp = swaplist_find(vp, 0)) != NULL) { error = EBUSY; - simple_unlock(&uvm.swap_data_lock); break; } sdp = malloc(sizeof *sdp, M_VMSWAP, M_WAITOK|M_ZERO); @@ -793,7 +780,6 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) } swaplist_insert(sdp, spp, priority); - simple_unlock(&uvm.swap_data_lock); sdp->swd_pathlen = len; sdp->swd_path = malloc(sdp->swd_pathlen, M_VMSWAP, M_WAITOK); @@ -808,10 +794,8 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) */ if ((error = swap_on(p, sdp)) != 0) { - simple_lock(&uvm.swap_data_lock); (void) swaplist_find(vp, 1); /* kill fake entry */ swaplist_trim(); - simple_unlock(&uvm.swap_data_lock); if (vp->v_type == VREG) { crfree(sdp->swd_cred); } @@ -822,9 +806,7 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) break; case SWAP_OFF: - simple_lock(&uvm.swap_data_lock); if ((sdp = swaplist_find(vp, 0)) == NULL) { - simple_unlock(&uvm.swap_data_lock); error = ENXIO; break; } @@ -834,7 +816,6 @@ sys_swapctl(struct proc *p, void *v, register_t *retval) * can't stop swapping from it (again). */ if ((sdp->swd_flags & (SWF_INUSE|SWF_ENABLE)) == 0) { - simple_unlock(&uvm.swap_data_lock); error = EBUSY; break; } @@ -1016,13 +997,11 @@ swap_on(struct proc *p, struct swapdev *sdp) /* * now add the new swapdev to the drum and enable. */ - simple_lock(&uvm.swap_data_lock); swapdrum_add(sdp, npages); sdp->swd_npages = size; sdp->swd_flags &= ~SWF_FAKE; /* going live */ sdp->swd_flags |= (SWF_INUSE|SWF_ENABLE); uvmexp.swpages += size; - simple_unlock(&uvm.swap_data_lock); return (0); bad: @@ -1046,7 +1025,6 @@ swap_off(struct proc *p, struct swapdev *sdp) /* disable the swap area being removed */ sdp->swd_flags &= ~SWF_ENABLE; - simple_unlock(&uvm.swap_data_lock); /* * the idea is to find all the pages that are paged out to this @@ -1066,9 +1044,7 @@ swap_off(struct proc *p, struct swapdev *sdp) } if (error) { - simple_lock(&uvm.swap_data_lock); sdp->swd_flags |= SWF_ENABLE; - simple_unlock(&uvm.swap_data_lock); return (error); } @@ -1085,7 +1061,6 @@ swap_off(struct proc *p, struct swapdev *sdp) (void) VOP_CLOSE(sdp->swd_vp, FREAD|FWRITE, p->p_ucred, p); } - simple_lock(&uvm.swap_data_lock); uvmexp.swpages -= sdp->swd_npages; if (swaplist_find(sdp->swd_vp, 1) == NULL) @@ -1099,7 +1074,6 @@ swap_off(struct proc *p, struct swapdev *sdp) EX_WAITOK); extent_destroy(sdp->swd_ex); free(sdp, M_VMSWAP); - simple_unlock(&uvm.swap_data_lock); return (0); } @@ -1124,9 +1098,7 @@ swstrategy(struct buf *bp) * in it (i.e. the blocks we are doing I/O on). */ pageno = dbtob((u_int64_t)bp->b_blkno) >> PAGE_SHIFT; - simple_lock(&uvm.swap_data_lock); sdp = swapdrum_getsdp(pageno); - simple_unlock(&uvm.swap_data_lock); if (sdp == NULL) { bp->b_error = EINVAL; bp->b_flags |= B_ERROR; @@ -1481,7 +1453,6 @@ uvm_swap_alloc(int *nslots, boolean_t lessok) /* * lock data lock, convert slots into blocks, and enter loop */ - simple_lock(&uvm.swap_data_lock); ReTry: /* XXXMRG */ for (spp = LIST_FIRST(&swap_priority); spp != NULL; @@ -1507,7 +1478,6 @@ ReTry: /* XXXMRG */ CIRCLEQ_INSERT_TAIL(&spp->spi_swapdev, sdp, swd_next); sdp->swd_npginuse += *nslots; uvmexp.swpginuse += *nslots; - simple_unlock(&uvm.swap_data_lock); /* done! return drum slot number */ return(result + sdp->swd_drumoffset); } @@ -1520,7 +1490,6 @@ ReTry: /* XXXMRG */ } /* XXXMRG: END HACK */ - simple_unlock(&uvm.swap_data_lock); return 0; /* failed */ } @@ -1534,7 +1503,6 @@ uvm_swap_markbad(int startslot, int nslots) { struct swapdev *sdp; - simple_lock(&uvm.swap_data_lock); sdp = swapdrum_getsdp(startslot); if (sdp != NULL) { /* @@ -1545,7 +1513,6 @@ uvm_swap_markbad(int startslot, int nslots) */ sdp->swd_npgbad += nslots; } - simple_unlock(&uvm.swap_data_lock); } /* @@ -1573,7 +1540,6 @@ uvm_swap_free(int startslot, int nslots) * lookup and access the extent. */ - simple_lock(&uvm.swap_data_lock); sdp = swapdrum_getsdp(startslot); KASSERT(uvmexp.nswapdev >= 1); KASSERT(sdp != NULL); @@ -1605,7 +1571,6 @@ uvm_swap_free(int startslot, int nslots) } } #endif /* UVM_SWAP_ENCRYPT */ - simple_unlock(&uvm.swap_data_lock); } /* @@ -1645,9 +1610,7 @@ uvm_swap_get(struct vm_page *page, int swslot, int flags) /* * this page is (about to be) no longer only in swap. */ - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly--; - simple_unlock(&uvm.swap_data_lock); result = uvm_swap_io(&page, swslot, 1, B_READ | ((flags & PGO_SYNCIO) ? 0 : B_ASYNC)); @@ -1656,9 +1619,7 @@ uvm_swap_get(struct vm_page *page, int swslot, int flags) /* * oops, the read failed so it really is still only in swap. */ - simple_lock(&uvm.swap_data_lock); uvmexp.swpgonly++; - simple_unlock(&uvm.swap_data_lock); } return (result); @@ -1724,9 +1685,7 @@ uvm_swap_io(struct vm_page **pps, int startslot, int npages, int flags) * XXX - does this information stay the same over the whole * execution of this function? */ - simple_lock(&uvm.swap_data_lock); sdp = swapdrum_getsdp(startslot); - simple_unlock(&uvm.swap_data_lock); } /* diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index 130cf88ae0c..36691f59906 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_vnode.c,v 1.76 2011/07/04 20:35:35 deraadt Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.77 2013/05/30 15:17:59 tedu Exp $ */ /* $NetBSD: uvm_vnode.c,v 1.36 2000/11/24 20:34:01 chs Exp $ */ /* @@ -159,19 +159,16 @@ uvn_attach(void *arg, vm_prot_t accessprot) /* * first get a lock on the uvn. */ - simple_lock(&uvn->u_obj.vmobjlock); while (uvn->u_flags & UVM_VNODE_BLOCKED) { uvn->u_flags |= UVM_VNODE_WANTED; UVM_UNLOCK_AND_WAIT(uvn, &uvn->u_obj.vmobjlock, FALSE, "uvn_attach", 0); - simple_lock(&uvn->u_obj.vmobjlock); } /* * if we're mapping a BLK device, make sure it is a disk. */ if (vp->v_type == VBLK && bdevsw[major(vp->v_rdev)].d_type != D_DISK) { - simple_unlock(&uvn->u_obj.vmobjlock); /* drop lock */ return(NULL); } @@ -198,7 +195,6 @@ uvn_attach(void *arg, vm_prot_t accessprot) } /* unlock and return */ - simple_unlock(&uvn->u_obj.vmobjlock); return (&uvn->u_obj); } @@ -211,8 +207,6 @@ uvn_attach(void *arg, vm_prot_t accessprot) * it. */ uvn->u_flags = UVM_VNODE_ALOCK; - simple_unlock(&uvn->u_obj.vmobjlock); /* drop lock in case we sleep */ - /* XXX: curproc? */ if (vp->v_type == VBLK) { /* @@ -237,13 +231,11 @@ uvn_attach(void *arg, vm_prot_t accessprot) } /* relock object */ - simple_lock(&uvn->u_obj.vmobjlock); if (result != 0) { if (uvn->u_flags & UVM_VNODE_WANTED) wakeup(uvn); uvn->u_flags = 0; - simple_unlock(&uvn->u_obj.vmobjlock); /* drop lock */ return(NULL); } @@ -277,7 +269,6 @@ uvn_attach(void *arg, vm_prot_t accessprot) * reference count goes to zero [and we either free or persist]. */ vref(vp); - simple_unlock(&uvn->u_obj.vmobjlock); if (oldflags & UVM_VNODE_WANTED) wakeup(uvn); @@ -304,7 +295,6 @@ uvn_reference(struct uvm_object *uobj) struct uvm_vnode *uvn = (struct uvm_vnode *) uobj; #endif - simple_lock(&uobj->vmobjlock); #ifdef DEBUG if ((uvn->u_flags & UVM_VNODE_VALID) == 0) { printf("uvn_reference: ref=%d, flags=0x%x\n", uvn->u_flags, @@ -313,7 +303,6 @@ uvn_reference(struct uvm_object *uobj) } #endif uobj->uo_refs++; - simple_unlock(&uobj->vmobjlock); } /* @@ -332,11 +321,9 @@ uvn_detach(struct uvm_object *uobj) struct vnode *vp; int oldflags; - simple_lock(&uobj->vmobjlock); uobj->uo_refs--; /* drop ref! */ if (uobj->uo_refs) { /* still more refs */ - simple_unlock(&uobj->vmobjlock); return; } @@ -361,7 +348,6 @@ uvn_detach(struct uvm_object *uobj) if (uvn->u_flags & UVM_VNODE_CANPERSIST) { /* won't block */ uvn_flush(uobj, 0, 0, PGO_DEACTIVATE|PGO_ALLPAGES); - simple_unlock(&uobj->vmobjlock); vrele(vp); /* drop vnode reference */ return; } @@ -399,7 +385,6 @@ uvn_detach(struct uvm_object *uobj) uvn->u_flags |= UVM_VNODE_IOSYNC; UVM_UNLOCK_AND_WAIT(&uvn->u_nio, &uvn->u_obj.vmobjlock, FALSE, "uvn_term",0); - simple_lock(&uvn->u_obj.vmobjlock); } if ((uvn->u_flags & UVM_VNODE_RELKILL) == 0) @@ -415,7 +400,6 @@ uvn_detach(struct uvm_object *uobj) KASSERT(RB_EMPTY(&uobj->memt)); oldflags = uvn->u_flags; uvn->u_flags = 0; - simple_unlock(&uobj->vmobjlock); /* wake up any sleepers */ if (oldflags & UVM_VNODE_WANTED) @@ -464,9 +448,7 @@ uvm_vnp_terminate(struct vnode *vp) /* * lock object and check if it is valid */ - simple_lock(&uvn->u_obj.vmobjlock); if ((uvn->u_flags & UVM_VNODE_VALID) == 0) { - simple_unlock(&uvn->u_obj.vmobjlock); return; } @@ -539,7 +521,6 @@ uvm_vnp_terminate(struct vnode *vp) uvn->u_flags |= UVM_VNODE_IOSYNC; UVM_UNLOCK_AND_WAIT(&uvn->u_nio, &uvn->u_obj.vmobjlock, FALSE, "uvn_term",0); - simple_lock(&uvn->u_obj.vmobjlock); } /* @@ -578,7 +559,6 @@ uvm_vnp_terminate(struct vnode *vp) if (oldflags & UVM_VNODE_WANTED) wakeup(uvn); /* object lock still held */ - simple_unlock(&uvn->u_obj.vmobjlock); } @@ -756,7 +736,6 @@ uvn_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags) uvm_unlock_pageq(); UVM_UNLOCK_AND_WAIT(pp, &uobj->vmobjlock, 0, "uvn_flsh", 0); - simple_lock(&uobj->vmobjlock); uvm_lock_pageq(); curoff -= PAGE_SIZE; continue; @@ -802,7 +781,6 @@ ReTry: */ /* relock! */ - simple_lock(&uobj->vmobjlock); uvm_lock_pageq(); /* @@ -926,7 +904,6 @@ ReTry: uvn->u_flags |= UVM_VNODE_IOSYNC; UVM_UNLOCK_AND_WAIT(&uvn->u_nio, &uvn->u_obj.vmobjlock, FALSE, "uvn_flush",0); - simple_lock(&uvn->u_obj.vmobjlock); } if (uvn->u_flags & UVM_VNODE_IOSYNCWANTED) wakeup(&uvn->u_flags); @@ -1134,9 +1111,7 @@ uvn_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, /* out of RAM? */ if (ptmp == NULL) { - simple_unlock(&uobj->vmobjlock); uvm_wait("uvn_getpage"); - simple_lock(&uobj->vmobjlock); /* goto top of pps while loop */ continue; @@ -1154,7 +1129,6 @@ uvn_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, atomic_setbits_int(&ptmp->pg_flags, PG_WANTED); UVM_UNLOCK_AND_WAIT(ptmp, &uobj->vmobjlock, FALSE, "uvn_get",0); - simple_lock(&uobj->vmobjlock); continue; /* goto top of pps while loop */ } @@ -1194,7 +1168,6 @@ uvn_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, */ /* lock object. check for errors. */ - simple_lock(&uobj->vmobjlock); if (result != VM_PAGER_OK) { if (ptmp->pg_flags & PG_WANTED) /* object lock still held */ @@ -1206,7 +1179,6 @@ uvn_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, uvm_lock_pageq(); uvm_pagefree(ptmp); uvm_unlock_pageq(); - simple_unlock(&uobj->vmobjlock); return(result); } @@ -1232,7 +1204,6 @@ uvn_get(struct uvm_object *uobj, voff_t offset, struct vm_page **pps, * finally, unlock object and return. */ - simple_unlock(&uobj->vmobjlock); return (VM_PAGER_OK); } @@ -1271,13 +1242,11 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int npages, int flags, int rw) while (uvn->u_flags & UVM_VNODE_IOSYNC) { if (waitf == M_NOWAIT) { - simple_unlock(&uvn->u_obj.vmobjlock); return(VM_PAGER_AGAIN); } uvn->u_flags |= UVM_VNODE_IOSYNCWANTED; UVM_UNLOCK_AND_WAIT(&uvn->u_flags, &uvn->u_obj.vmobjlock, FALSE, "uvn_iosync",0); - simple_lock(&uvn->u_obj.vmobjlock); } /* @@ -1285,7 +1254,6 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int npages, int flags, int rw) */ if (file_offset >= uvn->u_size) { - simple_unlock(&uvn->u_obj.vmobjlock); return(VM_PAGER_BAD); } @@ -1298,7 +1266,6 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int npages, int flags, int rw) kva = uvm_pagermapin(pps, npages, mapinflags); if (kva == 0 && waitf == M_NOWAIT) { - simple_unlock(&uvn->u_obj.vmobjlock); return(VM_PAGER_AGAIN); } @@ -1309,7 +1276,6 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int npages, int flags, int rw) */ uvn->u_nio++; /* we have an I/O in progress! */ - simple_unlock(&uvn->u_obj.vmobjlock); /* NOTE: object now unlocked */ if (kva == 0) kva = uvm_pagermapin(pps, npages, @@ -1395,14 +1361,12 @@ uvn_io(struct uvm_vnode *uvn, vm_page_t *pps, int npages, int flags, int rw) * now clean up the object (i.e. drop I/O count) */ - simple_lock(&uvn->u_obj.vmobjlock); /* NOTE: object now locked! */ uvn->u_nio--; /* I/O DONE! */ if ((uvn->u_flags & UVM_VNODE_IOSYNC) != 0 && uvn->u_nio == 0) { wakeup(&uvn->u_nio); } - simple_unlock(&uvn->u_obj.vmobjlock); /* NOTE: object now unlocked! */ /* @@ -1460,10 +1424,8 @@ uvm_vnp_uncache(struct vnode *vp) * lock uvn part of the vnode and check to see if we need to do anything */ - simple_lock(&uvn->u_obj.vmobjlock); if ((uvn->u_flags & UVM_VNODE_VALID) == 0 || (uvn->u_flags & UVM_VNODE_BLOCKED) != 0) { - simple_unlock(&uvn->u_obj.vmobjlock); return(TRUE); } @@ -1474,7 +1436,6 @@ uvm_vnp_uncache(struct vnode *vp) uvn->u_flags &= ~UVM_VNODE_CANPERSIST; if (uvn->u_obj.uo_refs) { - simple_unlock(&uvn->u_obj.vmobjlock); return(FALSE); } @@ -1485,7 +1446,6 @@ uvm_vnp_uncache(struct vnode *vp) vref(vp); /* seems ok, even with VOP_LOCK */ uvn->u_obj.uo_refs++; /* value is now 1 */ - simple_unlock(&uvn->u_obj.vmobjlock); #ifdef VFSLCKDEBUG /* @@ -1543,7 +1503,6 @@ uvm_vnp_setsize(struct vnode *vp, voff_t newsize) /* * lock uvn and check for valid object, and if valid: do it! */ - simple_lock(&uvn->u_obj.vmobjlock); if (uvn->u_flags & UVM_VNODE_VALID) { /* @@ -1557,7 +1516,6 @@ uvm_vnp_setsize(struct vnode *vp, voff_t newsize) } uvn->u_size = newsize; } - simple_unlock(&uvn->u_obj.vmobjlock); /* * done |