git: f186252e0d6e - main - vm_object: add OBJ_SYSVSHM flag to indicate SysV shm backing object

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 07 Oct 2024 08:25:00 UTC
The branch main has been updated by kib:

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

commit f186252e0d6ef970a23c6af12ec34003df56055d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-05 09:08:51 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-07 08:22:12 +0000

    vm_object: add OBJ_SYSVSHM flag to indicate SysV shm backing object
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D46959
---
 sys/kern/sysv_shm.c | 4 ++++
 sys/vm/vm_object.h  | 1 +
 2 files changed, 5 insertions(+)

diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 90b95c7db8e7..4dbe77f19b07 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -742,6 +742,10 @@ shmget_allocate_segment(struct thread *td, key_t key, size_t size, int mode)
 		return (ENOMEM);
 	}
 
+	VM_OBJECT_WLOCK(shm_object);
+	vm_object_set_flag(shm_object, OBJ_SYSVSHM);
+	VM_OBJECT_WUNLOCK(shm_object);
+
 	shmseg->object = shm_object;
 	shmseg->u.shm_perm.cuid = shmseg->u.shm_perm.uid = cred->cr_uid;
 	shmseg->u.shm_perm.cgid = shmseg->u.shm_perm.gid = cred->cr_gid;
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 3eaab1282fa6..73284fddd2a6 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -201,6 +201,7 @@ struct vm_object {
 					   mapping flag */
 #define	OBJ_PAGERPRIV1	0x00004000	/* Pager private */
 #define	OBJ_PAGERPRIV2	0x00008000	/* Pager private */
+#define	OBJ_SYSVSHM	0x00010000	/* SysV SHM */
 
 /*
  * Helpers to perform conversion between vm_object page indexes and offsets.