summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2018-05-12 17:17:27 +0000
committerkrw <krw@openbsd.org>2018-05-12 17:17:27 +0000
commit7ace0ba63022455563986376303e3200ddbcd02e (patch)
tree26c72f1fc3da07f943ddf8273dded7e1e9d05def
parentminor consistency fix; from raf czlonka (diff)
downloadwireguard-openbsd-7ace0ba63022455563986376303e3200ddbcd02e.tar.xz
wireguard-openbsd-7ace0ba63022455563986376303e3200ddbcd02e.zip
Re-apply inadvertantly misplaced r1.127 from kettenis@:
"Buffer cache pages are wired but not counted as such. Therefore we have to set the wire count on the pages to 0 before we call uvm_pagefree() on them, just like we do in buf_free_pages(). Otherwise the wired pages counter goes negative. While there, also sprinkle some KASSERTs in there that buf_free_pages() has as well." ok beck@ (again)
-rw-r--r--sys/uvm/uvm_page.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c
index 4002c61dfad..4fa266c020b 100644
--- a/sys/uvm/uvm_page.c
+++ b/sys/uvm/uvm_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.c,v 1.146 2016/11/07 00:26:33 guenther Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.147 2018/05/12 17:17:27 krw Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
@@ -853,11 +853,14 @@ uvm_pagerealloc_multi(struct uvm_object *obj, voff_t off, vsize_t size,
while((pg = TAILQ_FIRST(&plist)) != NULL) {
offset = off + ptoa(i++);
tpg = uvm_pagelookup(obj, offset);
+ KASSERT(tpg != NULL);
pg->wire_count = 1;
atomic_setbits_int(&pg->pg_flags, PG_CLEAN | PG_FAKE);
KASSERT((pg->pg_flags & PG_DEV) == 0);
TAILQ_REMOVE(&plist, pg, pageq);
uvm_pagecopy(tpg, pg);
+ KASSERT(tpg->wire_count == 1);
+ tpg->wire_count = 0;
uvm_pagefree(tpg);
uvm_pagealloc_pg(pg, obj, offset, NULL);
}