| 1 |
.\" Copyright 1994-1995, Daniel Quinlan <[email protected]> |
| 2 |
.\" Copyright 2002-2017, Michael Kerrisk <[email protected]> |
| 3 |
.\" Copyright, Andries E. Brouwer <[email protected]> |
| 4 |
.\" Copyright, the authors of the Linux man-pages project |
| 5 |
.\" |
| 6 |
.\" SPDX-License-Identifier: GPL-3.0-or-later |
| 7 |
.\" |
| 8 |
.TH proc_sys_vm 5 2026-02-08 "Linux man-pages 6.18" |
| 9 |
.SH NAME |
| 10 |
/proc/sys/vm/ \- virtual memory subsystem |
| 11 |
.SH DESCRIPTION |
| 12 |
.TP |
| 13 |
.I /proc/sys/vm/ |
| 14 |
This directory contains files for memory management tuning, buffer, and |
| 15 |
cache management. |
| 16 |
.TP |
| 17 |
.IR /proc/sys/vm/admin_reserve_kbytes " (since Linux 3.10)" |
| 18 |
.\" commit 4eeab4f5580d11bffedc697684b91b0bca0d5009 |
| 19 |
This file defines the amount of free memory (in KiB) on the system that |
| 20 |
should be reserved for users with the capability |
| 21 |
.BR CAP_SYS_ADMIN . |
| 22 |
.IP |
| 23 |
The default value in this file is the minimum of [3% of free pages, 8MiB] |
| 24 |
expressed as KiB. |
| 25 |
The default is intended to provide enough for the superuser |
| 26 |
to log in and kill a process, if necessary, |
| 27 |
under the default overcommit 'guess' mode (i.e., 0 in |
| 28 |
.IR /proc/sys/vm/overcommit_memory ). |
| 29 |
.IP |
| 30 |
Systems running in "overcommit never" mode (i.e., 2 in |
| 31 |
.IR /proc/sys/vm/overcommit_memory ) |
| 32 |
should increase the value in this file to account |
| 33 |
for the full virtual memory size of the programs used to recover (e.g., |
| 34 |
.BR login (1) |
| 35 |
.BR ssh (1), |
| 36 |
and |
| 37 |
.BR top (1)) |
| 38 |
Otherwise, the superuser may not be able to log in to recover the system. |
| 39 |
For example, on x86-64 a suitable value is 131072 (128MiB reserved). |
| 40 |
.IP |
| 41 |
Changing the value in this file takes effect whenever |
| 42 |
an application requests memory. |
| 43 |
.TP |
| 44 |
.IR /proc/sys/vm/compact_memory " (since Linux 2.6.35)" |
| 45 |
When 1 is written to this file, all zones are compacted such that free |
| 46 |
memory is available in contiguous blocks where possible. |
| 47 |
The effect of this action can be seen by examining |
| 48 |
.IR /proc/buddyinfo . |
| 49 |
.IP |
| 50 |
Present only if the kernel was configured with |
| 51 |
.BR CONFIG_COMPACTION . |
| 52 |
.TP |
| 53 |
.IR /proc/sys/vm/drop_caches " (since Linux 2.6.16)" |
| 54 |
Writing to this file causes the kernel to drop clean caches, dentries, and |
| 55 |
inodes from memory, causing that memory to become free. |
| 56 |
This can be useful for memory management testing and |
| 57 |
performing reproducible filesystem benchmarks. |
| 58 |
Because writing to this file causes the benefits of caching to be lost, |
| 59 |
it can degrade overall system performance. |
| 60 |
.IP |
| 61 |
To free pagecache, use: |
| 62 |
.IP |
| 63 |
.in +4n |
| 64 |
.EX |
| 65 |
echo 1 > /proc/sys/vm/drop_caches |
| 66 |
.EE |
| 67 |
.in |
| 68 |
.IP |
| 69 |
To free dentries and inodes, use: |
| 70 |
.IP |
| 71 |
.in +4n |
| 72 |
.EX |
| 73 |
echo 2 > /proc/sys/vm/drop_caches |
| 74 |
.EE |
| 75 |
.in |
| 76 |
.IP |
| 77 |
To free pagecache, dentries, and inodes, use: |
| 78 |
.IP |
| 79 |
.in +4n |
| 80 |
.EX |
| 81 |
echo 3 > /proc/sys/vm/drop_caches |
| 82 |
.EE |
| 83 |
.in |
| 84 |
.IP |
| 85 |
Because writing to this file is a nondestructive operation and dirty objects |
| 86 |
are not freeable, the |
| 87 |
user should run |
| 88 |
.BR sync (1) |
| 89 |
first. |
| 90 |
.TP |
| 91 |
.IR /proc/sys/vm/hugetlb_shm_group " (since Linux 2.6.7)" |
| 92 |
This writable file contains a group ID that is allowed |
| 93 |
to allocate memory using huge pages. |
| 94 |
If a process has a filesystem group ID or any supplementary group ID that |
| 95 |
matches this group ID, |
| 96 |
then it can make huge-page allocations without holding the |
| 97 |
.B CAP_IPC_LOCK |
| 98 |
capability; |
| 99 |
see |
| 100 |
.BR memfd_create (2), |
| 101 |
.BR mmap (2), |
| 102 |
and |
| 103 |
.BR shmget (2). |
| 104 |
.TP |
| 105 |
.IR /proc/sys/vm/legacy_va_layout " (since Linux 2.6.9)" |
| 106 |
If nonzero, this disables the new 32-bit memory-mapping layout; |
| 107 |
the kernel will use the legacy (2.4) layout for all processes. |
| 108 |
.TP |
| 109 |
.IR /proc/sys/vm/memory_failure_early_kill " (since Linux 2.6.32)" |
| 110 |
Control how to kill processes when an uncorrected memory error |
| 111 |
(typically a 2-bit error in a memory module) |
| 112 |
that cannot be handled by the kernel |
| 113 |
is detected in the background by hardware. |
| 114 |
In some cases (like the page still having a valid copy on disk), |
| 115 |
the kernel will handle the failure |
| 116 |
transparently without affecting any applications. |
| 117 |
But if there is no other up-to-date copy of the data, |
| 118 |
it will kill processes to prevent any data corruptions from propagating. |
| 119 |
.IP |
| 120 |
The file has one of the following values: |
| 121 |
.RS |
| 122 |
.TP |
| 123 |
.B 1 |
| 124 |
Kill all processes that have the corrupted-and-not-reloadable page mapped |
| 125 |
as soon as the corruption is detected. |
| 126 |
Note that this is not supported for a few types of pages, |
| 127 |
such as kernel internally |
| 128 |
allocated data or the swap cache, but works for the majority of user pages. |
| 129 |
.TP |
| 130 |
.B 0 |
| 131 |
Unmap the corrupted page from all processes and kill a process |
| 132 |
only if it tries to access the page. |
| 133 |
.RE |
| 134 |
.IP |
| 135 |
The kill is performed using a |
| 136 |
.B SIGBUS |
| 137 |
signal with |
| 138 |
.I si_code |
| 139 |
set to |
| 140 |
.BR BUS_MCEERR_AO . |
| 141 |
Processes can handle this if they want to; |
| 142 |
see |
| 143 |
.BR sigaction (2) |
| 144 |
for more details. |
| 145 |
.IP |
| 146 |
This feature is active only on architectures/platforms with advanced machine |
| 147 |
check handling and depends on the hardware capabilities. |
| 148 |
.IP |
| 149 |
Applications can override the |
| 150 |
.I memory_failure_early_kill |
| 151 |
setting individually with the |
| 152 |
.BR prctl (2) |
| 153 |
.B PR_MCE_KILL |
| 154 |
operation. |
| 155 |
.IP |
| 156 |
Present only if the kernel was configured with |
| 157 |
.BR CONFIG_MEMORY_FAILURE . |
| 158 |
.TP |
| 159 |
.IR /proc/sys/vm/memory_failure_recovery " (since Linux 2.6.32)" |
| 160 |
Enable memory failure recovery (when supported by the platform). |
| 161 |
.RS |
| 162 |
.TP |
| 163 |
.B 1 |
| 164 |
Attempt recovery. |
| 165 |
.TP |
| 166 |
.B 0 |
| 167 |
Always panic on a memory failure. |
| 168 |
.RE |
| 169 |
.IP |
| 170 |
Present only if the kernel was configured with |
| 171 |
.BR CONFIG_MEMORY_FAILURE . |
| 172 |
.TP |
| 173 |
.IR /proc/sys/vm/oom_dump_tasks " (since Linux 2.6.25)" |
| 174 |
Enables a system-wide task dump (excluding kernel threads) to be |
| 175 |
produced when the kernel performs an OOM-killing. |
| 176 |
The dump includes the following information |
| 177 |
for each task (thread, process): |
| 178 |
thread ID, real user ID, thread group ID (process ID), |
| 179 |
virtual memory size, resident set size, |
| 180 |
the CPU that the task is scheduled on, |
| 181 |
oom_adj score (see the description of |
| 182 |
.IR /proc/ pid /oom_adj ), |
| 183 |
and command name. |
| 184 |
This is helpful to determine why the OOM-killer was invoked |
| 185 |
and to identify the rogue task that caused it. |
| 186 |
.IP |
| 187 |
If this contains the value zero, this information is suppressed. |
| 188 |
On very large systems with thousands of tasks, |
| 189 |
it may not be feasible to dump the memory state information for each one. |
| 190 |
Such systems should not be forced to incur a performance penalty in |
| 191 |
OOM situations when the information may not be desired. |
| 192 |
.IP |
| 193 |
If this is set to nonzero, this information is shown whenever the |
| 194 |
OOM-killer actually kills a memory-hogging task. |
| 195 |
.IP |
| 196 |
The default value is 0. |
| 197 |
.TP |
| 198 |
.IR /proc/sys/vm/oom_kill_allocating_task " (since Linux 2.6.24)" |
| 199 |
This enables or disables killing the OOM-triggering task in |
| 200 |
out-of-memory situations. |
| 201 |
.IP |
| 202 |
If this is set to zero, the OOM-killer will scan through the entire |
| 203 |
tasklist and select a task based on heuristics to kill. |
| 204 |
This normally selects a rogue memory-hogging task that |
| 205 |
frees up a large amount of memory when killed. |
| 206 |
.IP |
| 207 |
If this is set to nonzero, the OOM-killer simply kills the task that |
| 208 |
triggered the out-of-memory condition. |
| 209 |
This avoids a possibly expensive tasklist scan. |
| 210 |
.IP |
| 211 |
If |
| 212 |
.I /proc/sys/vm/panic_on_oom |
| 213 |
is nonzero, it takes precedence over whatever value is used in |
| 214 |
.IR /proc/sys/vm/oom_kill_allocating_task . |
| 215 |
.IP |
| 216 |
The default value is 0. |
| 217 |
.TP |
| 218 |
.IR /proc/sys/vm/overcommit_kbytes " (since Linux 3.14)" |
| 219 |
.\" commit 49f0ce5f92321cdcf741e35f385669a421013cb7 |
| 220 |
This writable file provides an alternative to |
| 221 |
.I /proc/sys/vm/overcommit_ratio |
| 222 |
for controlling the |
| 223 |
.I CommitLimit |
| 224 |
when |
| 225 |
.I /proc/sys/vm/overcommit_memory |
| 226 |
has the value 2. |
| 227 |
It allows the amount of memory overcommitting to be specified as |
| 228 |
an absolute value (in kB), |
| 229 |
rather than as a percentage, as is done with |
| 230 |
.IR overcommit_ratio . |
| 231 |
This allows for finer-grained control of |
| 232 |
.I CommitLimit |
| 233 |
on systems with extremely large memory sizes. |
| 234 |
.IP |
| 235 |
Only one of |
| 236 |
.I overcommit_kbytes |
| 237 |
or |
| 238 |
.I overcommit_ratio |
| 239 |
can have an effect: |
| 240 |
if |
| 241 |
.I overcommit_kbytes |
| 242 |
has a nonzero value, then it is used to calculate |
| 243 |
.IR CommitLimit , |
| 244 |
otherwise |
| 245 |
.I overcommit_ratio |
| 246 |
is used. |
| 247 |
Writing a value to either of these files causes the |
| 248 |
value in the other file to be set to zero. |
| 249 |
.TP |
| 250 |
.I /proc/sys/vm/overcommit_memory |
| 251 |
This file contains the kernel virtual memory accounting mode. |
| 252 |
Values are: |
| 253 |
.RS |
| 254 |
.IP |
| 255 |
0: heuristic overcommit (this is the default) |
| 256 |
.br |
| 257 |
1: always overcommit, never check |
| 258 |
.br |
| 259 |
2: always check, never overcommit |
| 260 |
.RE |
| 261 |
.IP |
| 262 |
In mode 0, calls of |
| 263 |
.BR mmap (2) |
| 264 |
with |
| 265 |
.B MAP_NORESERVE |
| 266 |
are not checked, and the default check is very weak, |
| 267 |
leading to the risk of getting a process "OOM-killed". |
| 268 |
.IP |
| 269 |
In mode 1, the kernel pretends there is always enough memory, |
| 270 |
until memory actually runs out. |
| 271 |
One use case for this mode is scientific computing applications |
| 272 |
that employ large sparse arrays. |
| 273 |
Before Linux 2.6.0, any nonzero value implies mode 1. |
| 274 |
.IP |
| 275 |
In mode 2 (available since Linux 2.6), the total virtual address space |
| 276 |
that can be allocated |
| 277 |
.RI ( CommitLimit |
| 278 |
in |
| 279 |
.IR /proc/meminfo ) |
| 280 |
is calculated as |
| 281 |
.IP |
| 282 |
.in +4n |
| 283 |
.EX |
| 284 |
CommitLimit = (total_RAM \- total_huge_TLB) * |
| 285 |
overcommit_ratio / 100 + total_swap |
| 286 |
.EE |
| 287 |
.in |
| 288 |
.IP |
| 289 |
where: |
| 290 |
.RS |
| 291 |
.IP \[bu] 3 |
| 292 |
.I total_RAM |
| 293 |
is the total amount of RAM on the system; |
| 294 |
.IP \[bu] |
| 295 |
.I total_huge_TLB |
| 296 |
is the amount of memory set aside for huge pages; |
| 297 |
.IP \[bu] |
| 298 |
.I overcommit_ratio |
| 299 |
is the value in |
| 300 |
.IR /proc/sys/vm/overcommit_ratio ; |
| 301 |
and |
| 302 |
.IP \[bu] |
| 303 |
.I total_swap |
| 304 |
is the amount of swap space. |
| 305 |
.RE |
| 306 |
.IP |
| 307 |
For example, on a system with 16 GB of physical RAM, 16 GB |
| 308 |
of swap, no space dedicated to huge pages, and an |
| 309 |
.I overcommit_ratio |
| 310 |
of 50, this formula yields a |
| 311 |
.I CommitLimit |
| 312 |
of 24 GB. |
| 313 |
.IP |
| 314 |
Since Linux 3.14, if the value in |
| 315 |
.I /proc/sys/vm/overcommit_kbytes |
| 316 |
is nonzero, then |
| 317 |
.I CommitLimit |
| 318 |
is instead calculated as: |
| 319 |
.IP |
| 320 |
.in +4n |
| 321 |
.EX |
| 322 |
CommitLimit = overcommit_kbytes + total_swap |
| 323 |
.EE |
| 324 |
.in |
| 325 |
.IP |
| 326 |
See also the description of |
| 327 |
.I /proc/sys/vm/admin_reserve_kbytes |
| 328 |
and |
| 329 |
.IR /proc/sys/vm/user_reserve_kbytes . |
| 330 |
.TP |
| 331 |
.IR /proc/sys/vm/overcommit_ratio " (since Linux 2.6.0)" |
| 332 |
This writable file defines a percentage by which memory |
| 333 |
can be overcommitted. |
| 334 |
The default value in the file is 50. |
| 335 |
See the description of |
| 336 |
.IR /proc/sys/vm/overcommit_memory . |
| 337 |
.TP |
| 338 |
.IR /proc/sys/vm/panic_on_oom " (since Linux 2.6.18)" |
| 339 |
This enables or disables a kernel panic in |
| 340 |
an out-of-memory situation. |
| 341 |
.IP |
| 342 |
If this file is set to the value 0, |
| 343 |
the kernel's OOM-killer will kill some rogue process. |
| 344 |
Usually, the OOM-killer is able to kill a rogue process and the |
| 345 |
system will survive. |
| 346 |
.IP |
| 347 |
If this file is set to the value 1, |
| 348 |
then the kernel normally panics when out-of-memory happens. |
| 349 |
However, if a process limits allocations to certain nodes |
| 350 |
using memory policies |
| 351 |
.RB ( mbind (2) |
| 352 |
.BR MPOL_BIND ) |
| 353 |
or cpusets |
| 354 |
.RB ( cpuset (7)) |
| 355 |
and those nodes reach memory exhaustion status, |
| 356 |
one process may be killed by the OOM-killer. |
| 357 |
No panic occurs in this case: |
| 358 |
because other nodes' memory may be free, |
| 359 |
this means the system as a whole may not have reached |
| 360 |
an out-of-memory situation yet. |
| 361 |
.IP |
| 362 |
If this file is set to the value 2, |
| 363 |
the kernel always panics when an out-of-memory condition occurs. |
| 364 |
.IP |
| 365 |
The default value is 0. |
| 366 |
1 and 2 are for failover of clustering. |
| 367 |
Select either according to your policy of failover. |
| 368 |
.TP |
| 369 |
.I /proc/sys/vm/swappiness |
| 370 |
The value in this file controls how aggressively the kernel will swap |
| 371 |
memory pages. |
| 372 |
Higher values increase aggressiveness, lower values |
| 373 |
decrease aggressiveness. |
| 374 |
The default value is 60. |
| 375 |
.TP |
| 376 |
.IR /proc/sys/vm/user_reserve_kbytes " (since Linux 3.10)" |
| 377 |
.\" commit c9b1d0981fcce3d9976d7b7a56e4e0503bc610dd |
| 378 |
Specifies an amount of memory (in KiB) to reserve for user processes. |
| 379 |
This is intended to prevent a user from starting a single memory hogging |
| 380 |
process, such that they cannot recover (kill the hog). |
| 381 |
The value in this file has an effect only when |
| 382 |
.I /proc/sys/vm/overcommit_memory |
| 383 |
is set to 2 ("overcommit never" mode). |
| 384 |
In this case, the system reserves an amount of memory that is the minimum |
| 385 |
of [3% of current process size, |
| 386 |
.IR user_reserve_kbytes ]. |
| 387 |
.IP |
| 388 |
The default value in this file is the minimum of [3% of free pages, 128MiB] |
| 389 |
expressed as KiB. |
| 390 |
.IP |
| 391 |
If the value in this file is set to zero, |
| 392 |
then a user will be allowed to allocate all free memory with a single process |
| 393 |
(minus the amount reserved by |
| 394 |
.IR /proc/sys/vm/admin_reserve_kbytes ). |
| 395 |
Any subsequent attempts to execute a command will result in |
| 396 |
"fork: Cannot allocate memory". |
| 397 |
.IP |
| 398 |
Changing the value in this file takes effect whenever |
| 399 |
an application requests memory. |
| 400 |
.TP |
| 401 |
.IR /proc/sys/vm/unprivileged_userfaultfd " (since Linux 5.2)" |
| 402 |
.\" cefdca0a86be517bc390fc4541e3674b8e7803b0 |
| 403 |
This (writable) file exposes a flag that controls whether |
| 404 |
unprivileged processes are allowed to employ |
| 405 |
.BR userfaultfd (2). |
| 406 |
If this file has the value 1, then unprivileged processes may use |
| 407 |
.BR userfaultfd (2). |
| 408 |
If this file has the value 0, then only processes that have the |
| 409 |
.B CAP_SYS_PTRACE |
| 410 |
capability may employ |
| 411 |
.BR userfaultfd (2). |
| 412 |
The default value in this file is 1. |
| 413 |
.SH SEE ALSO |
| 414 |
.BR proc (5), |
| 415 |
.BR proc_sys (5) |