git: d48524e21f1a - main - dev_pager: define free_page for mgt devices
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 21 Aug 2024 20:50:24 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=d48524e21f1a49752485418324538755571ed13f commit d48524e21f1a49752485418324538755571ed13f Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-08-21 20:48:59 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2024-08-21 20:48:59 +0000 dev_pager: define free_page for mgt devices Callers of cdev_pager_free_page in the kernel always have object->type == OBJT_MGTDEVICE. Define a function for them to call that skips the runtime type check in cdev_pager_free. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46389 --- sys/arm/nvidia/drm2/tegra_bo.c | 2 +- sys/compat/linuxkpi/common/src/linux_page.c | 2 +- sys/dev/drm2/ttm/ttm_bo_vm.c | 2 +- sys/dev/xen/gntdev/gntdev.c | 2 +- sys/dev/xen/privcmd/privcmd.c | 2 +- sys/vm/device_pager.c | 24 ++++++++++++++++++------ sys/vm/vm_pager.h | 1 + 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/sys/arm/nvidia/drm2/tegra_bo.c b/sys/arm/nvidia/drm2/tegra_bo.c index 08cd3de6a3fe..346118b78c2b 100644 --- a/sys/arm/nvidia/drm2/tegra_bo.c +++ b/sys/arm/nvidia/drm2/tegra_bo.c @@ -62,7 +62,7 @@ tegra_bo_destruct(struct tegra_bo *bo) for (i = 0; i < bo->npages; i++) { m = bo->m[i]; vm_page_busy_acquire(m, 0); - cdev_pager_free_page(bo->cdev_pager, m); + cdev_mgtdev_pager_free_page(bo->cdev_pager, m); m->flags &= ~PG_FICTITIOUS; vm_page_unwire_noq(m); vm_page_free(m); diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index d4f8e75a3251..25243382f9ea 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -436,7 +436,7 @@ retry: continue; if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) goto retry; - cdev_pager_free_page(devobj, page); + cdev_mgtdev_pager_free_page(devobj, page); } VM_OBJECT_WUNLOCK(devobj); vm_object_deallocate(devobj); diff --git a/sys/dev/drm2/ttm/ttm_bo_vm.c b/sys/dev/drm2/ttm/ttm_bo_vm.c index 4f6c66382453..e543b8dfb993 100644 --- a/sys/dev/drm2/ttm/ttm_bo_vm.c +++ b/sys/dev/drm2/ttm/ttm_bo_vm.c @@ -376,7 +376,7 @@ retry: continue; if (vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL) == 0) goto retry; - cdev_pager_free_page(vm_obj, m); + cdev_mgtdev_pager_free_page(vm_obj, m); } VM_OBJECT_WUNLOCK(vm_obj); diff --git a/sys/dev/xen/gntdev/gntdev.c b/sys/dev/xen/gntdev/gntdev.c index 4530feb1c76d..49f8aefad62e 100644 --- a/sys/dev/xen/gntdev/gntdev.c +++ b/sys/dev/xen/gntdev/gntdev.c @@ -600,7 +600,7 @@ retry: continue; if (vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL) == 0) goto retry; - cdev_pager_free_page(gmap->map->mem, m); + cdev_mgtdev_pager_free_page(gmap->map->mem, m); } VM_OBJECT_WUNLOCK(gmap->map->mem); diff --git a/sys/dev/xen/privcmd/privcmd.c b/sys/dev/xen/privcmd/privcmd.c index 02e268b23d42..c04ac287183b 100644 --- a/sys/dev/xen/privcmd/privcmd.c +++ b/sys/dev/xen/privcmd/privcmd.c @@ -135,7 +135,7 @@ retry: continue; if (vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL) == 0) goto retry; - cdev_pager_free_page(map->mem, m); + cdev_mgtdev_pager_free_page(map->mem, m); } VM_OBJECT_WUNLOCK(map->mem); diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c index 4f8651411851..a5be05efc6d9 100644 --- a/sys/vm/device_pager.c +++ b/sys/vm/device_pager.c @@ -262,13 +262,25 @@ void cdev_pager_free_page(vm_object_t object, vm_page_t m) { - VM_OBJECT_ASSERT_WLOCKED(object); - if (object->type == OBJT_MGTDEVICE) { - KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("unmanaged %p", m)); - pmap_remove_all(m); - (void)vm_page_remove(m); - } else if (object->type == OBJT_DEVICE) + if (object->type == OBJT_MGTDEVICE) + cdev_mgtdev_pager_free_page(object, m); + else if (object->type == OBJT_DEVICE) dev_pager_free_page(object, m); + else + KASSERT(false, + ("Invalid device type obj %p m %p", object, m)); +} + +void +cdev_mgtdev_pager_free_page(vm_object_t object, vm_page_t m) +{ + + VM_OBJECT_ASSERT_WLOCKED(object); + KASSERT((object->type == OBJT_MGTDEVICE && + (m->oflags & VPO_UNMANAGED) == 0), + ("Unmanaged device or page obj %p m %p", object, m)); + pmap_remove_all(m); + (void)vm_page_remove(m); } static void diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index 7d6b2e96b38c..d30bf349e411 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -300,6 +300,7 @@ vm_object_t cdev_pager_allocate(void *handle, enum obj_type tp, vm_ooffset_t foff, struct ucred *cred); vm_object_t cdev_pager_lookup(void *handle); void cdev_pager_free_page(vm_object_t object, vm_page_t m); +void cdev_mgtdev_pager_free_page(vm_object_t object, vm_page_t m); struct phys_pager_ops { int (*phys_pg_getpages)(vm_object_t vm_obj, vm_page_t *m, int count,