diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-04-15 21:35:17 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-04-15 21:35:17 +0000 |
commit | fa619d7bd2e087182c8c00dac32225a414d6de0a (patch) | |
tree | 83f81e0b5fa13cbcda9301d5beccc3fe5a9a5bbc /sys | |
parent | cb3d7d732eb032fd0f48f31a92c3db0acd7c0663 (diff) |
Add a bit of paranoia to uvm_pageinsert.
At various times diffs have had debugging that checked that we don't
insert a page into the tree on top of an existing page, leaking that
page's references. Until the recent hackathon (and introduction if
uvm_pagealloc_multi) the bufcache for example did a rb tree look up on
insert to check (under #ifdef DEBUG || 1) so instead just check it on
pageinsert every time, since RB_INSERT returns any duplicates so this
check is pretty much free.
``emphatically yes'' beck@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm_page.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 9db5d419b68..5cd691438df 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.105 2011/04/03 12:36:08 beck Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.106 2011/04/15 21:35:16 oga Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -156,11 +156,13 @@ static void uvm_pageremove(struct vm_page *); __inline static void uvm_pageinsert(struct vm_page *pg) { + struct vm_page *dupe; UVMHIST_FUNC("uvm_pageinsert"); UVMHIST_CALLED(pghist); KASSERT((pg->pg_flags & PG_TABLED) == 0); - /* XXX should we check duplicates? */ - RB_INSERT(uvm_objtree, &pg->uobject->memt, pg); + dupe = RB_INSERT(uvm_objtree, &pg->uobject->memt, pg); + /* not allowed to insert over another page */ + KASSERT(dupe == NULL); atomic_setbits_int(&pg->pg_flags, PG_TABLED); pg->uobject->uo_npages++; } |