1/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */ 2/*- 3 * Copyright (c) 1994 Adam Glass and Charles Hannum. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 46 unchanged lines hidden (view full) --- 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * SUCH DAMAGE. 60 */ 61 62#include <sys/cdefs.h> |
63__FBSDID("$FreeBSD: stable/10/sys/kern/sysv_shm.c 284665 2015-06-21 06:28:26Z trasz $"); |
64 65#include "opt_compat.h" 66#include "opt_sysvipc.h" 67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/kernel.h> 71#include <sys/limits.h> --- 574 unchanged lines hidden (view full) --- 646 } else { 647 segnum = shm_last_free; 648 shm_last_free = -1; 649 } 650 KASSERT(segnum >= 0 && segnum < shmalloced, 651 ("segnum %d shmalloced %d", segnum, shmalloced)); 652 shmseg = &shmsegs[segnum]; 653#ifdef RACCT |
654 if (racct_enable) { 655 PROC_LOCK(td->td_proc); 656 if (racct_add(td->td_proc, RACCT_NSHM, 1)) { 657 PROC_UNLOCK(td->td_proc); 658 return (ENOSPC); 659 } 660 if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) { 661 racct_sub(td->td_proc, RACCT_NSHM, 1); 662 PROC_UNLOCK(td->td_proc); 663 return (ENOMEM); 664 } |
665 PROC_UNLOCK(td->td_proc); |
666 } |
667#endif 668 669 /* 670 * We make sure that we have allocated a pager before we need 671 * to. 672 */ 673 shm_object = vm_pager_allocate(shm_use_phys ? OBJT_PHYS : OBJT_SWAP, 674 0, size, VM_PROT_DEFAULT, 0, cred); 675 if (shm_object == NULL) { 676#ifdef RACCT |
677 if (racct_enable) { 678 PROC_LOCK(td->td_proc); 679 racct_sub(td->td_proc, RACCT_NSHM, 1); 680 racct_sub(td->td_proc, RACCT_SHMSIZE, size); 681 PROC_UNLOCK(td->td_proc); 682 } |
683#endif 684 return (ENOMEM); 685 } 686 shm_object->pg_color = 0; 687 VM_OBJECT_WLOCK(shm_object); 688 vm_object_clear_flag(shm_object, OBJ_ONEMAPPING); 689 vm_object_set_flag(shm_object, OBJ_COLORED | OBJ_NOSPLIT); 690 VM_OBJECT_WUNLOCK(shm_object); --- 686 unchanged lines hidden --- |