git: e578fd853a25 - main - shm_alloc(): cleanup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Oct 2024 11:42:35 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e578fd853a251c04d1eeb55c3aa499f8d0cb7480 commit e578fd853a251c04d1eeb55c3aa499f8d0cb7480 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-08 17:43:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-09 11:28:12 +0000 shm_alloc(): cleanup Consistently use the shorter name 'obj' for the new object. Set OBJ_POSIXSHM flag outside if, it is set on both pathes. Suggested by: alc Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D47018 --- sys/kern/uipc_shm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index f6861a3278ff..141d386af396 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -945,24 +945,20 @@ shm_alloc(struct ucred *ucred, mode_t mode, bool largepage) shmfd->shm_gid = ucred->cr_gid; shmfd->shm_mode = mode; if (largepage) { - 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 = phys_pager_allocate(NULL, &shm_largepage_phys_ops, + NULL, shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); 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; } - KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate")); + KASSERT(obj != NULL, ("shm_create: vm_pager_allocate")); + VM_OBJECT_WLOCK(obj); + vm_object_set_flag(obj, OBJ_POSIXSHM); + VM_OBJECT_WUNLOCK(obj); + shmfd->shm_object = obj; vfs_timestamp(&shmfd->shm_birthtime); shmfd->shm_atime = shmfd->shm_mtime = shmfd->shm_ctime = shmfd->shm_birthtime;