Using madv.so.1
The madv.so.1
shared object enables the selective
configuration of virtual memory advice for launched processes and their descendants.
To use the shared object, the following string must be present in the environment:
LD_PRELOAD=$LD_PRELOAD:madv.so.1
The madv.so.1
shared object applies memory advice
as specified by the value of the MADV
environment variable.
The MADV
environment variable specifies the virtual memory
advice to use for all heap, shared memory, and mmap regions in the process
address space. This advice is applied to all created processes. The following
values of the MADV
environment variable affect resource allocation
among lgroups:
-
access_default
-
This value resets the kernel's expected access pattern to the default.
-
access_lwp
-
This value advises the kernel that the next LWP to touch an address range is the LWP that accesses that range the most. The kernel allocates the memory and other resources for this range and the LWP accordingly.
-
access_many
-
This value advises the kernel that many processes or LWPs will access memory randomly across the system. The kernel allocates the memory and other resources accordingly.
The value of the MADVCFGFILE
environment variable is
the name of a text file that contains one or more memory advice configuration
entries in the form exec-name:advice-opts.
The value of exec-name is the name of an application or executable. The value of exec-name can be a full pathname, a base name, or a pattern string.
The value of advice-opts is of the form region=advice. The values of advice are the same as the values for the MADV
environment
variable. Replace region with any of the following
legal values:
-
madv
-
Advice applies to all heap, shared memory, and
mmap
regions in the process address space. -
heap
-
The heap is defined to be the
brk
area. Advice applies to the existing heap and to any additional heap memory allocated in the future. -
shm
-
Advice applies to shared memory segments. For more information about shared memory operations, see the
shmat
(2) man page. -
ism
-
Advice applies to shared memory segments that are using the
SHM_SHARE_MMU
flag. Theism
option takes precedence overshm
. -
dsm
-
Advice applies to shared memory segments that are using the
SHM_PAGEABLE
flag. Thedsm
option takes precedence overshm
. -
mapshared
-
Advice applies to mappings established by the
mmap
() system call by using theMAP_SHARED
flag. -
mapprivate
-
Advice applies to mappings established by the
mmap
() system call by using theMAP_PRIVATE
flag. -
mapanon
-
Advice applies to mappings established by the
mmap
() system call by using theMAP_ANON
flag. Themapanon
option takes precedence when multiple options apply.
The value of the MADVERRFILE
environment variable is the path where error
messages are logged. In the absence of a MADVERRFILE
location, the
madv.so.1
shared object log errors by using
syslog
()
function with LOG_ERR
as the
severity level and LOG_USER
as the facility descriptor. For more
information, see the
syslog
(3C) man page,
Memory advice is inherited. A child process has the same advice as its parent. The advice is
set back to the system default advice after a call to exec
()
function, unless a different level of advice is configured using the
madv.so.1
shared object. Advice is only applied to
mmap
()
regions explicitly created by the user program.
Regions established by the run-time linker or by system libraries that make direct
system calls are not affected. For more information, see the
exec
(2) man page.