1Documentation for /proc/sys/vm/* kernel version 2.6.29 2 (c) 1998, 1999, Rik van Riel <riel@nl.linux.org> 3 (c) 2008 Peter W. Morreale <pmorreale@novell.com> 4 5For general info and legal blurb, please look in README. 6 7============================================================== 8 9This file contains the documentation for the sysctl files in 10/proc/sys/vm and is valid for Linux kernel version 2.6.29. 11 12The files in this directory can be used to tune the operation 13of the virtual memory (VM) subsystem of the Linux kernel and 14the writeout of dirty data to disk. 15 16Default values and initialization routines for most of these 17files can be found in mm/swap.c. 18 19Currently, these files are in /proc/sys/vm: 20 21- block_dump 22- compact_memory 23- dirty_background_bytes 24- dirty_background_ratio 25- dirty_bytes 26- dirty_expire_centisecs 27- dirty_ratio 28- dirty_writeback_centisecs 29- drop_caches 30- extfrag_threshold 31- hugepages_treat_as_movable 32- hugetlb_shm_group 33- laptop_mode 34- legacy_va_layout 35- lowmem_reserve_ratio 36- max_map_count 37- memory_failure_early_kill 38- memory_failure_recovery 39- min_free_kbytes 40- min_slab_ratio 41- min_unmapped_ratio 42- mmap_min_addr 43- nr_hugepages 44- nr_overcommit_hugepages 45- nr_pdflush_threads 46- nr_trim_pages (only if CONFIG_MMU=n) 47- numa_zonelist_order 48- oom_dump_tasks 49- oom_kill_allocating_task 50- overcommit_memory 51- overcommit_ratio 52- page-cluster 53- panic_on_oom 54- percpu_pagelist_fraction 55- stat_interval 56- swappiness 57- vfs_cache_pressure 58- zone_reclaim_mode 59 60============================================================== 61 62block_dump 63 64block_dump enables block I/O debugging when set to a nonzero value. More 65information on block I/O debugging is in Documentation/laptops/laptop-mode.txt. 66 67============================================================== 68 69compact_memory 70 71Available only when CONFIG_COMPACTION is set. When 1 is written to the file, 72all zones are compacted such that free memory is available in contiguous 73blocks where possible. This can be important for example in the allocation of 74huge pages although processes will also directly compact memory as required. 75 76============================================================== 77 78dirty_background_bytes 79 80Contains the amount of dirty memory at which the pdflush background writeback 81daemon will start writeback. 82 83If dirty_background_bytes is written, dirty_background_ratio becomes a function 84of its value (dirty_background_bytes / the amount of dirtyable system memory). 85 86============================================================== 87 88dirty_background_ratio 89 90Contains, as a percentage of total system memory, the number of pages at which 91the pdflush background writeback daemon will start writing out dirty data. 92 93============================================================== 94 95dirty_bytes 96 97Contains the amount of dirty memory at which a process generating disk writes 98will itself start writeback. 99 100If dirty_bytes is written, dirty_ratio becomes a function of its value 101(dirty_bytes / the amount of dirtyable system memory). 102 103Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any 104value lower than this limit will be ignored and the old configuration will be 105retained. 106 107============================================================== 108 109dirty_expire_centisecs 110 111This tunable is used to define when dirty data is old enough to be eligible 112for writeout by the pdflush daemons. It is expressed in 100'ths of a second. 113Data which has been dirty in-memory for longer than this interval will be 114written out next time a pdflush daemon wakes up. 115 116============================================================== 117 118dirty_ratio 119 120Contains, as a percentage of total system memory, the number of pages at which 121a process which is generating disk writes will itself start writing out dirty 122data. 123 124============================================================== 125 126dirty_writeback_centisecs 127 128The pdflush writeback daemons will periodically wake up and write `old' data 129out to disk. This tunable expresses the interval between those wakeups, in 130100'ths of a second. 131 132Setting this to zero disables periodic writeback altogether. 133 134============================================================== 135 136drop_caches 137 138Writing to this will cause the kernel to drop clean caches, dentries and 139inodes from memory, causing that memory to become free. 140 141To free pagecache: 142 echo 1 > /proc/sys/vm/drop_caches 143To free dentries and inodes: 144 echo 2 > /proc/sys/vm/drop_caches 145To free pagecache, dentries and inodes: 146 echo 3 > /proc/sys/vm/drop_caches 147 148As this is a non-destructive operation and dirty objects are not freeable, the 149user should run `sync' first. 150 151============================================================== 152 153extfrag_threshold 154 155This parameter affects whether the kernel will compact memory or direct 156reclaim to satisfy a high-order allocation. /proc/extfrag_index shows what 157the fragmentation index for each order is in each zone in the system. Values 158tending towards 0 imply allocations would fail due to lack of memory, 159values towards 1000 imply failures are due to fragmentation and -1 implies 160that the allocation will succeed as long as watermarks are met. 161 162The kernel will not compact memory in a zone if the 163fragmentation index is <= extfrag_threshold. The default value is 500. 164 165============================================================== 166 167hugepages_treat_as_movable 168 169This parameter is only useful when kernelcore= is specified at boot time to 170create ZONE_MOVABLE for pages that may be reclaimed or migrated. Huge pages 171are not movable so are not normally allocated from ZONE_MOVABLE. A non-zero 172value written to hugepages_treat_as_movable allows huge pages to be allocated 173from ZONE_MOVABLE. 174 175Once enabled, the ZONE_MOVABLE is treated as an area of memory the huge 176pages pool can easily grow or shrink within. Assuming that applications are 177not running that mlock() a lot of memory, it is likely the huge pages pool 178can grow to the size of ZONE_MOVABLE by repeatedly entering the desired value 179into nr_hugepages and triggering page reclaim. 180 181============================================================== 182 183hugetlb_shm_group 184 185hugetlb_shm_group contains group id that is allowed to create SysV 186shared memory segment using hugetlb page. 187 188============================================================== 189 190laptop_mode 191 192laptop_mode is a knob that controls "laptop mode". All the things that are 193controlled by this knob are discussed in Documentation/laptops/laptop-mode.txt. 194 195============================================================== 196 197legacy_va_layout 198 199If non-zero, this sysctl disables the new 32-bit mmap mmap layout - the kernel 200will use the legacy (2.4) layout for all processes. 201 202============================================================== 203 204lowmem_reserve_ratio 205 206For some specialised workloads on highmem machines it is dangerous for 207the kernel to allow process memory to be allocated from the "lowmem" 208zone. This is because that memory could then be pinned via the mlock() 209system call, or by unavailability of swapspace. 210 211And on large highmem machines this lack of reclaimable lowmem memory 212can be fatal. 213 214So the Linux page allocator has a mechanism which prevents allocations 215which _could_ use highmem from using too much lowmem. This means that 216a certain amount of lowmem is defended from the possibility of being 217captured into pinned user memory. 218 219(The same argument applies to the old 16 megabyte ISA DMA region. This 220mechanism will also defend that region from allocations which could use 221highmem or lowmem). 222 223The `lowmem_reserve_ratio' tunable determines how aggressive the kernel is 224in defending these lower zones. 225 226If you have a machine which uses highmem or ISA DMA and your 227applications are using mlock(), or if you are running with no swap then 228you probably should change the lowmem_reserve_ratio setting. 229 230The lowmem_reserve_ratio is an array. You can see them by reading this file. 231- 232% cat /proc/sys/vm/lowmem_reserve_ratio 233256 256 32 234- 235Note: # of this elements is one fewer than number of zones. Because the highest 236 zone's value is not necessary for following calculation. 237 238But, these values are not used directly. The kernel calculates # of protection 239pages for each zones from them. These are shown as array of protection pages 240in /proc/zoneinfo like followings. (This is an example of x86-64 box). 241Each zone has an array of protection pages like this. 242 243- 244Node 0, zone DMA 245 pages free 1355 246 min 3 247 low 3 248 high 4 249 : 250 : 251 numa_other 0 252 protection: (0, 2004, 2004, 2004) 253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 254 pagesets 255 cpu: 0 pcp: 0 256 : 257- 258These protections are added to score to judge whether this zone should be used 259for page allocation or should be reclaimed. 260 261In this example, if normal pages (index=2) are required to this DMA zone and 262watermark[WMARK_HIGH] is used for watermark, the kernel judges this zone should 263not be used because pages_free(1355) is smaller than watermark + protection[2] 264(4 + 2004 = 2008). If this protection value is 0, this zone would be used for 265normal page requirement. If requirement is DMA zone(index=0), protection[0] 266(=0) is used. 267 268zone[i]'s protection[j] is calculated by following expression. 269 270(i < j): 271 zone[i]->protection[j] 272 = (total sums of present_pages from zone[i+1] to zone[j] on the node) 273 / lowmem_reserve_ratio[i]; 274(i = j): 275 (should not be protected. = 0; 276(i > j): 277 (not necessary, but looks 0) 278 279The default values of lowmem_reserve_ratio[i] are 280 256 (if zone[i] means DMA or DMA32 zone) 281 32 (others). 282As above expression, they are reciprocal number of ratio. 283256 means 1/256. # of protection pages becomes about "0.39%" of total present 284pages of higher zones on the node. 285 286If you would like to protect more pages, smaller values are effective. 287The minimum value is 1 (1/1 -> 100%). 288 289============================================================== 290 291max_map_count: 292 293This file contains the maximum number of memory map areas a process 294may have. Memory map areas are used as a side-effect of calling 295malloc, directly by mmap and mprotect, and also when loading shared 296libraries. 297 298While most applications need less than a thousand maps, certain 299programs, particularly malloc debuggers, may consume lots of them, 300e.g., up to one or two maps per allocation. 301 302The default value is 65536. 303 304============================================================= 305 306memory_failure_early_kill: 307 308Control how to kill processes when uncorrected memory error (typically 309a 2bit error in a memory module) is detected in the background by hardware 310that cannot be handled by the kernel. In some cases (like the page 311still having a valid copy on disk) the kernel will handle the failure 312transparently without affecting any applications. But if there is 313no other uptodate copy of the data it will kill to prevent any data 314corruptions from propagating. 315 3161: Kill all processes that have the corrupted and not reloadable page mapped 317as soon as the corruption is detected. Note this is not supported 318for a few types of pages, like kernel internally allocated data or 319the swap cache, but works for the majority of user pages. 320 3210: Only unmap the corrupted page from all processes and only kill a process 322who tries to access it. 323 324The kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes can 325handle this if they want to. 326 327This is only active on architectures/platforms with advanced machine 328check handling and depends on the hardware capabilities. 329 330Applications can override this setting individually with the PR_MCE_KILL prctl 331 332============================================================== 333 334memory_failure_recovery 335 336Enable memory failure recovery (when supported by the platform) 337 3381: Attempt recovery. 339 3400: Always panic on a memory failure. 341 342============================================================== 343 344min_free_kbytes: 345 346This is used to force the Linux VM to keep a minimum number 347of kilobytes free. The VM uses this number to compute a 348watermark[WMARK_MIN] value for each lowmem zone in the system. 349Each lowmem zone gets a number of reserved free pages based 350proportionally on its size. 351 352Some minimal amount of memory is needed to satisfy PF_MEMALLOC 353allocations; if you set this to lower than 1024KB, your system will 354become subtly broken, and prone to deadlock under high loads. 355 356Setting this too high will OOM your machine instantly. 357 358============================================================= 359 360min_slab_ratio: 361 362This is available only on NUMA kernels. 363 364A percentage of the total pages in each zone. On Zone reclaim 365(fallback from the local zone occurs) slabs will be reclaimed if more 366than this percentage of pages in a zone are reclaimable slab pages. 367This insures that the slab growth stays under control even in NUMA 368systems that rarely perform global reclaim. 369 370The default is 5 percent. 371 372Note that slab reclaim is triggered in a per zone / node fashion. 373The process of reclaiming slab memory is currently not node specific 374and may not be fast. 375 376============================================================= 377 378min_unmapped_ratio: 379 380This is available only on NUMA kernels. 381 382This is a percentage of the total pages in each zone. Zone reclaim will 383only occur if more than this percentage of pages are in a state that 384zone_reclaim_mode allows to be reclaimed. 385 386If zone_reclaim_mode has the value 4 OR'd, then the percentage is compared 387against all file-backed unmapped pages including swapcache pages and tmpfs 388files. Otherwise, only unmapped pages backed by normal files but not tmpfs 389files and similar are considered. 390 391The default is 1 percent. 392 393============================================================== 394 395mmap_min_addr 396 397This file indicates the amount of address space which a user process will 398be restricted from mmapping. Since kernel null dereference bugs could 399accidentally operate based on the information in the first couple of pages 400of memory userspace processes should not be allowed to write to them. By 401default this value is set to 0 and no protections will be enforced by the 402security module. Setting this value to something like 64k will allow the 403vast majority of applications to work correctly and provide defense in depth 404against future potential kernel bugs. 405 406============================================================== 407 408nr_hugepages 409 410Change the minimum size of the hugepage pool. 411 412See Documentation/vm/hugetlbpage.txt 413 414============================================================== 415 416nr_overcommit_hugepages 417 418Change the maximum size of the hugepage pool. The maximum is 419nr_hugepages + nr_overcommit_hugepages. 420 421See Documentation/vm/hugetlbpage.txt 422 423============================================================== 424 425nr_pdflush_threads 426 427The current number of pdflush threads. This value is read-only. 428The value changes according to the number of dirty pages in the system. 429 430When necessary, additional pdflush threads are created, one per second, up to 431nr_pdflush_threads_max. 432 433============================================================== 434 435nr_trim_pages 436 437This is available only on NOMMU kernels. 438 439This value adjusts the excess page trimming behaviour of power-of-2 aligned 440NOMMU mmap allocations. 441 442A value of 0 disables trimming of allocations entirely, while a value of 1 443trims excess pages aggressively. Any value >= 1 acts as the watermark where 444trimming of allocations is initiated. 445 446The default value is 1. 447 448See Documentation/nommu-mmap.txt for more information. 449 450============================================================== 451 452numa_zonelist_order 453 454This sysctl is only for NUMA. 455'where the memory is allocated from' is controlled by zonelists. 456(This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation. 457 you may be able to read ZONE_DMA as ZONE_DMA32...) 458 459In non-NUMA case, a zonelist for GFP_KERNEL is ordered as following. 460ZONE_NORMAL -> ZONE_DMA 461This means that a memory allocation request for GFP_KERNEL will 462get memory from ZONE_DMA only when ZONE_NORMAL is not available. 463 464In NUMA case, you can think of following 2 types of order. 465Assume 2 node NUMA and below is zonelist of Node(0)'s GFP_KERNEL 466 467(A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL 468(B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA. 469 470Type(A) offers the best locality for processes on Node(0), but ZONE_DMA 471will be used before ZONE_NORMAL exhaustion. This increases possibility of 472out-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small. 473 474Type(B) cannot offer the best locality but is more robust against OOM of 475the DMA zone. 476 477Type(A) is called as "Node" order. Type (B) is "Zone" order. 478 479"Node order" orders the zonelists by node, then by zone within each node. 480Specify "[Nn]ode" for zone order 481 482"Zone Order" orders the zonelists by zone type, then by node within each 483zone. Specify "[Zz]one"for zode order. 484 485Specify "[Dd]efault" to request automatic configuration. Autoconfiguration 486will select "node" order in following case. 487(1) if the DMA zone does not exist or 488(2) if the DMA zone comprises greater than 50% of the available memory or 489(3) if any node's DMA zone comprises greater than 60% of its local memory and 490 the amount of local memory is big enough. 491 492Otherwise, "zone" order will be selected. Default order is recommended unless 493this is causing problems for your system/application. 494 495============================================================== 496 497oom_dump_tasks 498 499Enables a system-wide task dump (excluding kernel threads) to be 500produced when the kernel performs an OOM-killing and includes such 501information as pid, uid, tgid, vm size, rss, cpu, oom_adj score, and 502name. This is helpful to determine why the OOM killer was invoked 503and to identify the rogue task that caused it. 504 505If this is set to zero, this information is suppressed. On very 506large systems with thousands of tasks it may not be feasible to dump 507the memory state information for each one. Such systems should not 508be forced to incur a performance penalty in OOM conditions when the 509information may not be desired. 510 511If this is set to non-zero, this information is shown whenever the 512OOM killer actually kills a memory-hogging task. 513 514The default value is 0. 515 516============================================================== 517 518oom_kill_allocating_task 519 520This enables or disables killing the OOM-triggering task in 521out-of-memory situations. 522 523If this is set to zero, the OOM killer will scan through the entire 524tasklist and select a task based on heuristics to kill. This normally 525selects a rogue memory-hogging task that frees up a large amount of 526memory when killed. 527 528If this is set to non-zero, the OOM killer simply kills the task that 529triggered the out-of-memory condition. This avoids the expensive 530tasklist scan. 531 532If panic_on_oom is selected, it takes precedence over whatever value 533is used in oom_kill_allocating_task. 534 535The default value is 0. 536 537============================================================== 538 539overcommit_memory: 540 541This value contains a flag that enables memory overcommitment. 542 543When this flag is 0, the kernel attempts to estimate the amount 544of free memory left when userspace requests more memory. 545 546When this flag is 1, the kernel pretends there is always enough 547memory until it actually runs out. 548 549When this flag is 2, the kernel uses a "never overcommit" 550policy that attempts to prevent any overcommit of memory. 551 552This feature can be very useful because there are a lot of 553programs that malloc() huge amounts of memory "just-in-case" 554and don't use much of it. 555 556The default value is 0. 557 558See Documentation/vm/overcommit-accounting and 559security/commoncap.c::cap_vm_enough_memory() for more information. 560 561============================================================== 562 563overcommit_ratio: 564 565When overcommit_memory is set to 2, the committed address 566space is not permitted to exceed swap plus this percentage 567of physical RAM. See above. 568 569============================================================== 570 571page-cluster 572 573page-cluster controls the number of pages which are written to swap in 574a single attempt. The swap I/O size. 575 576It is a logarithmic value - setting it to zero means "1 page", setting 577it to 1 means "2 pages", setting it to 2 means "4 pages", etc. 578 579The default value is three (eight pages at a time). There may be some 580small benefits in tuning this to a different value if your workload is 581swap-intensive. 582 583============================================================= 584 585panic_on_oom 586 587This enables or disables panic on out-of-memory feature. 588 589If this is set to 0, the kernel will kill some rogue process, 590called oom_killer. Usually, oom_killer can kill rogue processes and 591system will survive. 592 593If this is set to 1, the kernel panics when out-of-memory happens. 594However, if a process limits using nodes by mempolicy/cpusets, 595and those nodes become memory exhaustion status, one process 596may be killed by oom-killer. No panic occurs in this case. 597Because other nodes' memory may be free. This means system total status 598may be not fatal yet. 599 600If this is set to 2, the kernel panics compulsorily even on the 601above-mentioned. Even oom happens under memory cgroup, the whole 602system panics. 603 604The default value is 0. 6051 and 2 are for failover of clustering. Please select either 606according to your policy of failover. 607panic_on_oom=2+kdump gives you very strong tool to investigate 608why oom happens. You can get snapshot. 609 610============================================================= 611 612percpu_pagelist_fraction 613 614This is the fraction of pages at most (high mark pcp->high) in each zone that 615are allocated for each per cpu page list. The min value for this is 8. It 616means that we don't allow more than 1/8th of pages in each zone to be 617allocated in any single per_cpu_pagelist. This entry only changes the value 618of hot per cpu pagelists. User can specify a number like 100 to allocate 6191/100th of each zone to each per cpu page list. 620 621The batch value of each per cpu pagelist is also updated as a result. It is 622set to pcp->high/4. The upper limit of batch is (PAGE_SHIFT * 8) 623 624The initial value is zero. Kernel does not use this value at boot time to set 625the high water marks for each per cpu page list. 626 627============================================================== 628 629stat_interval 630 631The time interval between which vm statistics are updated. The default 632is 1 second. 633 634============================================================== 635 636swappiness 637 638This control is used to define how aggressive the kernel will swap 639memory pages. Higher values will increase agressiveness, lower values 640decrease the amount of swap. 641 642The default value is 60. 643 644============================================================== 645 646vfs_cache_pressure 647------------------ 648 649Controls the tendency of the kernel to reclaim the memory which is used for 650caching of directory and inode objects. 651 652At the default value of vfs_cache_pressure=100 the kernel will attempt to 653reclaim dentries and inodes at a "fair" rate with respect to pagecache and 654swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer 655to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will 656never reclaim dentries and inodes due to memory pressure and this can easily 657lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100 658causes the kernel to prefer to reclaim dentries and inodes. 659 660============================================================== 661 662zone_reclaim_mode: 663 664Zone_reclaim_mode allows someone to set more or less aggressive approaches to 665reclaim memory when a zone runs out of memory. If it is set to zero then no 666zone reclaim occurs. Allocations will be satisfied from other zones / nodes 667in the system. 668 669This is value ORed together of 670 6711 = Zone reclaim on 6722 = Zone reclaim writes dirty pages out 6734 = Zone reclaim swaps pages 674 675zone_reclaim_mode is set during bootup to 1 if it is determined that pages 676from remote zones will cause a measurable performance reduction. The 677page allocator will then reclaim easily reusable pages (those page 678cache pages that are currently not used) before allocating off node pages. 679 680It may be beneficial to switch off zone reclaim if the system is 681used for a file server and all of memory should be used for caching files 682from disk. In that case the caching effect is more important than 683data locality. 684 685Allowing zone reclaim to write out pages stops processes that are 686writing large amounts of data from dirtying pages on other nodes. Zone 687reclaim will write out dirty pages if a zone fills up and so effectively 688throttle the process. This may decrease the performance of a single process 689since it cannot use all of system memory to buffer the outgoing writes 690anymore but it preserve the memory on other nodes so that the performance 691of other processes running on other nodes will not be affected. 692 693Allowing regular swap effectively restricts allocations to the local 694node unless explicitly overridden by memory policies or cpuset 695configurations. 696 697============ End of Document ================================= 698

