git: 6a3fbdc7e9c8 - main - kinfo_vmobject: report backing object of the SysV shm segments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Oct 2024 08:25:03 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=6a3fbdc7e9c8323a1c13c4afcc65f89cb47911e6
commit 6a3fbdc7e9c8323a1c13c4afcc65f89cb47911e6
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-05 09:20:21 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-07 08:22:12 +0000
kinfo_vmobject: report backing object of the SysV shm segments
Use reserved work for kvo_flags.
Mark such object with KVMO_FLAG_SYSVSHM.
Provide segment key in kvo_vn_fileid, vnode never can back shm mapping.
Provide sequence number in kvo_vn_fsid_freebsd11.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D46959
---
sys/sys/user.h | 5 ++++-
sys/vm/vm_object.c | 11 +++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 00cfbf09b4d6..1fd802b03a42 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -577,6 +577,8 @@ struct kinfo_vmentry {
#define kve_vn_fsid kve_type_spec._kve_vn_fsid
#define kve_obj kve_type_spec._kve_obj
+#define KVMO_FLAG_SYSVSHM 0x0001
+
/*
* The "vm.objects" sysctl provides a list of all VM objects in the system
* via an array of these entries.
@@ -600,7 +602,8 @@ struct kinfo_vmobject {
uint64_t kvo_me; /* Uniq handle for anon obj */
uint64_t _kvo_qspare[6];
uint32_t kvo_swapped; /* Number of swapped pages */
- uint32_t _kvo_ispare[7];
+ uint32_t kvo_flags;
+ uint32_t _kvo_ispare[6];
char kvo_path[PATH_MAX]; /* Pathname, if any. */
};
#define kvo_vn_fsid kvo_type_spec._kvo_vn_fsid
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 86f9271341df..85fc27d169d6 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -67,6 +67,7 @@
#include <sys/systm.h>
#include <sys/blockcount.h>
#include <sys/cpuset.h>
+#include <sys/ipc.h>
#include <sys/jail.h>
#include <sys/limits.h>
#include <sys/lock.h>
@@ -77,6 +78,7 @@
#include <sys/pctrie.h>
#include <sys/proc.h>
#include <sys/refcount.h>
+#include <sys/shm.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/resourcevar.h>
@@ -2506,6 +2508,8 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
vm_page_t m;
u_long sp;
int count, error;
+ key_t key;
+ unsigned short seq;
bool want_path;
if (req->oldptr == NULL) {
@@ -2553,6 +2557,7 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
kvo->kvo_memattr = obj->memattr;
kvo->kvo_active = 0;
kvo->kvo_inactive = 0;
+ kvo->kvo_flags = 0;
if (!swap_only) {
TAILQ_FOREACH(m, &obj->memq, listq) {
/*
@@ -2590,6 +2595,12 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
kvo->kvo_swapped = sp > UINT32_MAX ? UINT32_MAX : sp;
}
VM_OBJECT_RUNLOCK(obj);
+ if ((obj->flags & OBJ_SYSVSHM) != 0) {
+ kvo->kvo_flags |= KVMO_FLAG_SYSVSHM;
+ shmobjinfo(obj, &key, &seq);
+ kvo->kvo_vn_fileid = key;
+ kvo->kvo_vn_fsid_freebsd11 = seq;
+ }
if (vp != NULL) {
vn_fullpath(vp, &fullpath, &freepath);
vn_lock(vp, LK_SHARED | LK_RETRY);