sysctl vm.vm_objects: report cdev name for device-backed objects

(cherry picked from commit d9daa28c364d0b1189ab616d8d697b4c9f748038)
This commit is contained in:
Konstantin Belousov 2024-10-10 12:37:19 +03:00
parent cdc72c4960
commit dfe83ae4da

View file

@ -68,6 +68,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>
@ -2517,8 +2518,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;
@ -2605,6 +2608,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;