Read this section for an outline of memory, kernel and file system capacity, the parameters related to each, and the trade-offs involved in adjusting these parameters.
To set these values temporarily during tuning, echo the desired value to the appropriate file in the proc file system. For example, to set overcommit_memory temporarily to 1, run:
# echo 1 > /proc/sys/vm/overcommit_memory
Note that the path to the parameter in the proc file system varies depending on the system affected by the change.
To set these values persistently, you will need to use the
sysctl command. Refer to
The proc File System appendix of the Red Hat Enterprise Linux 6
Deployment Guide for further information.
Capacity-related Memory Tunables
Each of the following parameters is located under /proc/sys/vm/ in the proc file system.
overcommit_memory
Defines the conditions that determine whether a large memory request is accepted or denied. There are three possible values for this parameter:
0 — The default setting. The kernel performs heuristic memory overcommit handling by estimating the amount of memory available and failing requests that are blatantly invalid. Unfortunately, since memory is allocated using a heuristic rather than a precise algorithm, this setting can sometimes allow available memory on the system to be overloaded.
1 — The kernel performs no memory overcommit handling. Under this setting, the potential for memory overload is increased, but so is performance for memory-intensive tasks.
2 — The kernel denies requests for memory equal to or larger than the sum of total available swap and the percentage of physical RAM specified in overcommit_ratio. This setting is best if you want a lesser risk of memory overcommitment.
This setting is only recommended for systems with swap areas larger than their physical memory.
overcommit_ratio
Specifies the percentage of physical RAM considered when overcommit_memory is set to 2. The default value is 50.
max_map_count
Defines the maximum number of memory map areas that a process may use. In most cases, the default value of 65530 is appropriate. Increase this value if your application needs to map more than this number of files.
nr_hugepages
Defines the number of hugepages configured in the kernel. It is only possible to allocate (or deallocate) hugepages if there are sufficient physically contiguous free pages in the system. Pages reserved by this parameter cannot be used for other purposes. Further information is available from the installed documentation: /usr/share/doc/kernel-doc-kernel_version/Documentation/vm/hugetlbpage.txt
Capacity-related Kernel Tunables
Each of the following parameters is located under /proc/sys/kernel/ in the proc file system.
msgmax
Defines the maximum allowable size in bytes of any single message in a message queue. This value must not exceed the size of the queue (msgmnb). The default value is 65536.
msgmnb
Defines the maximum size in bytes of a single message queue. The default value is 65536 bytes.
msgmni
Defines the maximum number of message queue identifiers (and therefore the maximum number of queues). The default is 7454.
shmall
Defines the total amount of shared memory in bytes that can be used on the system at one time. The default value for machines with 64-bit architecture is 4294967296; for 32-bit architecture the default value is 268435456.
shmmax
Defines the maximum shared memory segment allowed by the kernel, in bytes. The default value is 68719476736. Note, however, that the kernel supports values much larger than this.
shmmni
Defines the system-wide maximum number of shared memory segments. The default value is 4096.
threads-max
Defines the system-wide maximum number of threads (tasks) to be used by the kernel at one time. The default value on machines with 64-bit architecture is 59344; for 32-bit architecture, the default value is 127600.
Capacity-related File System Tunables
Each of the following parameters is located under /proc/sys/fs/ in the proc file system.
aio-max-nr
Defines the maximum allowed number of events in all active asynchronous I/O contexts. The default value is 65536. Note that changing this value does not pre-allocate or resize any kernel data structures.
file-max
Lists the maximum number of file handles that the kernel allocates. The default value on machines with 64-bit architecture is 374263; for 32-bit architecture, the default value is 811491. Raising this value can resolve errors caused by a lack of available file handles.
Out-of-Memory Kill Tunables
Out of Memory (OOM) refers to a computing state where all available memory, including swap space, has been allocated. By default, this situation causes the system to panic and stop functioning as expected. However, setting the /proc/sys/vm/panic_on_oom parameter to 0 instructs the kernel to call the oom_killer function when OOM occurs. Usually, oom_killer can kill rogue processes and the system survives.
The following parameter can be set on a per-process basis, giving you increased control over which processes are killed by the oom_killer function. It is located under /proc/pid/ in the proc file system, where pid is the process ID number.
oom_adj
Defines a value from -16 to 15 that helps determine the oom_score of a process. The higher the oom_score value, the more likely the process will be killed by the oom_killer. Setting a oom_adj value of -17 disables the oom_killer for that process.
Any processes spawned by an adjusted process will inherit that process's oom_score. For example, if an sshd process is protected from the oom_killer function, all processes initiated by that SSH session will also be protected. This can affect the oom_killer function's ability to salvage the system if OOM occurs.