memcntl.c revision ede2438e8f556ca20640a62396a44cf0c635b8f9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2015 Joyent, Inc.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <sys/sysmacros.h>
#include <sys/tuneable.h>
/*
* Memory control operations
*/
int
{
int error = 0;
if (mask)
}
} else if (cmd != MC_HAT_ADVISE) {
}
/*
* We're only concerned with the address range
* here, not the protections. The protections
* are only used as a "filter" in this code,
* they aren't set or modified here.
*/
}
}
if (cmd == MC_HAT_ADVISE) {
}
} else {
}
}
}
if (attr) {
}
switch (cmd) {
case MC_SYNC:
/*
* MS_SYNC used to be defined to be zero but is now non-zero.
* For binary compatibility we still accept zero
* (the absence of MS_ASYNC) to mean the same thing.
*/
if ((iarg & ~MS_INVALIDATE) == 0)
} else {
if (error) {
}
}
return (error);
case MC_LOCKAS:
}
break;
case MC_LOCK:
case MC_UNLOCKAS:
case MC_UNLOCK:
break;
case MC_HAT_ADVISE:
/*
* Set prefered page size.
*/
}
/*
* Currently only MHA_MAPSIZE_VA, MHA_MAPSIZE_STACK
* and MHA_MAPSIZE_BSSBRK are supported. Only one
* command may be specified at a time.
*/
/*
* call platform specific map_pgsz() routine to get the
* optimal pgsz if pgsz is 0.
*
* For stack and heap operations addr and len must be zero.
*/
}
/*
* Disable autompss for this process unless pgsz == 0,
* which means the system should pick. In the
* pgsz == 0 case, leave the SAUTOLPG setting alone, as
* we don't want to enable it when someone has
* disabled automatic large page selection for the
* whole system.
*/
mutex_enter(&p->p_lock);
if (pgsz != 0) {
}
mutex_exit(&p->p_lock);
if (pgsz == 0) {
int type;
if (pgcmd == MHA_MAPSIZE_BSSBRK)
type = MAPPGSZ_HEAP;
else
type = MAPPGSZ_STK;
}
} else {
/*
* addr and len must be valid for range specified.
*/
}
/*
* Note that we don't disable automatic large page
* selection for anon segments based on use of
* memcntl().
*/
if (pgsz == 0) {
if (error) {
}
return (error);
}
/*
* addr and len must be prefered page size aligned
*/
}
}
!= 0) {
}
}
/*
* For stack and heap operations we first need to pad
* out existing range (create new mappings) to the new
* prefered page size boundary. Also the start of the
* .bss for the heap or user's stack base may not be on
* the new prefered page size boundary. For these cases
* we align the base of the request on the new prefered
* page size.
*/
if (pgcmd & MHA_MAPSIZE_BSSBRK) {
if (szc == p->p_brkpageszc) {
return (0);
}
if (szc > p->p_brkpageszc) {
if (error) {
}
}
/*
* It is possible for brk_internal to silently fail to
* promote the heap size, so don't panic or ASSERT.
*/
}
oszc = p->p_brkpageszc;
p->p_brkpageszc = szc;
pgsz);
/*
* Perhaps no existing pages to promote.
*/
if (len == 0) {
return (0);
}
}
/*
* The code below, as does grow.c, assumes stacks always grow
* downward.
*/
if (pgcmd & MHA_MAPSIZE_STACK) {
if (szc == p->p_stkpageszc) {
return (0);
}
if (szc > p->p_stkpageszc) {
if (error) {
}
}
/*
* It is possible for grow_internal to silently fail to
* promote the stack size, so don't panic or ASSERT.
*/
}
oszc = p->p_stkpageszc;
p->p_stkpageszc = szc;
/*
* Perhaps nothing to promote.
*/
return (0);
}
}
/*
* On stack or heap failures restore original
* pg size code.
*/
if (error) {
if ((pgcmd & MHA_MAPSIZE_BSSBRK) != 0) {
p->p_brkpageszc = oszc;
}
if ((pgcmd & MHA_MAPSIZE_STACK) != 0) {
p->p_stkpageszc = oszc;
}
}
}
return (error);
case MC_ADVISE:
}
case MADV_WILLNEED:
if (fc) {
else
return (error);
}
break;
case MADV_DONTNEED:
/*
* For now, don't need is turned into an as_ctl(MC_SYNC)
* operation flagged for async invalidate.
*/
if (error)
return (error);
default:
if (error)
return (error);
}
break;
case MC_INHERIT_ZERO:
break;
default:
}
if (error)
return (error);
}
/*
* Return page size code for page size passed in. If
* matching page size not found or supported, return -1.
*/
static uint_t
}