git: d9daa28c364d - main - sysctl vm.vm_objects: report cdev name for device-backed objects
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Oct 2024 10:15:09 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d9daa28c364d0b1189ab616d8d697b4c9f748038 commit d9daa28c364d0b1189ab616d8d697b4c9f748038 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-10 09:37:19 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-11 10:14:15 +0000 sysctl vm.vm_objects: report cdev name for device-backed objects Reviewed by: emaste. markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47038 --- sys/vm/vm_object.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 0b9a8af2ccb1..83d6b709e277 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -66,6 +66,7 @@ #include <sys/systm.h> #include <sys/blockcount.h> +#include <sys/conf.h> #include <sys/cpuset.h> #include <sys/ipc.h> #include <sys/jail.h> @@ -2506,8 +2507,10 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) struct vattr va; vm_object_t obj; vm_page_t m; + struct cdev *cdev; + struct cdevsw *csw; u_long sp; - int count, error; + int count, error, ref; key_t key; unsigned short seq; bool want_path; @@ -2594,6 +2597,17 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only) sp = swap_pager_swapped_pages(obj); kvo->kvo_swapped = sp > UINT32_MAX ? UINT32_MAX : sp; } + if (obj->type == OBJT_DEVICE || obj->type == OBJT_MGTDEVICE) { + cdev = obj->un_pager.devp.dev; + if (cdev != NULL) { + csw = dev_refthread(cdev, &ref); + if (csw != NULL) { + strlcpy(kvo->kvo_path, cdev->si_name, + sizeof(kvo->kvo_path)); + dev_relthread(cdev, ref); + } + } + } VM_OBJECT_RUNLOCK(obj); if ((obj->flags & OBJ_SYSVSHM) != 0) { kvo->kvo_flags |= KVMO_FLAG_SYSVSHM;