Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sysv_shm.c
Show First 20 Lines • Show All 645 Lines • ▼ Show 20 Lines | shmget_allocate_segment(struct thread *td, struct shmget_args *uap, int mode) | ||||
} else { | } else { | ||||
segnum = shm_last_free; | segnum = shm_last_free; | ||||
shm_last_free = -1; | shm_last_free = -1; | ||||
} | } | ||||
KASSERT(segnum >= 0 && segnum < shmalloced, | KASSERT(segnum >= 0 && segnum < shmalloced, | ||||
("segnum %d shmalloced %d", segnum, shmalloced)); | ("segnum %d shmalloced %d", segnum, shmalloced)); | ||||
shmseg = &shmsegs[segnum]; | shmseg = &shmsegs[segnum]; | ||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | |||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
if (racct_add(td->td_proc, RACCT_NSHM, 1)) { | if (racct_add(td->td_proc, RACCT_NSHM, 1)) { | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
return (ENOSPC); | return (ENOSPC); | ||||
} | } | ||||
if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) { | if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) { | ||||
racct_sub(td->td_proc, RACCT_NSHM, 1); | racct_sub(td->td_proc, RACCT_NSHM, 1); | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
} | |||||
#endif | #endif | ||||
/* | /* | ||||
* We make sure that we have allocated a pager before we need | * We make sure that we have allocated a pager before we need | ||||
* to. | * to. | ||||
*/ | */ | ||||
shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP, | shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP, | ||||
0, size, VM_PROT_DEFAULT, 0, cred); | 0, size, VM_PROT_DEFAULT, 0, cred); | ||||
if (shm_object == NULL) { | if (shm_object == NULL) { | ||||
#ifdef RACCT | #ifdef RACCT | ||||
if (racct_enable) { | |||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
racct_sub(td->td_proc, RACCT_NSHM, 1); | racct_sub(td->td_proc, RACCT_NSHM, 1); | ||||
racct_sub(td->td_proc, RACCT_SHMSIZE, size); | racct_sub(td->td_proc, RACCT_SHMSIZE, size); | ||||
PROC_UNLOCK(td->td_proc); | PROC_UNLOCK(td->td_proc); | ||||
} | |||||
#endif | #endif | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
shm_object->pg_color = 0; | shm_object->pg_color = 0; | ||||
VM_OBJECT_WLOCK(shm_object); | VM_OBJECT_WLOCK(shm_object); | ||||
vm_object_clear_flag(shm_object, OBJ_ONEMAPPING); | vm_object_clear_flag(shm_object, OBJ_ONEMAPPING); | ||||
vm_object_set_flag(shm_object, OBJ_COLORED | OBJ_NOSPLIT); | vm_object_set_flag(shm_object, OBJ_COLORED | OBJ_NOSPLIT); | ||||
VM_OBJECT_WUNLOCK(shm_object); | VM_OBJECT_WUNLOCK(shm_object); | ||||
▲ Show 20 Lines • Show All 680 Lines • Show Last 20 Lines |