Date: Sat, 22 May 2021 09:46:36 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 4c4bb6da853b - stable/13 - vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops Message-ID: <202105220946.14M9ka85012590@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4c4bb6da853bb86f24483fefa5a676a3a6b6c556 commit 4c4bb6da853bb86f24483fefa5a676a3a6b6c556 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-05-07 17:46:51 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-05-22 09:38:30 +0000 vm_object_kvme_type(): reimplement by embedding kvme_type into pagerops (cherry picked from commit 00a3fe968b840ee197c32dfe4107dab730bd9915) --- sys/vm/default_pager.c | 2 ++ sys/vm/device_pager.c | 3 +++ sys/vm/phys_pager.c | 2 ++ sys/vm/sg_pager.c | 2 ++ sys/vm/swap_pager.c | 3 +++ sys/vm/vm_object.c | 35 ----------------------------------- sys/vm/vm_pager.c | 16 ++++++++++++++++ sys/vm/vm_pager.h | 1 + sys/vm/vnode_pager.c | 2 ++ 9 files changed, 31 insertions(+), 35 deletions(-) diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c index 758012692a48..d07a84f8c98e 100644 --- a/sys/vm/default_pager.c +++ b/sys/vm/default_pager.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/proc.h> #include <sys/resourcevar.h> #include <sys/rwlock.h> +#include <sys/user.h> #include <vm/vm.h> #include <vm/vm_object.h> @@ -71,6 +72,7 @@ static boolean_t default_pager_haspage(vm_object_t, vm_pindex_t, int *, * object is converted to swap pager type. */ const struct pagerops defaultpagerops = { + .pgo_kvme_type = KVME_TYPE_DEFAULT, .pgo_alloc = default_pager_alloc, .pgo_dealloc = default_pager_dealloc, .pgo_getpages = default_pager_getpages, diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c index 25affb114a47..567f8fe55817 100644 --- a/sys/vm/device_pager.c +++ b/sys/vm/device_pager.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mman.h> #include <sys/rwlock.h> #include <sys/sx.h> +#include <sys/user.h> #include <sys/vmmeter.h> #include <vm/vm.h> @@ -75,6 +76,7 @@ static struct pagerlst dev_pager_object_list; static struct mtx dev_pager_mtx; const struct pagerops devicepagerops = { + .pgo_kvme_type = KVME_TYPE_DEVICE, .pgo_init = dev_pager_init, .pgo_alloc = dev_pager_alloc, .pgo_dealloc = dev_pager_dealloc, @@ -84,6 +86,7 @@ const struct pagerops devicepagerops = { }; const struct pagerops mgtdevicepagerops = { + .pgo_kvme_type = KVME_TYPE_MGTDEVICE, .pgo_alloc = dev_pager_alloc, .pgo_dealloc = dev_pager_dealloc, .pgo_getpages = dev_pager_getpages, diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c index af7b10701b16..6d7c5a4a7291 100644 --- a/sys/vm/phys_pager.c +++ b/sys/vm/phys_pager.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mman.h> #include <sys/rwlock.h> #include <sys/sysctl.h> +#include <sys/user.h> #include <vm/vm.h> #include <vm/vm_param.h> @@ -299,6 +300,7 @@ phys_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, } const struct pagerops physpagerops = { + .pgo_kvme_type = KVME_TYPE_PHYS, .pgo_init = phys_pager_init, .pgo_alloc = phys_pager_alloc, .pgo_dealloc = phys_pager_dealloc, diff --git a/sys/vm/sg_pager.c b/sys/vm/sg_pager.c index 9b3e60bc170a..d7af2aed935a 100644 --- a/sys/vm/sg_pager.c +++ b/sys/vm/sg_pager.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/rwlock.h> #include <sys/sglist.h> +#include <sys/user.h> #include <sys/vmmeter.h> #include <vm/vm.h> @@ -60,6 +61,7 @@ static boolean_t sg_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); const struct pagerops sgpagerops = { + .pgo_kvme_type = KVME_TYPE_SG, .pgo_alloc = sg_pager_alloc, .pgo_dealloc = sg_pager_dealloc, .pgo_getpages = sg_pager_getpages, diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 57c953542a88..37db4cbac857 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysproto.h> #include <sys/systm.h> #include <sys/sx.h> +#include <sys/user.h> #include <sys/vmmeter.h> #include <sys/vnode.h> @@ -442,6 +443,7 @@ static void swap_pager_freespace(vm_object_t object, vm_pindex_t start, vm_size_t size); const struct pagerops swappagerops = { + .pgo_kvme_type = KVME_TYPE_SWAP, .pgo_init = swap_pager_init, /* early system initialization of pager */ .pgo_alloc = swap_pager_alloc, /* allocate an OBJT_SWAP object */ .pgo_dealloc = swap_pager_dealloc, /* deallocate an OBJT_SWAP object */ @@ -456,6 +458,7 @@ const struct pagerops swappagerops = { }; const struct pagerops swaptmpfspagerops = { + .pgo_kvme_type = KVME_TYPE_VNODE, .pgo_alloc = swap_tmpfs_pager_alloc, .pgo_dealloc = swap_pager_dealloc, .pgo_getpages = swap_pager_getpages, diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 1c4e879d82ea..735ab603a09b 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2469,41 +2469,6 @@ vm_object_busy_wait(vm_object_t obj, const char *wmesg) (void)blockcount_sleep(&obj->busy, NULL, wmesg, PVM); } -/* - * Return the kvme type of the given object. - * If vpp is not NULL, set it to the object's vm_object_vnode() or NULL. - */ -int -vm_object_kvme_type(vm_object_t object, struct vnode **vpp) -{ - - VM_OBJECT_ASSERT_LOCKED(object); - if (vpp != NULL) - *vpp = vm_object_vnode(object); - switch (object->type) { - case OBJT_DEFAULT: - return (KVME_TYPE_DEFAULT); - case OBJT_VNODE: - return (KVME_TYPE_VNODE); - case OBJT_SWAP: - return (KVME_TYPE_SWAP); - case OBJT_SWAP_TMPFS: - return (KVME_TYPE_VNODE); - case OBJT_DEVICE: - return (KVME_TYPE_DEVICE); - case OBJT_PHYS: - return (KVME_TYPE_PHYS); - case OBJT_DEAD: - return (KVME_TYPE_DEAD); - case OBJT_SG: - return (KVME_TYPE_SG); - case OBJT_MGTDEVICE: - return (KVME_TYPE_MGTDEVICE); - default: - return (KVME_TYPE_UNKNOWN); - } -} - static int sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) { diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 240847903f62..9476058a75bf 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -79,6 +79,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ucred.h> #include <sys/malloc.h> #include <sys/rwlock.h> +#include <sys/user.h> #include <vm/vm.h> #include <vm/vm_param.h> @@ -155,6 +156,7 @@ dead_pager_getvp(vm_object_t object, struct vnode **vpp, bool *vp_heldp) } static const struct pagerops deadpagerops = { + .pgo_kvme_type = KVME_TYPE_DEAD, .pgo_alloc = dead_pager_alloc, .pgo_dealloc = dead_pager_dealloc, .pgo_getpages = dead_pager_getpages, @@ -530,3 +532,17 @@ vm_object_mightbedirty(vm_object_t object) return (false); return (method(object)); } + +/* + * Return the kvme type of the given object. + * If vpp is not NULL, set it to the object's vm_object_vnode() or NULL. + */ +int +vm_object_kvme_type(vm_object_t object, struct vnode **vpp) +{ + VM_OBJECT_ASSERT_LOCKED(object); + + if (vpp != NULL) + *vpp = vm_object_vnode(object); + return (pagertab[object->type]->pgo_kvme_type); +} diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 68c5fe42351e..5e0261f818cf 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -71,6 +71,7 @@ typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start, vm_size_t size); struct pagerops { + int pgo_kvme_type; pgo_init_t *pgo_init; /* Initialize pager. */ pgo_alloc_t *pgo_alloc; /* Allocate pager. */ pgo_dealloc_t *pgo_dealloc; /* Disassociate. */ diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index c264fc992b26..08927b5671f6 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$"); #include <sys/rwlock.h> #include <sys/sf_buf.h> #include <sys/domainset.h> +#include <sys/user.h> #include <machine/atomic.h> @@ -108,6 +109,7 @@ static void vnode_pager_release_writecount(vm_object_t, vm_offset_t, static void vnode_pager_getvp(vm_object_t, struct vnode **, bool *); const struct pagerops vnodepagerops = { + .pgo_kvme_type = KVME_TYPE_VNODE, .pgo_alloc = vnode_pager_alloc, .pgo_dealloc = vnode_pager_dealloc, .pgo_getpages = vnode_pager_getpages,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105220946.14M9ka85012590>