git: b0b18b57a55b - main - sysctl vm.objects: report objects backing posix shm segments

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 12:39:26 UTC
The branch main has been updated by kib:

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

commit b0b18b57a55b429cf3f625883da5dcb541b14960
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-07 01:55:16 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-08 12:38:15 +0000

    sysctl vm.objects: report objects backing posix shm segments
    
    Add the KVMO_FLAG_POSIXSHM flag.  Fill the path.
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D46970
---
 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 5703dababbe3..8f42cfa36476 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -582,6 +582,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 6b9f89790ccd..0b9a8af2ccb1 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2601,6 +2601,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);