diff options
author | 2015-08-21 16:04:35 +0000 | |
---|---|---|
committer | 2015-08-21 16:04:35 +0000 | |
commit | 6f909936bb4c7686afdb3e0e32c083f29a5fb9c6 (patch) | |
tree | b66b8c02597ea82c3e206180c88a252e9861f663 | |
parent | Switch iked to C99-style fixed-width integer types. (diff) | |
download | wireguard-openbsd-6f909936bb4c7686afdb3e0e32c083f29a5fb9c6.tar.xz wireguard-openbsd-6f909936bb4c7686afdb3e0e32c083f29a5fb9c6.zip |
Remove the unused loan_count field and the related uvm logic. Most of
the page loaning code is already in the Attic.
ok kettenis@, beck@
-rw-r--r-- | sys/uvm/uvm_amap.c | 15 | ||||
-rw-r--r-- | sys/uvm/uvm_anon.c | 93 | ||||
-rw-r--r-- | sys/uvm/uvm_anon.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_aobj.c | 12 | ||||
-rw-r--r-- | sys/uvm/uvm_fault.c | 190 | ||||
-rw-r--r-- | sys/uvm/uvm_map.c | 23 | ||||
-rw-r--r-- | sys/uvm/uvm_object.c | 18 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 41 | ||||
-rw-r--r-- | sys/uvm/uvm_page.h | 5 | ||||
-rw-r--r-- | sys/uvm/uvm_pdaemon.c | 46 | ||||
-rw-r--r-- | sys/uvm/uvm_pmemrange.c | 4 |
11 files changed, 56 insertions, 394 deletions
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index 25f5ae1d86b..ef8e5058bf1 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.58 2014/12/23 04:56:47 tedu Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.59 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -613,8 +613,6 @@ amap_copy(struct vm_map *map, struct vm_map_entry *entry, int waitf, * so we resolve the COW here. * * => assume parent's entry was wired, thus all pages are resident. - * => assume pages that are loaned out (loan_count) are already mapped - * read-only in all maps, and thus no need for us to worry about them * => caller passes child's map/entry in to us * => XXXCDC: out of memory should cause fork to fail, but there is * currently no easy way to do this (needs fix) @@ -646,15 +644,10 @@ ReStart: " in anon %p", anon); /* - * if the anon ref count is one and the page is not loaned, - * then we are safe (the child has exclusive access to the - * page). if the page is loaned, then it must already be - * mapped read-only. - * - * we only need to get involved when these are not true. - * [note: if loan_count == 0, then the anon must own the page] + * if the anon ref count is one, we are safe (the child has + * exclusive access to the page). */ - if (anon->an_ref > 1 && pg->loan_count == 0) { + if (anon->an_ref > 1) { /* * if the page is busy then we have to wait for * it and then restart. diff --git a/sys/uvm/uvm_anon.c b/sys/uvm/uvm_anon.c index 4cea58096f9..2b17264b6ee 100644 --- a/sys/uvm/uvm_anon.c +++ b/sys/uvm/uvm_anon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_anon.c,v 1.43 2014/12/23 04:56:47 tedu Exp $ */ +/* $OpenBSD: uvm_anon.c,v 1.44 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_anon.c,v 1.10 2000/11/25 06:27:59 chs Exp $ */ /* @@ -86,47 +86,24 @@ uvm_anfree(struct vm_anon *anon) pg = anon->an_page; /* - * if there is a resident page and it is loaned, then anon may not - * own it. call out to uvm_anon_lockpage() to ensure the real owner - * of the page has been identified and locked. - */ - if (pg && pg->loan_count) - pg = uvm_anon_lockloanpg(anon); - - /* * if we have a resident page, we must dispose of it before freeing * the anon. */ if (pg) { /* - * if the page is owned by a uobject, then we must - * kill the loan on the page rather than free it. + * if page is busy then we just mark it as released (who ever + * has it busy must check for this when they wake up). if the + * page is not busy then we can free it now. */ - if (pg->uobject) { - uvm_lock_pageq(); - KASSERT(pg->loan_count > 0); - pg->loan_count--; - pg->uanon = NULL; - uvm_unlock_pageq(); - } else { - /* - * page has no uobject, so we must be the owner of it. - * - * if page is busy then we just mark it as released - * (who ever has it busy must check for this when they - * wake up). if the page is not busy then we can - * free it now. - */ - if ((pg->pg_flags & PG_BUSY) != 0) { - /* tell them to dump it when done */ - atomic_setbits_int(&pg->pg_flags, PG_RELEASED); - return; - } - pmap_page_protect(pg, PROT_NONE); - uvm_lock_pageq(); /* lock out pagedaemon */ - uvm_pagefree(pg); /* bye bye */ - uvm_unlock_pageq(); /* free the daemon */ - } + if ((pg->pg_flags & PG_BUSY) != 0) { + /* tell them to dump it when done */ + atomic_setbits_int(&pg->pg_flags, PG_RELEASED); + return; + } + pmap_page_protect(pg, PROT_NONE); + uvm_lock_pageq(); /* lock out pagedaemon */ + uvm_pagefree(pg); /* bye bye */ + uvm_unlock_pageq(); /* free the daemon */ } if (pg == NULL && anon->an_swslot != 0) { /* this page is no longer only in swap. */ @@ -162,50 +139,6 @@ uvm_anon_dropswap(struct vm_anon *anon) } /* - * uvm_anon_lockloanpg: given a locked anon, lock its resident page - * - * => on return: - * if there is a resident page: - * if it is ownerless, we take over as owner - * we return the resident page (it can change during - * this function) - * => note that the only time an anon has an ownerless resident page - * is if the page was loaned from a uvm_object and the uvm_object - * disowned it - * => this only needs to be called when you want to do an operation - * on an anon's resident page and that page has a non-zero loan - * count. - */ -struct vm_page * -uvm_anon_lockloanpg(struct vm_anon *anon) -{ - struct vm_page *pg; - - /* - * loop while we have a resident page that has a non-zero loan count. - * if we successfully get our lock, we will "break" the loop. - * note that the test for pg->loan_count is not protected -- this - * may produce false positive results. note that a false positive - * result may cause us to do more work than we need to, but it will - * not produce an incorrect result. - */ - while (((pg = anon->an_page) != NULL) && pg->loan_count != 0) { - /* - * if page is un-owned [i.e. the object dropped its ownership], - * then we can take over as owner! - */ - if (pg->uobject == NULL && (pg->pg_flags & PQ_ANON) == 0) { - uvm_lock_pageq(); - atomic_setbits_int(&pg->pg_flags, PQ_ANON); - pg->loan_count--; /* ... and drop our loan */ - uvm_unlock_pageq(); - } - break; - } - return(pg); -} - -/* * fetch an anon's page. * * => returns TRUE if pagein was aborted due to lack of memory. diff --git a/sys/uvm/uvm_anon.h b/sys/uvm/uvm_anon.h index f0a5800f0df..894f5031dec 100644 --- a/sys/uvm/uvm_anon.h +++ b/sys/uvm/uvm_anon.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_anon.h,v 1.18 2014/07/11 16:35:40 jsg Exp $ */ +/* $OpenBSD: uvm_anon.h,v 1.19 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_anon.h,v 1.13 2000/12/27 09:17:04 chs Exp $ */ /* @@ -80,7 +80,6 @@ struct vm_aref { struct vm_anon *uvm_analloc(void); void uvm_anfree(struct vm_anon *); void uvm_anon_init(void); -struct vm_page *uvm_anon_lockloanpg(struct vm_anon *); void uvm_anon_dropswap(struct vm_anon *); boolean_t uvm_anon_pagein(struct vm_anon *); #endif /* _KERNEL */ diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 09871fdcb34..0a6371048ce 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_aobj.c,v 1.79 2015/05/07 01:55:44 jsg Exp $ */ +/* $OpenBSD: uvm_aobj.c,v 1.80 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */ /* @@ -960,9 +960,8 @@ uao_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags) /* FALLTHROUGH */ case PGO_DEACTIVATE: deactivate_it: - /* skip the page if it's loaned or wired */ - if (pp->loan_count != 0 || - pp->wire_count != 0) + /* skip the page if it's wired */ + if (pp->wire_count != 0) continue; uvm_lock_pageq(); @@ -982,9 +981,8 @@ uao_flush(struct uvm_object *uobj, voff_t start, voff_t stop, int flags) if (uobj->uo_refs > 1) goto deactivate_it; - /* XXX skip the page if it's loaned or wired */ - if (pp->loan_count != 0 || - pp->wire_count != 0) + /* XXX skip the page if it's wired */ + if (pp->wire_count != 0) continue; /* zap all mappings for the page. */ diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index 2e6807ab553..a9bf2889fb2 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_fault.c,v 1.84 2015/03/14 03:38:53 jsg Exp $ */ +/* $OpenBSD: uvm_fault.c,v 1.85 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */ /* @@ -180,7 +180,7 @@ uvmfault_anonflush(struct vm_anon **anons, int n) if (anons[lcv] == NULL) continue; pg = anons[lcv]->an_page; - if (pg && (pg->pg_flags & PG_BUSY) == 0 && pg->loan_count == 0) { + if (pg && (pg->pg_flags & PG_BUSY) == 0) { uvm_lock_pageq(); if (pg->wire_count == 0) { pmap_page_protect(pg, PROT_NONE); @@ -258,8 +258,6 @@ uvmfault_amapcopy(struct uvm_faultinfo *ufi) * => we don't move the page on the queues [gets moved later] * => if we allocate a new page [we_own], it gets put on the queues. * either way, the result is that the page is on the queues at return time - * => for pages which are on loan from a uvm_object (and thus are not - * owned by the anon): if successful, we return with the owning object */ int uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, @@ -283,25 +281,17 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, we_own = FALSE; /* TRUE if we set PG_BUSY on a page */ pg = anon->an_page; - /* - * if there is a resident page and it is loaned, then anon - * may not own it. call out to uvm_anon_lockpage() to ensure - * the real owner of the page has been identified. - */ - if (pg && pg->loan_count) - pg = uvm_anon_lockloanpg(anon); - /* page there? make sure it is not busy/released. */ if (pg) { + KASSERT(pg->pg_flags & PQ_ANON); + KASSERT(pg->uanon == anon); + /* - * at this point, if the page has a uobject [meaning - * we have it on loan], then that uobject is locked - * by us! if the page is busy, we drop all the - * locks (including uobject) and try again. + * if the page is busy, we drop all the locks and + * try again. */ - if ((pg->pg_flags & (PG_BUSY|PG_RELEASED)) == 0) { + if ((pg->pg_flags & (PG_BUSY|PG_RELEASED)) == 0) return (VM_PAGER_OK); - } atomic_setbits_int(&pg->pg_flags, PG_WANTED); uvmexp.fltpgwait++; @@ -309,14 +299,8 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap, * the last unlock must be an atomic unlock+wait on * the owner of page */ - if (pg->uobject) { /* owner is uobject ? */ - uvmfault_unlockall(ufi, amap, NULL, anon); - UVM_WAIT(pg, FALSE, "anonget1",0); - } else { - /* anon owns page */ - uvmfault_unlockall(ufi, amap, NULL, NULL); - UVM_WAIT(pg, 0, "anonget2", 0); - } + uvmfault_unlockall(ufi, amap, NULL, NULL); + UVM_WAIT(pg, 0, "anonget2", 0); /* ready to relock and try again */ } else { /* no page, we must try and bring it in. */ @@ -694,8 +678,7 @@ ReFault: continue; } anon = anons[lcv]; - /* ignore loaned pages */ - if (anon->an_page && anon->an_page->loan_count == 0 && + if (anon->an_page && (anon->an_page->pg_flags & (PG_RELEASED|PG_BUSY)) == 0) { uvm_lock_pageq(); uvm_pageactivate(anon->an_page); /* reactivate */ @@ -881,73 +864,6 @@ ReFault: #endif } - /* uobj is non null if the page is on loan from an object (i.e. uobj) */ - uobj = anon->an_page->uobject; - - /* special handling for loaned pages */ - if (anon->an_page->loan_count) { - if ((access_type & PROT_WRITE) == 0) { - /* - * for read faults on loaned pages we just cap the - * protection at read-only. - */ - enter_prot = enter_prot & ~PROT_WRITE; - } else { - /* - * note that we can't allow writes into a loaned page! - * - * if we have a write fault on a loaned page in an - * anon then we need to look at the anon's ref count. - * if it is greater than one then we are going to do - * a normal copy-on-write fault into a new anon (this - * is not a problem). however, if the reference count - * is one (a case where we would normally allow a - * write directly to the page) then we need to kill - * the loan before we continue. - */ - - /* >1 case is already ok */ - if (anon->an_ref == 1) { - /* get new un-owned replacement page */ - pg = uvm_pagealloc(NULL, 0, NULL, 0); - if (pg == NULL) { - uvmfault_unlockall(&ufi, amap, uobj, - anon); - uvm_wait("flt_noram2"); - goto ReFault; - } - - /* copy data, kill loan */ - /* copy old -> new */ - uvm_pagecopy(anon->an_page, pg); - - /* force reload */ - pmap_page_protect(anon->an_page, PROT_NONE); - uvm_lock_pageq(); /* KILL loan */ - if (uobj) - /* if we were loaning */ - anon->an_page->loan_count--; - anon->an_page->uanon = NULL; - /* in case we owned */ - atomic_clearbits_int( - &anon->an_page->pg_flags, PQ_ANON); - uvm_pageactivate(pg); - uvm_unlock_pageq(); - if (uobj) { - uobj = NULL; - } - - /* install new page in anon */ - anon->an_page = pg; - pg->uanon = anon; - atomic_setbits_int(&pg->pg_flags, PQ_ANON); - atomic_clearbits_int(&pg->pg_flags, - PG_BUSY|PG_FAKE); - UVM_PAGE_OWN(pg, NULL); - } /* ref == 1 */ - } /* write fault */ - } /* loan count */ - /* * if we are case 1B then we will need to allocate a new blank * anon to transfer the data into. note that we have a lock @@ -973,7 +889,7 @@ ReFault: if (anon == NULL || pg == NULL) { if (anon) uvm_anfree(anon); - uvmfault_unlockall(&ufi, amap, uobj, oanon); + uvmfault_unlockall(&ufi, amap, NULL, oanon); KASSERT(uvmexp.swpgonly <= uvmexp.swpages); if (anon == NULL || uvmexp.swpgonly == uvmexp.swpages) { uvmexp.fltnoanon++; @@ -1025,7 +941,7 @@ ReFault: * We do, however, have to go through the ReFault path, * as the map may change while we're asleep. */ - uvmfault_unlockall(&ufi, amap, uobj, oanon); + uvmfault_unlockall(&ufi, amap, NULL, oanon); KASSERT(uvmexp.swpgonly <= uvmexp.swpages); if (uvmexp.swpgonly == uvmexp.swpages) { /* XXX instrumentation */ @@ -1057,7 +973,7 @@ ReFault: uvm_unlock_pageq(); /* done case 1! finish up by unlocking everything and returning success */ - uvmfault_unlockall(&ufi, amap, uobj, oanon); + uvmfault_unlockall(&ufi, amap, NULL, oanon); pmap_update(ufi.orig_map->pmap); return (0); @@ -1176,84 +1092,8 @@ Case2: /* assert(uobjpage != PGO_DONTCARE) */ /* - * we are faulting directly on the page. be careful - * about writing to loaned pages... + * we are faulting directly on the page. */ - if (uobjpage->loan_count) { - - if ((access_type & PROT_WRITE) == 0) { - /* read fault: cap the protection at readonly */ - /* cap! */ - enter_prot = enter_prot & ~PROT_WRITE; - } else { - /* write fault: must break the loan here */ - /* alloc new un-owned page */ - pg = uvm_pagealloc(NULL, 0, NULL, 0); - - if (pg == NULL) { - /* - * drop ownership of page, it can't - * be released - */ - if (uobjpage->pg_flags & PG_WANTED) - wakeup(uobjpage); - atomic_clearbits_int( - &uobjpage->pg_flags, - PG_BUSY|PG_WANTED); - UVM_PAGE_OWN(uobjpage, NULL); - - uvm_lock_pageq(); - /* activate: we will need it later */ - uvm_pageactivate(uobjpage); - - uvm_unlock_pageq(); - uvmfault_unlockall(&ufi, amap, uobj, - NULL); - uvmexp.fltnoram++; - uvm_wait("flt_noram4"); - goto ReFault; - } - - /* - * copy the data from the old page to the new - * one and clear the fake/clean flags on the - * new page (keep it busy). force a reload - * of the old page by clearing it from all - * pmaps. then lock the page queues to - * rename the pages. - */ - uvm_pagecopy(uobjpage, pg); /* old -> new */ - atomic_clearbits_int(&pg->pg_flags, - PG_FAKE|PG_CLEAN); - pmap_page_protect(uobjpage, PROT_NONE); - if (uobjpage->pg_flags & PG_WANTED) - wakeup(uobjpage); - atomic_clearbits_int(&uobjpage->pg_flags, - PG_BUSY|PG_WANTED); - UVM_PAGE_OWN(uobjpage, NULL); - - uvm_lock_pageq(); - uoff = uobjpage->offset; - /* remove old page */ - uvm_pagerealloc(uobjpage, NULL, 0); - - /* - * at this point we have absolutely no - * control over uobjpage - */ - /* install new page */ - uvm_pagerealloc(pg, uobj, uoff); - uvm_unlock_pageq(); - - /* - * done! loan is broken and "pg" is - * PG_BUSY. it can now replace uobjpage. - */ - - uobjpage = pg; - - } /* write fault case */ - } /* if loan_count */ } else { /* * if we are going to promote the data to an anon we diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 15ad44a21c9..c83a303febd 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.193 2015/08/19 12:23:25 visa Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.194 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -2940,8 +2940,8 @@ uvm_page_printit(pg, full, pr) (*pr)(" flags=%b, vers=%d, wire_count=%d, pa=0x%llx\n", pg->pg_flags, page_flagbits, pg->pg_version, pg->wire_count, (long long)pg->phys_addr); - (*pr)(" uobject=%p, uanon=%p, offset=0x%llx loan_count=%d\n", - pg->uobject, pg->uanon, (long long)pg->offset, pg->loan_count); + (*pr)(" uobject=%p, uanon=%p, offset=0x%llx\n", + pg->uobject, pg->uanon, (long long)pg->offset); #if defined(UVM_PAGE_TRKOWN) if (pg->pg_flags & PG_BUSY) (*pr)(" owning process = %d, tag=%s", @@ -4232,6 +4232,7 @@ uvm_map_clean(struct vm_map *map, vaddr_t start, vaddr_t end, int flags) if (pg == NULL) { continue; } + KASSERT(pg->pg_flags & PQ_ANON); switch (flags & (PGO_CLEANIT|PGO_FREE|PGO_DEACTIVATE)) { /* @@ -4244,24 +4245,12 @@ uvm_map_clean(struct vm_map *map, vaddr_t start, vaddr_t end, int flags) case PGO_CLEANIT|PGO_DEACTIVATE: case PGO_DEACTIVATE: deactivate_it: - /* skip the page if it's loaned or wired */ - if (pg->loan_count != 0 || - pg->wire_count != 0) { + /* skip the page if it's wired */ + if (pg->wire_count != 0) break; - } uvm_lock_pageq(); - /* - * skip the page if it's not actually owned - * by the anon (may simply be loaned to the - * anon). - */ - if ((pg->pg_flags & PQ_ANON) == 0) { - KASSERT(pg->uobject == NULL); - uvm_unlock_pageq(); - break; - } KASSERT(pg->uanon == anon); /* zap all mappings for the page. */ diff --git a/sys/uvm/uvm_object.c b/sys/uvm/uvm_object.c index cd0abfa74d4..6a666f15965 100644 --- a/sys/uvm/uvm_object.c +++ b/sys/uvm/uvm_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_object.c,v 1.12 2014/12/17 19:42:15 tedu Exp $ */ +/* $OpenBSD: uvm_object.c,v 1.13 2015/08/21 16:04:35 visa Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -92,22 +92,6 @@ uvm_objwire(struct uvm_object *uobj, voff_t start, voff_t end, KASSERT(pgs[i] != NULL); KASSERT(!(pgs[i]->pg_flags & PG_RELEASED)); -#if 0 - /* - * Loan break - */ - if (pgs[i]->loan_count) { - while (pgs[i]->loan_count) { - pg = uvm_loanbreak(pgs[i]); - if (!pg) { - uvm_wait("uobjwirepg"); - continue; - } - } - pgs[i] = pg; - } -#endif - if (pgs[i]->pg_flags & PQ_AOBJ) { atomic_clearbits_int(&pgs[i]->pg_flags, PG_CLEAN); diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 4534980aaa9..4f9eabf7be7 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.140 2015/07/19 22:52:30 beck Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.141 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -967,7 +967,6 @@ uvm_pagerealloc(struct vm_page *pg, struct uvm_object *newobj, voff_t newoff) void uvm_pagefree(struct vm_page *pg) { - int saved_loan_count = pg->loan_count; u_int flags_to_clear = 0; #ifdef DEBUG @@ -983,45 +982,9 @@ uvm_pagefree(struct vm_page *pg) * if the page was an object page (and thus "TABLED"), remove it * from the object. */ - if (pg->pg_flags & PG_TABLED) { - /* - * if the object page is on loan we are going to drop ownership. - * it is possible that an anon will take over as owner for this - * page later on. the anon will want a !PG_CLEAN page so that - * it knows it needs to allocate swap if it wants to page the - * page out. - */ - - /* in case an anon takes over */ - if (saved_loan_count) - atomic_clearbits_int(&pg->pg_flags, PG_CLEAN); + if (pg->pg_flags & PG_TABLED) uvm_pageremove(pg); - /* - * if our page was on loan, then we just lost control over it - * (in fact, if it was loaned to an anon, the anon may have - * already taken over ownership of the page by now and thus - * changed the loan_count [e.g. in uvmfault_anonget()]) we just - * return (when the last loan is dropped, then the page can be - * freed by whatever was holding the last loan). - */ - if (saved_loan_count) - return; - } else if (saved_loan_count && pg->uanon) { - /* - * if our page is owned by an anon and is loaned out to the - * kernel then we just want to drop ownership and return. - * the kernel must free the page when all its loans clear ... - * note that the kernel can't change the loan status of our - * page as long as we are holding PQ lock. - */ - atomic_clearbits_int(&pg->pg_flags, PQ_ANON); - pg->uanon->an_page = NULL; - pg->uanon = NULL; - return; - } - KASSERT(saved_loan_count == 0); - /* now remove the page from the queues */ if (pg->pg_flags & PQ_ACTIVE) { TAILQ_REMOVE(&uvm.page_active, pg, pageq); diff --git a/sys/uvm/uvm_page.h b/sys/uvm/uvm_page.h index 32119e7f597..aaf03181c81 100644 --- a/sys/uvm/uvm_page.h +++ b/sys/uvm/uvm_page.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.h,v 1.58 2015/04/22 03:48:52 dlg Exp $ */ +/* $OpenBSD: uvm_page.h,v 1.59 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */ /* @@ -105,9 +105,6 @@ struct vm_page { u_int pg_version; /* version count */ u_int wire_count; /* wired down map refs [P] */ - u_int loan_count; /* number of active loans - * to read: [P] - * to modify: [P] */ paddr_t phys_addr; /* physical address of page */ psize_t fpgsz; /* free page range size */ diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c index 1e661a04e19..ea8961703e0 100644 --- a/sys/uvm/uvm_pdaemon.c +++ b/sys/uvm/uvm_pdaemon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pdaemon.c,v 1.75 2014/12/17 19:42:15 tedu Exp $ */ +/* $OpenBSD: uvm_pdaemon.c,v 1.76 2015/08/21 16:04:35 visa Exp $ */ /* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */ /* @@ -419,31 +419,9 @@ uvmpd_scan_inactive(struct pglist *pglst) continue; } - /* - * the only time we expect to see an ownerless page - * (i.e. a page with no uobject and !PQ_ANON) is if an - * anon has loaned a page from a uvm_object and the - * uvm_object has dropped the ownership. in that - * case, the anon can "take over" the loaned page - * and make it its own. - */ - - /* is page part of an anon or ownerless ? */ - if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) { + if (p->pg_flags & PQ_ANON) { anon = p->uanon; KASSERT(anon != NULL); - - /* - * if the page is ownerless, claim it in the - * name of "anon"! - */ - if ((p->pg_flags & PQ_ANON) == 0) { - KASSERT(p->loan_count > 0); - p->loan_count--; - atomic_setbits_int(&p->pg_flags, - PQ_ANON); - /* anon now owns it */ - } if (p->pg_flags & PG_BUSY) { uvmexp.pdbusy++; /* someone else owns page, skip it */ @@ -872,25 +850,15 @@ uvmpd_scan(void) p != NULL && (inactive_shortage > 0 || swap_shortage > 0); p = nextpg) { nextpg = TAILQ_NEXT(p, pageq); + + /* skip this page if it's busy. */ if (p->pg_flags & PG_BUSY) continue; - /* is page anon owned or ownerless? */ - if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) { + if (p->pg_flags & PQ_ANON) KASSERT(p->uanon != NULL); - - /* take over the page? */ - if ((p->pg_flags & PQ_ANON) == 0) { - KASSERT(p->loan_count > 0); - p->loan_count--; - atomic_setbits_int(&p->pg_flags, PQ_ANON); - } - } - - /* skip this page if it's busy. */ - if ((p->pg_flags & PG_BUSY) != 0) { - continue; - } + else + KASSERT(p->uobject != NULL); /* * if there's a shortage of swap, free any swap allocated diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c index cee67c0a721..f4a86c9936d 100644 --- a/sys/uvm/uvm_pmemrange.c +++ b/sys/uvm/uvm_pmemrange.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pmemrange.c,v 1.47 2015/08/19 12:24:30 visa Exp $ */ +/* $OpenBSD: uvm_pmemrange.c,v 1.48 2015/08/21 16:04:35 visa Exp $ */ /* * Copyright (c) 2009, 2010 Ariane van der Steldt <ariane@stack.nl> @@ -1244,12 +1244,10 @@ uvm_pmr_assertvalid(struct uvm_pmemrange *pmr) /* * Free pages are: * - not wired - * - not loaned * - have no vm_anon * - have no uvm_object */ KASSERT(i[lcv].wire_count == 0); - KASSERT(i[lcv].loan_count == 0); KASSERT(i[lcv].uanon == (void*)0xdeadbeef || i[lcv].uanon == NULL); KASSERT(i[lcv].uobject == (void*)0xdeadbeef || |