MCPcopy Create free account
hub / github.com/F-Stack/f-stack / shm_alloc

Function shm_alloc

freebsd/kern/uipc_shm.c:853–886  ·  view source on GitHub ↗

* shmfd object management including creation and reference counting * routines. */

Source from the content-addressed store, hash-verified

851 * routines.
852 */
853struct shmfd *
854shm_alloc(struct ucred *ucred, mode_t mode, bool largepage)
855{
856 struct shmfd *shmfd;
857
858 shmfd = malloc(sizeof(*shmfd), M_SHMFD, M_WAITOK | M_ZERO);
859 shmfd->shm_size = 0;
860 shmfd->shm_uid = ucred->cr_uid;
861 shmfd->shm_gid = ucred->cr_gid;
862 shmfd->shm_mode = mode;
863 if (largepage) {
864 shmfd->shm_object = phys_pager_allocate(NULL,
865 &shm_largepage_phys_ops, NULL, shmfd->shm_size,
866 VM_PROT_DEFAULT, 0, ucred);
867 shmfd->shm_lp_alloc_policy = SHM_LARGEPAGE_ALLOC_DEFAULT;
868 } else {
869 shmfd->shm_object = vm_pager_allocate(OBJT_SWAP, NULL,
870 shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred);
871 }
872 KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate"));
873 vfs_timestamp(&shmfd->shm_birthtime);
874 shmfd->shm_atime = shmfd->shm_mtime = shmfd->shm_ctime =
875 shmfd->shm_birthtime;
876 shmfd->shm_ino = alloc_unr64(&shm_ino_unr);
877 refcount_init(&shmfd->shm_refs, 1);
878 mtx_init(&shmfd->shm_mtx, "shmrl", NULL, MTX_DEF);
879 rangelock_init(&shmfd->shm_rl);
880#ifdef MAC
881 mac_posixshm_init(shmfd);
882 mac_posixshm_create(ucred, shmfd);
883#endif
884
885 return (shmfd);
886}
887
888struct shmfd *
889shm_hold(struct shmfd *shmfd)

Callers 2

umtx_shm_create_regFunction · 0.85
kern_shm_open2Function · 0.85

Calls 10

mallocFunction · 0.85
phys_pager_allocateFunction · 0.85
vm_pager_allocateFunction · 0.85
vfs_timestampFunction · 0.85
refcount_initFunction · 0.85
mtx_initFunction · 0.85
rangelock_initFunction · 0.85
mac_posixshm_initFunction · 0.85
mac_posixshm_createFunction · 0.85
alloc_unr64Function · 0.70

Tested by

no test coverage detected