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
This commit is contained in:
Konstantin Belousov
2024-10-10 12:37:19 +03:00
parent ac9b565b1a
commit d9daa28c36
+15 -1
View File
@@ -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;