git: d3dd6bd40395 - main - kinfo_vmentry: report mappings of the SysV shm segments
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Oct 2024 08:25:02 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3dd6bd4039573eb74cd77da5b92e68b04296888
commit d3dd6bd4039573eb74cd77da5b92e68b04296888
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-05 09:15:12 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-07 08:22:12 +0000
kinfo_vmentry: report mappings of the SysV shm segments
Mark such mappings with the new flag KVME_FLAG_SYSVSHM.
Provide segment key in kve_vn_fileid, vnode never can back shm mapping.
Provide sequence number in kve_vn_fsid_freebsd11.
Reviewed by: markj (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D46959
---
sys/kern/kern_proc.c | 10 ++++++++++
sys/sys/user.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index c47f5a15f252..02d3b9fd69cd 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -42,6 +42,7 @@
#include <sys/eventhandler.h>
#include <sys/exec.h>
#include <sys/fcntl.h>
+#include <sys/ipc.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/limits.h>
@@ -60,6 +61,7 @@
#include <sys/sbuf.h>
#include <sys/sysent.h>
#include <sys/sched.h>
+#include <sys/shm.h>
#include <sys/smp.h>
#include <sys/stack.h>
#include <sys/stat.h>
@@ -2615,6 +2617,8 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags)
vm_offset_t addr;
unsigned int last_timestamp;
int error;
+ key_t key;
+ unsigned short seq;
bool guard, super;
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -2705,6 +2709,12 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags)
kve->kve_ref_count = obj->ref_count;
kve->kve_shadow_count = obj->shadow_count;
VM_OBJECT_RUNLOCK(obj);
+ if ((lobj->flags & OBJ_SYSVSHM) != 0) {
+ kve->kve_flags |= KVME_FLAG_SYSVSHM;
+ shmobjinfo(lobj, &key, &seq);
+ kve->kve_vn_fileid = key;
+ kve->kve_vn_fsid_freebsd11 = seq;
+ }
if (vp != NULL) {
vn_fullpath(vp, &fullpath, &freepath);
kve->kve_vn_type = vntype_to_kinfo(vp->v_type);
diff --git a/sys/sys/user.h b/sys/sys/user.h
index cd0535f0d765..00cfbf09b4d6 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -514,6 +514,7 @@ struct kinfo_lockf {
#define KVME_FLAG_GROWS_UP 0x00000010
#define KVME_FLAG_GROWS_DOWN 0x00000020
#define KVME_FLAG_USER_WIRED 0x00000040
+#define KVME_FLAG_SYSVSHM 0x00000080
#if defined(__amd64__)
#define KINFO_OVMENTRY_SIZE 1168