git: dd7b4456983b - stable/14 - sysctl vm.objects: report objects backing posix shm segments

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 15 Oct 2024 15:05:36 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=dd7b4456983be8a7630aa23b0637b0954579abf0

commit dd7b4456983be8a7630aa23b0637b0954579abf0
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-07 01:55:16 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-15 14:50:17 +0000

    sysctl vm.objects: report objects backing posix shm segments
    
    (cherry picked from commit b0b18b57a55b429cf3f625883da5dcb541b14960)
---
 sys/sys/user.h     | 1 +
 sys/vm/vm_object.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/sys/sys/user.h b/sys/sys/user.h
index 7ae0779278a4..945a51f6c3de 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -584,6 +584,7 @@ struct kinfo_vmentry {
 #define	kve_obj		kve_type_spec._kve_obj
 
 #define	KVMO_FLAG_SYSVSHM	0x0001
+#define	KVMO_FLAG_POSIXSHM	0x0002
 
 /*
  * The "vm.objects" sysctl provides a list of all VM objects in the system
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 1dbebf139683..d0f367815469 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2612,6 +2612,11 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
 			kvo->kvo_vn_fileid = key;
 			kvo->kvo_vn_fsid_freebsd11 = seq;
 		}
+		if ((obj->flags & OBJ_POSIXSHM) != 0) {
+			kvo->kvo_flags |= KVMO_FLAG_POSIXSHM;
+			shm_get_path(obj, kvo->kvo_path,
+			    sizeof(kvo->kvo_path));
+		}
 		if (vp != NULL) {
 			vn_fullpath(vp, &fullpath, &freepath);
 			vn_lock(vp, LK_SHARED | LK_RETRY);