vm_pattr System Call and kvm_pattr Kernel Service
Purpose
Queries or modifies virtual memory attributes.
Library
Standard C Library (libc.a)
Syntax
Description
The vm_pattr system call queries or modifies memory attributes of the calling process's address space or that of another user process.
The kvm_pattr kernel service provides the same function to kernel subsystems (kernel extensions, kernel processes and so on) except that it cannot modify another kernel process' memory attributes.
Parameters
Item | Description | ||
---|---|---|---|
cmd | The following commands can be passed in:
|
||
pid | Specifies the ID of the process whose memory attributes
are to be queried or modified. A value of -1 specifies the calling process. The root user can
specify any process ID, but other users can only specify processes they own (that is, the target
process's user ID must match the calling process's user ID). The vm_pattr system call is only supported on user processes while the kvm_pattr kernel service can target user processes or its own kernel process (for example, pid = -1). |
||
attr | A pointer to a structure describing the effective
address range for the memory being queried or modified and additional data depending on the command.
The range is specified through the following vm_pa_range structure:
The
range specified must be in the target process's address space and must correspond to one of these
process areas:
|
||
attr (continued) |
The structure specified through the attr parameter must be a pointer to one of the
following structures:
|
||
|
|||
attr (continued) |
If the pa_info field is NULL, this command is identical to the VM_PA_GET_PSIZE command. The pa_info field should point to an array containing two 64 bit integers. The pa_info_size field should be set to the size of the array. In the first 64-bit integer, this command reports the number of 64-KB sized and aligned subregions in the specified pa_range range that consist of 16 contiguous 4-KB pages that are promoted to using a 64-KB page size hardware translation. In the second 64-bit integer, this command reports the number of 16 MB sized and aligned subregions in the specified range that consist of either 4096 4 KB or 256 64-KB contiguous pages that are promoted to using a 16-MB page size hardware translation. The pa_psize field reports the smallest page size found for the specified range. The information reported is transient because the operating system can change the backing page size at any time. Therefore, the page size reported must be for informational purposes only. |
||
attr (continued) |
|
||
attr (continued) |
|
||
attr (continued) |
|
||
attr (continued) |
Process's Memory Area Minimum Alignment Main process data 256 MB Process stack 256 MB Shared Library data 256 MB Privately loaded module data 256 MB Privately loaded module text 256 MB POSIX Real-Time Shared Memory 256 MB Anonymous MMAP 256 MB Anonymous Extended System V Shared memory 256 MB Anonymous System V Shared memory with page sizes less than or equal to 256 MB 256 MB Anonymous System V shared memory backed with 16 GB page size 1 TB |
||
attr (continued) |
VMPATTR_SET_PSIZE_VALID The specified page size can be used for the specified range. VMPATTR_INVALID_MPSS_PSIZE The specified page size is not supported in mixed page size segments. VMPATTR_NON_MPSS_SEGMENT The address range specified is from a segment that does not support mixed page sizes. VMPATTR_NON_MPSS_PAGE The size of the target page cannot be modified. For example, this reason code can be returned when trying to set an address range to a 64 KB page size if a portion of the range has page protection settings that do not match the rest of the range. VMPATTR_RDONLY_MEM The target range cannot be modified because the caller does not have write access to the memory specified. VMPATTR_PAGE_ATTRIBUTES The address range specified does not have uniform page attributes. VMPATTR_NOT_FULLY_POPULATED The address range specified does not fully reside in memory. VMPATTR_PHYSICAL_ATTACHMENTS The address range specified has memory affinity attachments that specify more than one affinity domain. VMPATTR_MEMORY_TYPE_UNSUPPORTED The address range contains a memory object that does not support the requested page size in a mixed page size segment. |
||
attr_size | The attr_size parameter must be the size of the structure needed, or greater for the specified command. |
Return Values
When successful, these commands return 0. Otherwise, they return -1 and set the errno global variable to indicate the error.
Error Codes
Item | Description |
---|---|
EPERM | The calling process does not have the appropriate privilege to perform the requested operation. |
ESRCH | The target process does not exist or is not in a valid state. |
ENOMEM | The range specified contains a hole. A hole is any part of the target process's address space that is not backed by a virtual memory segment or is outside of the valid range of the virtual memory segment specified. |
ENOTSUP | Any of the following situations can cause the ENOTSUP error:
|
EINVAL | Any of the following situations can cause the EINVAL error:
|
ENOMEM | The command specified was VM_PA_SET_PSIZE_EXTENDED, and the system was unable to allocate memory from the set of affinity domains specified by the pa_info object or the entire set of system affinity domains without potentially causing a performance degradation. |
EFAULT | The command specified was either VM_PA_SET_PSIZE_EXTENDED, or VM_PA_GET_PSIZE_EXTENDED and the pa_info address is not valid and is not NULL. |
EINVAL | The command specified was either VM_PA_SET_PSIZE_EXTENDED, or VM_PA_GET_PSIZE_EXTENDED and the pa_info field is not-NULL, but the pa_info_size field is 0. |
ENODEV | The command specified was VM_PA_SET_PSIZE_EXTENDED, and an invalid sradid was specified in pa_info. |