vm.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. Documentation 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. For general info and legal blurb, please look in README.
  5. ==============================================================
  6. This file contains the documentation for the sysctl files in
  7. /proc/sys/vm and is valid for Linux kernel version 2.6.29.
  8. The files in this directory can be used to tune the operation
  9. of the virtual memory (VM) subsystem of the Linux kernel and
  10. the writeout of dirty data to disk.
  11. Default values and initialization routines for most of these
  12. files can be found in mm/swap.c.
  13. Currently, these files are in /proc/sys/vm:
  14. - block_dump
  15. - dirty_background_bytes
  16. - dirty_background_ratio
  17. - dirty_bytes
  18. - dirty_expire_centisecs
  19. - dirty_ratio
  20. - dirty_writeback_centisecs
  21. - drop_caches
  22. - hugepages_treat_as_movable
  23. - hugetlb_shm_group
  24. - laptop_mode
  25. - legacy_va_layout
  26. - lowmem_reserve_ratio
  27. - max_map_count
  28. - min_free_kbytes
  29. - min_slab_ratio
  30. - min_unmapped_ratio
  31. - mmap_min_addr
  32. - nr_hugepages
  33. - nr_overcommit_hugepages
  34. - nr_pdflush_threads
  35. - nr_pdflush_threads_min
  36. - nr_pdflush_threads_max
  37. - nr_trim_pages (only if CONFIG_MMU=n)
  38. - numa_zonelist_order
  39. - oom_dump_tasks
  40. - oom_kill_allocating_task
  41. - overcommit_memory
  42. - overcommit_ratio
  43. - page-cluster
  44. - panic_on_oom
  45. - percpu_pagelist_fraction
  46. - stat_interval
  47. - swappiness
  48. - vfs_cache_pressure
  49. - zone_reclaim_mode
  50. ==============================================================
  51. block_dump
  52. block_dump enables block I/O debugging when set to a nonzero value. More
  53. information on block I/O debugging is in Documentation/laptops/laptop-mode.txt.
  54. ==============================================================
  55. dirty_background_bytes
  56. Contains the amount of dirty memory at which the pdflush background writeback
  57. daemon will start writeback.
  58. If dirty_background_bytes is written, dirty_background_ratio becomes a function
  59. of its value (dirty_background_bytes / the amount of dirtyable system memory).
  60. ==============================================================
  61. dirty_background_ratio
  62. Contains, as a percentage of total system memory, the number of pages at which
  63. the pdflush background writeback daemon will start writing out dirty data.
  64. ==============================================================
  65. dirty_bytes
  66. Contains the amount of dirty memory at which a process generating disk writes
  67. will itself start writeback.
  68. If dirty_bytes is written, dirty_ratio becomes a function of its value
  69. (dirty_bytes / the amount of dirtyable system memory).
  70. ==============================================================
  71. dirty_expire_centisecs
  72. This tunable is used to define when dirty data is old enough to be eligible
  73. for writeout by the pdflush daemons. It is expressed in 100'ths of a second.
  74. Data which has been dirty in-memory for longer than this interval will be
  75. written out next time a pdflush daemon wakes up.
  76. ==============================================================
  77. dirty_ratio
  78. Contains, as a percentage of total system memory, the number of pages at which
  79. a process which is generating disk writes will itself start writing out dirty
  80. data.
  81. ==============================================================
  82. dirty_writeback_centisecs
  83. The pdflush writeback daemons will periodically wake up and write `old' data
  84. out to disk. This tunable expresses the interval between those wakeups, in
  85. 100'ths of a second.
  86. Setting this to zero disables periodic writeback altogether.
  87. ==============================================================
  88. drop_caches
  89. Writing to this will cause the kernel to drop clean caches, dentries and
  90. inodes from memory, causing that memory to become free.
  91. To free pagecache:
  92. echo 1 > /proc/sys/vm/drop_caches
  93. To free dentries and inodes:
  94. echo 2 > /proc/sys/vm/drop_caches
  95. To free pagecache, dentries and inodes:
  96. echo 3 > /proc/sys/vm/drop_caches
  97. As this is a non-destructive operation and dirty objects are not freeable, the
  98. user should run `sync' first.
  99. ==============================================================
  100. hugepages_treat_as_movable
  101. This parameter is only useful when kernelcore= is specified at boot time to
  102. create ZONE_MOVABLE for pages that may be reclaimed or migrated. Huge pages
  103. are not movable so are not normally allocated from ZONE_MOVABLE. A non-zero
  104. value written to hugepages_treat_as_movable allows huge pages to be allocated
  105. from ZONE_MOVABLE.
  106. Once enabled, the ZONE_MOVABLE is treated as an area of memory the huge
  107. pages pool can easily grow or shrink within. Assuming that applications are
  108. not running that mlock() a lot of memory, it is likely the huge pages pool
  109. can grow to the size of ZONE_MOVABLE by repeatedly entering the desired value
  110. into nr_hugepages and triggering page reclaim.
  111. ==============================================================
  112. hugetlb_shm_group
  113. hugetlb_shm_group contains group id that is allowed to create SysV
  114. shared memory segment using hugetlb page.
  115. ==============================================================
  116. laptop_mode
  117. laptop_mode is a knob that controls "laptop mode". All the things that are
  118. controlled by this knob are discussed in Documentation/laptops/laptop-mode.txt.
  119. ==============================================================
  120. legacy_va_layout
  121. If non-zero, this sysctl disables the new 32-bit mmap mmap layout - the kernel
  122. will use the legacy (2.4) layout for all processes.
  123. ==============================================================
  124. lowmem_reserve_ratio
  125. For some specialised workloads on highmem machines it is dangerous for
  126. the kernel to allow process memory to be allocated from the "lowmem"
  127. zone. This is because that memory could then be pinned via the mlock()
  128. system call, or by unavailability of swapspace.
  129. And on large highmem machines this lack of reclaimable lowmem memory
  130. can be fatal.
  131. So the Linux page allocator has a mechanism which prevents allocations
  132. which _could_ use highmem from using too much lowmem. This means that
  133. a certain amount of lowmem is defended from the possibility of being
  134. captured into pinned user memory.
  135. (The same argument applies to the old 16 megabyte ISA DMA region. This
  136. mechanism will also defend that region from allocations which could use
  137. highmem or lowmem).
  138. The `lowmem_reserve_ratio' tunable determines how aggressive the kernel is
  139. in defending these lower zones.
  140. If you have a machine which uses highmem or ISA DMA and your
  141. applications are using mlock(), or if you are running with no swap then
  142. you probably should change the lowmem_reserve_ratio setting.
  143. The lowmem_reserve_ratio is an array. You can see them by reading this file.
  144. -
  145. % cat /proc/sys/vm/lowmem_reserve_ratio
  146. 256 256 32
  147. -
  148. Note: # of this elements is one fewer than number of zones. Because the highest
  149. zone's value is not necessary for following calculation.
  150. But, these values are not used directly. The kernel calculates # of protection
  151. pages for each zones from them. These are shown as array of protection pages
  152. in /proc/zoneinfo like followings. (This is an example of x86-64 box).
  153. Each zone has an array of protection pages like this.
  154. -
  155. Node 0, zone DMA
  156. pages free 1355
  157. min 3
  158. low 3
  159. high 4
  160. :
  161. :
  162. numa_other 0
  163. protection: (0, 2004, 2004, 2004)
  164. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  165. pagesets
  166. cpu: 0 pcp: 0
  167. :
  168. -
  169. These protections are added to score to judge whether this zone should be used
  170. for page allocation or should be reclaimed.
  171. In this example, if normal pages (index=2) are required to this DMA zone and
  172. pages_high is used for watermark, the kernel judges this zone should not be
  173. used because pages_free(1355) is smaller than watermark + protection[2]
  174. (4 + 2004 = 2008). If this protection value is 0, this zone would be used for
  175. normal page requirement. If requirement is DMA zone(index=0), protection[0]
  176. (=0) is used.
  177. zone[i]'s protection[j] is calculated by following expression.
  178. (i < j):
  179. zone[i]->protection[j]
  180. = (total sums of present_pages from zone[i+1] to zone[j] on the node)
  181. / lowmem_reserve_ratio[i];
  182. (i = j):
  183. (should not be protected. = 0;
  184. (i > j):
  185. (not necessary, but looks 0)
  186. The default values of lowmem_reserve_ratio[i] are
  187. 256 (if zone[i] means DMA or DMA32 zone)
  188. 32 (others).
  189. As above expression, they are reciprocal number of ratio.
  190. 256 means 1/256. # of protection pages becomes about "0.39%" of total present
  191. pages of higher zones on the node.
  192. If you would like to protect more pages, smaller values are effective.
  193. The minimum value is 1 (1/1 -> 100%).
  194. ==============================================================
  195. max_map_count:
  196. This file contains the maximum number of memory map areas a process
  197. may have. Memory map areas are used as a side-effect of calling
  198. malloc, directly by mmap and mprotect, and also when loading shared
  199. libraries.
  200. While most applications need less than a thousand maps, certain
  201. programs, particularly malloc debuggers, may consume lots of them,
  202. e.g., up to one or two maps per allocation.
  203. The default value is 65536.
  204. ==============================================================
  205. min_free_kbytes:
  206. This is used to force the Linux VM to keep a minimum number
  207. of kilobytes free. The VM uses this number to compute a pages_min
  208. value for each lowmem zone in the system. Each lowmem zone gets
  209. a number of reserved free pages based proportionally on its size.
  210. Some minimal amount of memory is needed to satisfy PF_MEMALLOC
  211. allocations; if you set this to lower than 1024KB, your system will
  212. become subtly broken, and prone to deadlock under high loads.
  213. Setting this too high will OOM your machine instantly.
  214. =============================================================
  215. min_slab_ratio:
  216. This is available only on NUMA kernels.
  217. A percentage of the total pages in each zone. On Zone reclaim
  218. (fallback from the local zone occurs) slabs will be reclaimed if more
  219. than this percentage of pages in a zone are reclaimable slab pages.
  220. This insures that the slab growth stays under control even in NUMA
  221. systems that rarely perform global reclaim.
  222. The default is 5 percent.
  223. Note that slab reclaim is triggered in a per zone / node fashion.
  224. The process of reclaiming slab memory is currently not node specific
  225. and may not be fast.
  226. =============================================================
  227. min_unmapped_ratio:
  228. This is available only on NUMA kernels.
  229. A percentage of the total pages in each zone. Zone reclaim will only
  230. occur if more than this percentage of pages are file backed and unmapped.
  231. This is to insure that a minimal amount of local pages is still available for
  232. file I/O even if the node is overallocated.
  233. The default is 1 percent.
  234. ==============================================================
  235. mmap_min_addr
  236. This file indicates the amount of address space which a user process will
  237. be restricted from mmaping. Since kernel null dereference bugs could
  238. accidentally operate based on the information in the first couple of pages
  239. of memory userspace processes should not be allowed to write to them. By
  240. default this value is set to 0 and no protections will be enforced by the
  241. security module. Setting this value to something like 64k will allow the
  242. vast majority of applications to work correctly and provide defense in depth
  243. against future potential kernel bugs.
  244. ==============================================================
  245. nr_hugepages
  246. Change the minimum size of the hugepage pool.
  247. See Documentation/vm/hugetlbpage.txt
  248. ==============================================================
  249. nr_overcommit_hugepages
  250. Change the maximum size of the hugepage pool. The maximum is
  251. nr_hugepages + nr_overcommit_hugepages.
  252. See Documentation/vm/hugetlbpage.txt
  253. ==============================================================
  254. nr_pdflush_threads
  255. The current number of pdflush threads. This value is read-only.
  256. The value changes according to the number of dirty pages in the system.
  257. When neccessary, additional pdflush threads are created, one per second, up to
  258. nr_pdflush_threads_max.
  259. ==============================================================
  260. nr_trim_pages
  261. This is available only on NOMMU kernels.
  262. This value adjusts the excess page trimming behaviour of power-of-2 aligned
  263. NOMMU mmap allocations.
  264. A value of 0 disables trimming of allocations entirely, while a value of 1
  265. trims excess pages aggressively. Any value >= 1 acts as the watermark where
  266. trimming of allocations is initiated.
  267. The default value is 1.
  268. See Documentation/nommu-mmap.txt for more information.
  269. ==============================================================
  270. numa_zonelist_order
  271. This sysctl is only for NUMA.
  272. 'where the memory is allocated from' is controlled by zonelists.
  273. (This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation.
  274. you may be able to read ZONE_DMA as ZONE_DMA32...)
  275. In non-NUMA case, a zonelist for GFP_KERNEL is ordered as following.
  276. ZONE_NORMAL -> ZONE_DMA
  277. This means that a memory allocation request for GFP_KERNEL will
  278. get memory from ZONE_DMA only when ZONE_NORMAL is not available.
  279. In NUMA case, you can think of following 2 types of order.
  280. Assume 2 node NUMA and below is zonelist of Node(0)'s GFP_KERNEL
  281. (A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL
  282. (B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA.
  283. Type(A) offers the best locality for processes on Node(0), but ZONE_DMA
  284. will be used before ZONE_NORMAL exhaustion. This increases possibility of
  285. out-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small.
  286. Type(B) cannot offer the best locality but is more robust against OOM of
  287. the DMA zone.
  288. Type(A) is called as "Node" order. Type (B) is "Zone" order.
  289. "Node order" orders the zonelists by node, then by zone within each node.
  290. Specify "[Nn]ode" for zone order
  291. "Zone Order" orders the zonelists by zone type, then by node within each
  292. zone. Specify "[Zz]one"for zode order.
  293. Specify "[Dd]efault" to request automatic configuration. Autoconfiguration
  294. will select "node" order in following case.
  295. (1) if the DMA zone does not exist or
  296. (2) if the DMA zone comprises greater than 50% of the available memory or
  297. (3) if any node's DMA zone comprises greater than 60% of its local memory and
  298. the amount of local memory is big enough.
  299. Otherwise, "zone" order will be selected. Default order is recommended unless
  300. this is causing problems for your system/application.
  301. ==============================================================
  302. oom_dump_tasks
  303. Enables a system-wide task dump (excluding kernel threads) to be
  304. produced when the kernel performs an OOM-killing and includes such
  305. information as pid, uid, tgid, vm size, rss, cpu, oom_adj score, and
  306. name. This is helpful to determine why the OOM killer was invoked
  307. and to identify the rogue task that caused it.
  308. If this is set to zero, this information is suppressed. On very
  309. large systems with thousands of tasks it may not be feasible to dump
  310. the memory state information for each one. Such systems should not
  311. be forced to incur a performance penalty in OOM conditions when the
  312. information may not be desired.
  313. If this is set to non-zero, this information is shown whenever the
  314. OOM killer actually kills a memory-hogging task.
  315. The default value is 0.
  316. ==============================================================
  317. oom_kill_allocating_task
  318. This enables or disables killing the OOM-triggering task in
  319. out-of-memory situations.
  320. If this is set to zero, the OOM killer will scan through the entire
  321. tasklist and select a task based on heuristics to kill. This normally
  322. selects a rogue memory-hogging task that frees up a large amount of
  323. memory when killed.
  324. If this is set to non-zero, the OOM killer simply kills the task that
  325. triggered the out-of-memory condition. This avoids the expensive
  326. tasklist scan.
  327. If panic_on_oom is selected, it takes precedence over whatever value
  328. is used in oom_kill_allocating_task.
  329. The default value is 0.
  330. ==============================================================
  331. nr_pdflush_threads_min
  332. This value controls the minimum number of pdflush threads.
  333. At boot time, the kernel will create and maintain 'nr_pdflush_threads_min'
  334. threads for the kernel's lifetime.
  335. The default value is 2. The minimum value you can specify is 1, and
  336. the maximum value is the current setting of 'nr_pdflush_threads_max'.
  337. See 'nr_pdflush_threads_max' below for more information.
  338. ==============================================================
  339. nr_pdflush_threads_max
  340. This value controls the maximum number of pdflush threads that can be
  341. created. The pdflush algorithm will create a new pdflush thread (up to
  342. this maximum) if no pdflush threads have been available for >= 1 second.
  343. The default value is 8. The minimum value you can specify is the
  344. current value of 'nr_pdflush_threads_min' and the
  345. maximum is 1000.
  346. ==============================================================
  347. overcommit_memory:
  348. This value contains a flag that enables memory overcommitment.
  349. When this flag is 0, the kernel attempts to estimate the amount
  350. of free memory left when userspace requests more memory.
  351. When this flag is 1, the kernel pretends there is always enough
  352. memory until it actually runs out.
  353. When this flag is 2, the kernel uses a "never overcommit"
  354. policy that attempts to prevent any overcommit of memory.
  355. This feature can be very useful because there are a lot of
  356. programs that malloc() huge amounts of memory "just-in-case"
  357. and don't use much of it.
  358. The default value is 0.
  359. See Documentation/vm/overcommit-accounting and
  360. security/commoncap.c::cap_vm_enough_memory() for more information.
  361. ==============================================================
  362. overcommit_ratio:
  363. When overcommit_memory is set to 2, the committed address
  364. space is not permitted to exceed swap plus this percentage
  365. of physical RAM. See above.
  366. ==============================================================
  367. page-cluster
  368. page-cluster controls the number of pages which are written to swap in
  369. a single attempt. The swap I/O size.
  370. It is a logarithmic value - setting it to zero means "1 page", setting
  371. it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
  372. The default value is three (eight pages at a time). There may be some
  373. small benefits in tuning this to a different value if your workload is
  374. swap-intensive.
  375. =============================================================
  376. panic_on_oom
  377. This enables or disables panic on out-of-memory feature.
  378. If this is set to 0, the kernel will kill some rogue process,
  379. called oom_killer. Usually, oom_killer can kill rogue processes and
  380. system will survive.
  381. If this is set to 1, the kernel panics when out-of-memory happens.
  382. However, if a process limits using nodes by mempolicy/cpusets,
  383. and those nodes become memory exhaustion status, one process
  384. may be killed by oom-killer. No panic occurs in this case.
  385. Because other nodes' memory may be free. This means system total status
  386. may be not fatal yet.
  387. If this is set to 2, the kernel panics compulsorily even on the
  388. above-mentioned.
  389. The default value is 0.
  390. 1 and 2 are for failover of clustering. Please select either
  391. according to your policy of failover.
  392. =============================================================
  393. percpu_pagelist_fraction
  394. This is the fraction of pages at most (high mark pcp->high) in each zone that
  395. are allocated for each per cpu page list. The min value for this is 8. It
  396. means that we don't allow more than 1/8th of pages in each zone to be
  397. allocated in any single per_cpu_pagelist. This entry only changes the value
  398. of hot per cpu pagelists. User can specify a number like 100 to allocate
  399. 1/100th of each zone to each per cpu page list.
  400. The batch value of each per cpu pagelist is also updated as a result. It is
  401. set to pcp->high/4. The upper limit of batch is (PAGE_SHIFT * 8)
  402. The initial value is zero. Kernel does not use this value at boot time to set
  403. the high water marks for each per cpu page list.
  404. ==============================================================
  405. stat_interval
  406. The time interval between which vm statistics are updated. The default
  407. is 1 second.
  408. ==============================================================
  409. swappiness
  410. This control is used to define how aggressive the kernel will swap
  411. memory pages. Higher values will increase agressiveness, lower values
  412. descrease the amount of swap.
  413. The default value is 60.
  414. ==============================================================
  415. vfs_cache_pressure
  416. ------------------
  417. Controls the tendency of the kernel to reclaim the memory which is used for
  418. caching of directory and inode objects.
  419. At the default value of vfs_cache_pressure=100 the kernel will attempt to
  420. reclaim dentries and inodes at a "fair" rate with respect to pagecache and
  421. swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer
  422. to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100
  423. causes the kernel to prefer to reclaim dentries and inodes.
  424. ==============================================================
  425. zone_reclaim_mode:
  426. Zone_reclaim_mode allows someone to set more or less aggressive approaches to
  427. reclaim memory when a zone runs out of memory. If it is set to zero then no
  428. zone reclaim occurs. Allocations will be satisfied from other zones / nodes
  429. in the system.
  430. This is value ORed together of
  431. 1 = Zone reclaim on
  432. 2 = Zone reclaim writes dirty pages out
  433. 4 = Zone reclaim swaps pages
  434. zone_reclaim_mode is set during bootup to 1 if it is determined that pages
  435. from remote zones will cause a measurable performance reduction. The
  436. page allocator will then reclaim easily reusable pages (those page
  437. cache pages that are currently not used) before allocating off node pages.
  438. It may be beneficial to switch off zone reclaim if the system is
  439. used for a file server and all of memory should be used for caching files
  440. from disk. In that case the caching effect is more important than
  441. data locality.
  442. Allowing zone reclaim to write out pages stops processes that are
  443. writing large amounts of data from dirtying pages on other nodes. Zone
  444. reclaim will write out dirty pages if a zone fills up and so effectively
  445. throttle the process. This may decrease the performance of a single process
  446. since it cannot use all of system memory to buffer the outgoing writes
  447. anymore but it preserve the memory on other nodes so that the performance
  448. of other processes running on other nodes will not be affected.
  449. Allowing regular swap effectively restricts allocations to the local
  450. node unless explicitly overridden by memory policies or cpuset
  451. configurations.
  452. ============ End of Document =================================