vm_mem_policy System Call

Purpose

Allows callers to get or set their applications' default memory placement policies.

Library

Standard C Library (libc.a)

Syntax

#include <sys/rset.h>

#include <sys/vminfo.h>

int vm_mem_policy(int cmd, int *early_lru, int *policies, int num_policies)

Description

The vm_mem_policy system call allows callers to get or set their applications' default memory placement policies for different types of memory.

Following are the different types of placement policies:
Item Description
P_FIRST_TOUCH Places the memory at the MCM where the application first referenced it. This is also achieved by setting the MEMORY_AFFINITY environment variable to MCM and benefit the applications with an identified home MCM to run on.
P_BALANCED Uses the stripe memory in the application across all the system's MCMs. This benefits applications that do not identify a home MCM to run on, or on global memory objects that is accessed by many applications.
P_DEFAULT Accepts the system's default policy for memory placement, which can be either the first touch or balanced policy, depending on the circumstances and the type of memory.

The vm_mem_policy system call allows the caller to get or set the early_lru flag, which triggers the system to look for stealable pages immediately after a P_FIRST_TOUCH driven scan for local memory (the memory on the same MCM the application is running on) does not find any available pages.

The parameters policies, and num_policies allow a caller to fine control over the default memory placement policies of different types of memory. The policy settings take effect on any new memory page the application creates after having called this function. The existing memory pages of the application retains their existing memory placement.

Parameters

Item Description
cmd A command that is either VM_SET_POLICY or VM_GET_POLICY. The VM_GET_POLICY command copies the current policy setting into the buffers supplied by the caller, and does not change any of the process policies. The VM_SET_POLICY command reads input from the supplied buffers and changes the process policies accordingly.
early_lru A pointer to an integer that indicates the state of the early_lru setting for first touch policy. Enabling early_lru causes memory to be paged out in order to fulfill a first-touch request for memory placement.
The possible values for early_lru are:
0
turn off early_lru.
1
turn on early_lru.
-1
do not modify early_lru setting for VM_SET_POLICY.
policies A pointer to an array of policies for distinct types of memory. Each array element contains one of the policy types. The array element contains -1 to leave the policy unchanged for the corresponding memory type. The array must be declared with a length of VM_NUM_POLICIES. The list that follows enumerates the memory types whose policies can be changed in the form of constants. Enter the constant that is an array index into the policies array for the corresponding memory type.
VM_POLICY_TEXT
policy for executable program text
VM_POLICY_STACK
policy for program stack
VM_POLICY_DATA
policy for program heap and private mmap data
VM_POLICY_SHM_NAMED
policy for shared memory obtained via shm_open() or shmget() with a key
VM_POLICY_SHM_ANON
policy for anonymous mmap memory, or shared memory obtained via shmget() with IPC_PRIVATE key
VM_POLICY_MAPPED_FILE
policy for files mapped into the address space via shmat() or mmap()
VM_POLICY_UNMAPPED_FILE
policy for open files that are not mapped
num_policies Number of elements in the policies array. This value must be set to VM_NUM_POLICIES.