diff options
author | 2019-11-29 22:10:04 +0000 | |
---|---|---|
committer | 2019-11-29 22:10:04 +0000 | |
commit | e91f82a5ac04f6d44a57117d10c9a01eb4d058ee (patch) | |
tree | 0e812eb0dc1b52627f20494e6d20148dfff0d8aa /sys/uvm | |
parent | Change the default security level for incoming IPsec flows from (diff) | |
download | wireguard-openbsd-e91f82a5ac04f6d44a57117d10c9a01eb4d058ee.tar.xz wireguard-openbsd-e91f82a5ac04f6d44a57117d10c9a01eb4d058ee.zip |
Add uvm_objfree function to free all pages in a uvm_obj in one go.
Use this in the buffer cache to free all the pages from a buffer,
resulting in a considerable speedup when throwing away pages from
the buffer cache.
Lots of work done with mlarkin and kettenis
ok kettinis@ deraadt@
Diffstat (limited to 'sys/uvm')
-rw-r--r-- | sys/uvm/uvm_object.c | 31 | ||||
-rw-r--r-- | sys/uvm/uvm_object.h | 3 |
2 files changed, 32 insertions, 2 deletions
diff --git a/sys/uvm/uvm_object.c b/sys/uvm/uvm_object.c index a326d7147f6..8fef418bd35 100644 --- a/sys/uvm/uvm_object.c +++ b/sys/uvm/uvm_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_object.c,v 1.14 2016/09/16 02:35:42 dlg Exp $ */ +/* $OpenBSD: uvm_object.c,v 1.15 2019/11/29 22:10:04 beck Exp $ */ /* * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -148,3 +148,32 @@ uvm_objunwire(struct uvm_object *uobj, voff_t start, voff_t end) uvm_unlock_pageq(); } #endif /* !SMALL_KERNEL */ + +/* + * uvm_objfree: free all pages in a uvm object, used by the buffer + * cache to free all pages attached to a buffer. + */ +void +uvm_objfree(struct uvm_object *uobj) +{ + struct vm_page *pg; + struct pglist pgl; + + TAILQ_INIT(&pgl); + /* + * Extract from rb tree in offset order. The phys addresses + * usually increase in that order, which is better for + * uvm_pmr_freepageq. + */ + RBT_FOREACH(pg, uvm_objtree, &uobj->memt) { + /* + * clear PG_TABLED so we don't do work to remove + * this pg from the uobj we are throwing away + */ + atomic_clearbits_int(&pg->pg_flags, PG_TABLED); + uvm_pageclean(pg); + TAILQ_INSERT_TAIL(&pgl, pg, pageq); + } + uvm_pmr_freepageq(&pgl); +} + diff --git a/sys/uvm/uvm_object.h b/sys/uvm/uvm_object.h index 0c453ef3d45..32e527e829f 100644 --- a/sys/uvm/uvm_object.h +++ b/sys/uvm/uvm_object.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_object.h,v 1.22 2016/09/16 02:35:42 dlg Exp $ */ +/* $OpenBSD: uvm_object.h,v 1.23 2019/11/29 22:10:04 beck Exp $ */ /* $NetBSD: uvm_object.h,v 1.11 2001/03/09 01:02:12 chs Exp $ */ /* @@ -92,6 +92,7 @@ RBT_PROTOTYPE(uvm_objtree, vm_page, objt, uvm_pagecmp) void uvm_objinit(struct uvm_object *, struct uvm_pagerops *, int); int uvm_objwire(struct uvm_object *, voff_t, voff_t, struct pglist *); void uvm_objunwire(struct uvm_object *, voff_t, voff_t); +void uvm_objfree(struct uvm_object *); #endif /* _KERNEL */ |