Date: Tue, 15 Oct 2024 15:05:33 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: ec35a9c65d2d - stable/14 - posix shm: mark backing objects with SHM_POSIXSHM flag Message-ID: <202410151505.49FF5XcJ089566@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ec35a9c65d2dc27f10097f08ee4ad3c2bf598471 commit ec35a9c65d2dc27f10097f08ee4ad3c2bf598471 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-07 01:26:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-15 14:50:17 +0000 posix shm: mark backing objects with SHM_POSIXSHM flag (cherry picked from commit a10870ecea813042db7c41e906e1a5c5693f8a34) --- sys/kern/uipc_shm.c | 16 +++++++++++----- sys/vm/vm_object.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 20dbe59e2a96..52a569931b01 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -944,15 +944,20 @@ shm_alloc(struct ucred *ucred, mode_t mode, bool largepage) shmfd->shm_gid = ucred->cr_gid; shmfd->shm_mode = mode; if (largepage) { - shmfd->shm_object = phys_pager_allocate(NULL, + obj = shmfd->shm_object = phys_pager_allocate(NULL, &shm_largepage_phys_ops, NULL, shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); + VM_OBJECT_WLOCK(shmfd->shm_object); + obj->un_pager.phys.phys_priv = shmfd; + vm_object_set_flag(obj, OBJ_POSIXSHM); + VM_OBJECT_WUNLOCK(shmfd->shm_object); shmfd->shm_lp_alloc_policy = SHM_LARGEPAGE_ALLOC_DEFAULT; } else { obj = vm_pager_allocate(shmfd_pager_type, NULL, shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); VM_OBJECT_WLOCK(obj); obj->un_pager.swp.swp_priv = shmfd; + vm_object_set_flag(obj, OBJ_POSIXSHM); VM_OBJECT_WUNLOCK(obj); shmfd->shm_object = obj; } @@ -992,11 +997,12 @@ shm_drop(struct shmfd *shmfd) rangelock_destroy(&shmfd->shm_rl); mtx_destroy(&shmfd->shm_mtx); obj = shmfd->shm_object; - if (!shm_largepage(shmfd)) { - VM_OBJECT_WLOCK(obj); + VM_OBJECT_WLOCK(obj); + if (shm_largepage(shmfd)) + obj->un_pager.phys.phys_priv = NULL; + else obj->un_pager.swp.swp_priv = NULL; - VM_OBJECT_WUNLOCK(obj); - } + VM_OBJECT_WUNLOCK(obj); vm_object_deallocate(obj); free(shmfd, M_SHMFD); } diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index c63a52260baf..9921f1130e8c 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -174,6 +174,7 @@ struct vm_object { void *data_ptr; uintptr_t data_val; }; + void *phys_priv; } phys; } un_pager; struct ucred *cred; @@ -204,6 +205,7 @@ struct vm_object { #define OBJ_PAGERPRIV1 0x00004000 /* Pager private */ #define OBJ_PAGERPRIV2 0x00008000 /* Pager private */ #define OBJ_SYSVSHM 0x00010000 /* SysV SHM */ +#define OBJ_POSIXSHM 0x00020000 /* Posix SHM */ /* * Helpers to perform conversion between vm_object page indexes and offsets.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410151505.49FF5XcJ089566>