From nobody Wed Aug 21 20:50:24 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wpz4J4nRcz5Snx5; Wed, 21 Aug 2024 20:50:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wpz4J42T3z43YK; Wed, 21 Aug 2024 20:50:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724273424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K+HIeKKuaJ5bv+ni5pFwL2pZxtb2cVa/ZZP84L6zTAo=; b=GVGgV0P9AcplWkeE+/Qyr/GLvMKQ5bZ2Q7/t8QnkZckiS/uG3x5apwl9u9+X4Imul9QHi4 uYdFW2RXCMRcfD5Ta11aROaEuE0CRYLZdjv4GKqbG9yOi4HCe/b6ip5IfwWutKgIVj7/Gh cMx1YcGop5JgjYld3pyTiPao89Ekasf2Z2ZoHoKgTCaWiBjh0gsPauMX6Nrf1s/mkzPHa5 m0eapUkcKp17j4ESZMkrWLsP8s+rbn6SQXMt/+z7ne3x4ubEgTY7scZ5jx/1etpNHTsIUc vVYTfwfzOv7Jvftk8MIlUDgWVlXvdJseR13fbGkmDgs4C5rqWWl8NksWnJ3pIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724273424; a=rsa-sha256; cv=none; b=c4EImBQpAGsCs8QlcA66uhmw36kY5aMnhbzhydo0YmuFcxtyzKSAt/Mh8KdQCxDA6F8zr+ VoQqdbdJok9IbFa60W+NqMV7NCOv0bP941NSyKzc1hLmUUEJmJ+S16pfV8CGtbSdTl5L4X ALJSNf5U5w3bNm+d/q+tu3x96ioOCpMQAN5MqGvRVIwQ1D+brCt9XHadwdzBPlwEAmXw3E t2KA1HhiSoSCnRtFsn8nabHmMncufivw+5Zta+rh0UHBcJ1nQVN1YRJGYzNuDvcSyMZ4i9 dnfw2ehNXmFSYB7EWmbl0brqq6+4pdNzvDSNpVNVXe6kul/4izBJUB9Yp3qW7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724273424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K+HIeKKuaJ5bv+ni5pFwL2pZxtb2cVa/ZZP84L6zTAo=; b=sqQwEFtrGKfr1lPPTr0dFYwfmEZ9v3p9IGTn7ruIsfybD2OhtoGU9B+BZacx2siAuYNqcS 91XG1zOfk902NPcY9e0H+Q2PKl/1yi6nPvOYWInINKDXckFUbazMOO5vhTpweNjWcy4LL8 JAfjYycuKhr7GAnz+P3FhgmSy1rOspkmrC9lbxiKOKSFU+jedu84t4JO+kThsCZfkbVhPK uFDklcAFqPw3OqCz7L0vVcpKkRBrybGDWKsND6mdzK9GzhhczLdsTPgayBxRurcNerPkO8 yWR8qKthJdNR4n4luQ5RUrzPTKL8fnxIPnEMs56/ndNr+PyZq7TXGAs1GE3+Zw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Wpz4J3dVpzykf; Wed, 21 Aug 2024 20:50:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47LKoO8K022793; Wed, 21 Aug 2024 20:50:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LKoOAJ022790; Wed, 21 Aug 2024 20:50:24 GMT (envelope-from git) Date: Wed, 21 Aug 2024 20:50:24 GMT Message-Id: <202408212050.47LKoOAJ022790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: d48524e21f1a - main - dev_pager: define free_page for mgt devices List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d48524e21f1a49752485418324538755571ed13f Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=d48524e21f1a49752485418324538755571ed13f commit d48524e21f1a49752485418324538755571ed13f Author: Doug Moore AuthorDate: 2024-08-21 20:48:59 +0000 Commit: Doug Moore 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,