vm.rst 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. ===============================
  2. Documentation for /proc/sys/vm/
  3. ===============================
  4. kernel version 2.6.29
  5. Copyright (c) 1998, 1999, Rik van Riel <riel@nl.linux.org>
  6. Copyright (c) 2008 Peter W. Morreale <pmorreale@novell.com>
  7. For general info and legal blurb, please look in index.rst.
  8. ------------------------------------------------------------------------------
  9. This file contains the documentation for the sysctl files in
  10. /proc/sys/vm and is valid for Linux kernel version 2.6.29.
  11. The files in this directory can be used to tune the operation
  12. of the virtual memory (VM) subsystem of the Linux kernel and
  13. the writeout of dirty data to disk.
  14. Default values and initialization routines for most of these
  15. files can be found in mm/swap.c.
  16. Currently, these files are in /proc/sys/vm:
  17. - admin_reserve_kbytes
  18. - block_dump
  19. - compact_memory
  20. - compaction_proactiveness
  21. - compact_unevictable_allowed
  22. - dirty_background_bytes
  23. - dirty_background_ratio
  24. - dirty_bytes
  25. - dirty_expire_centisecs
  26. - dirty_ratio
  27. - dirtytime_expire_seconds
  28. - dirty_writeback_centisecs
  29. - drop_caches
  30. - extfrag_threshold
  31. - extra_free_kbytes
  32. - highmem_is_dirtyable
  33. - hugetlb_shm_group
  34. - laptop_mode
  35. - legacy_va_layout
  36. - lowmem_reserve_ratio
  37. - max_map_count
  38. - memory_failure_early_kill
  39. - memory_failure_recovery
  40. - min_free_kbytes
  41. - min_slab_ratio
  42. - min_unmapped_ratio
  43. - mmap_min_addr
  44. - mmap_rnd_bits
  45. - mmap_rnd_compat_bits
  46. - nr_hugepages
  47. - nr_hugepages_mempolicy
  48. - nr_overcommit_hugepages
  49. - nr_trim_pages (only if CONFIG_MMU=n)
  50. - numa_zonelist_order
  51. - oom_dump_tasks
  52. - oom_kill_allocating_task
  53. - overcommit_kbytes
  54. - overcommit_memory
  55. - overcommit_ratio
  56. - page-cluster
  57. - panic_on_oom
  58. - percpu_pagelist_fraction
  59. - stat_interval
  60. - stat_refresh
  61. - numa_stat
  62. - swappiness
  63. - unprivileged_userfaultfd
  64. - user_reserve_kbytes
  65. - vfs_cache_pressure
  66. - watermark_boost_factor
  67. - watermark_scale_factor
  68. - zone_reclaim_mode
  69. admin_reserve_kbytes
  70. ====================
  71. The amount of free memory in the system that should be reserved for users
  72. with the capability cap_sys_admin.
  73. admin_reserve_kbytes defaults to min(3% of free pages, 8MB)
  74. That should provide enough for the admin to log in and kill a process,
  75. if necessary, under the default overcommit 'guess' mode.
  76. Systems running under overcommit 'never' should increase this to account
  77. for the full Virtual Memory Size of programs used to recover. Otherwise,
  78. root may not be able to log in to recover the system.
  79. How do you calculate a minimum useful reserve?
  80. sshd or login + bash (or some other shell) + top (or ps, kill, etc.)
  81. For overcommit 'guess', we can sum resident set sizes (RSS).
  82. On x86_64 this is about 8MB.
  83. For overcommit 'never', we can take the max of their virtual sizes (VSZ)
  84. and add the sum of their RSS.
  85. On x86_64 this is about 128MB.
  86. Changing this takes effect whenever an application requests memory.
  87. block_dump
  88. ==========
  89. block_dump enables block I/O debugging when set to a nonzero value. More
  90. information on block I/O debugging is in Documentation/admin-guide/laptops/laptop-mode.rst.
  91. compact_memory
  92. ==============
  93. Available only when CONFIG_COMPACTION is set. When 1 is written to the file,
  94. all zones are compacted such that free memory is available in contiguous
  95. blocks where possible. This can be important for example in the allocation of
  96. huge pages although processes will also directly compact memory as required.
  97. compaction_proactiveness
  98. ========================
  99. This tunable takes a value in the range [0, 100] with a default value of
  100. 20. This tunable determines how aggressively compaction is done in the
  101. background. On write of non zero value to this tunable will immediately
  102. trigger the proactive compaction. Setting it to 0 disables proactive compaction.
  103. Note that compaction has a non-trivial system-wide impact as pages
  104. belonging to different processes are moved around, which could also lead
  105. to latency spikes in unsuspecting applications. The kernel employs
  106. various heuristics to avoid wasting CPU cycles if it detects that
  107. proactive compaction is not being effective.
  108. Be careful when setting it to extreme values like 100, as that may
  109. cause excessive background compaction activity.
  110. compact_unevictable_allowed
  111. ===========================
  112. Available only when CONFIG_COMPACTION is set. When set to 1, compaction is
  113. allowed to examine the unevictable lru (mlocked pages) for pages to compact.
  114. This should be used on systems where stalls for minor page faults are an
  115. acceptable trade for large contiguous free memory. Set to 0 to prevent
  116. compaction from moving pages that are unevictable. Default value is 1.
  117. On CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page fault, due
  118. to compaction, which would block the task from becomming active until the fault
  119. is resolved.
  120. dirty_background_bytes
  121. ======================
  122. Contains the amount of dirty memory at which the background kernel
  123. flusher threads will start writeback.
  124. Note:
  125. dirty_background_bytes is the counterpart of dirty_background_ratio. Only
  126. one of them may be specified at a time. When one sysctl is written it is
  127. immediately taken into account to evaluate the dirty memory limits and the
  128. other appears as 0 when read.
  129. dirty_background_ratio
  130. ======================
  131. Contains, as a percentage of total available memory that contains free pages
  132. and reclaimable pages, the number of pages at which the background kernel
  133. flusher threads will start writing out dirty data.
  134. The total available memory is not equal to total system memory.
  135. dirty_bytes
  136. ===========
  137. Contains the amount of dirty memory at which a process generating disk writes
  138. will itself start writeback.
  139. Note: dirty_bytes is the counterpart of dirty_ratio. Only one of them may be
  140. specified at a time. When one sysctl is written it is immediately taken into
  141. account to evaluate the dirty memory limits and the other appears as 0 when
  142. read.
  143. Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any
  144. value lower than this limit will be ignored and the old configuration will be
  145. retained.
  146. dirty_expire_centisecs
  147. ======================
  148. This tunable is used to define when dirty data is old enough to be eligible
  149. for writeout by the kernel flusher threads. It is expressed in 100'ths
  150. of a second. Data which has been dirty in-memory for longer than this
  151. interval will be written out next time a flusher thread wakes up.
  152. dirty_ratio
  153. ===========
  154. Contains, as a percentage of total available memory that contains free pages
  155. and reclaimable pages, the number of pages at which a process which is
  156. generating disk writes will itself start writing out dirty data.
  157. The total available memory is not equal to total system memory.
  158. dirtytime_expire_seconds
  159. ========================
  160. When a lazytime inode is constantly having its pages dirtied, the inode with
  161. an updated timestamp will never get chance to be written out. And, if the
  162. only thing that has happened on the file system is a dirtytime inode caused
  163. by an atime update, a worker will be scheduled to make sure that inode
  164. eventually gets pushed out to disk. This tunable is used to define when dirty
  165. inode is old enough to be eligible for writeback by the kernel flusher threads.
  166. And, it is also used as the interval to wakeup dirtytime_writeback thread.
  167. dirty_writeback_centisecs
  168. =========================
  169. The kernel flusher threads will periodically wake up and write `old` data
  170. out to disk. This tunable expresses the interval between those wakeups, in
  171. 100'ths of a second.
  172. Setting this to zero disables periodic writeback altogether.
  173. drop_caches
  174. ===========
  175. Writing to this will cause the kernel to drop clean caches, as well as
  176. reclaimable slab objects like dentries and inodes. Once dropped, their
  177. memory becomes free.
  178. To free pagecache::
  179. echo 1 > /proc/sys/vm/drop_caches
  180. To free reclaimable slab objects (includes dentries and inodes)::
  181. echo 2 > /proc/sys/vm/drop_caches
  182. To free slab objects and pagecache::
  183. echo 3 > /proc/sys/vm/drop_caches
  184. This is a non-destructive operation and will not free any dirty objects.
  185. To increase the number of objects freed by this operation, the user may run
  186. `sync` prior to writing to /proc/sys/vm/drop_caches. This will minimize the
  187. number of dirty objects on the system and create more candidates to be
  188. dropped.
  189. This file is not a means to control the growth of the various kernel caches
  190. (inodes, dentries, pagecache, etc...) These objects are automatically
  191. reclaimed by the kernel when memory is needed elsewhere on the system.
  192. Use of this file can cause performance problems. Since it discards cached
  193. objects, it may cost a significant amount of I/O and CPU to recreate the
  194. dropped objects, especially if they were under heavy use. Because of this,
  195. use outside of a testing or debugging environment is not recommended.
  196. You may see informational messages in your kernel log when this file is
  197. used::
  198. cat (1234): drop_caches: 3
  199. These are informational only. They do not mean that anything is wrong
  200. with your system. To disable them, echo 4 (bit 2) into drop_caches.
  201. extfrag_threshold
  202. =================
  203. This parameter affects whether the kernel will compact memory or direct
  204. reclaim to satisfy a high-order allocation. The extfrag/extfrag_index file in
  205. debugfs shows what the fragmentation index for each order is in each zone in
  206. the system. Values tending towards 0 imply allocations would fail due to lack
  207. of memory, values towards 1000 imply failures are due to fragmentation and -1
  208. implies that the allocation will succeed as long as watermarks are met.
  209. The kernel will not compact memory in a zone if the
  210. fragmentation index is <= extfrag_threshold. The default value is 500.
  211. highmem_is_dirtyable
  212. ====================
  213. Available only for systems with CONFIG_HIGHMEM enabled (32b systems).
  214. This parameter controls whether the high memory is considered for dirty
  215. writers throttling. This is not the case by default which means that
  216. only the amount of memory directly visible/usable by the kernel can
  217. be dirtied. As a result, on systems with a large amount of memory and
  218. lowmem basically depleted writers might be throttled too early and
  219. streaming writes can get very slow.
  220. Changing the value to non zero would allow more memory to be dirtied
  221. and thus allow writers to write more data which can be flushed to the
  222. storage more effectively. Note this also comes with a risk of pre-mature
  223. OOM killer because some writers (e.g. direct block device writes) can
  224. only use the low memory and they can fill it up with dirty data without
  225. any throttling.
  226. extra_free_kbytes
  227. This parameter tells the VM to keep extra free memory between the threshold
  228. where background reclaim (kswapd) kicks in, and the threshold where direct
  229. reclaim (by allocating processes) kicks in.
  230. This is useful for workloads that require low latency memory allocations
  231. and have a bounded burstiness in memory allocations, for example a
  232. realtime application that receives and transmits network traffic
  233. (causing in-kernel memory allocations) with a maximum total message burst
  234. size of 200MB may need 200MB of extra free memory to avoid direct reclaim
  235. related latencies.
  236. ==============================================================
  237. hugetlb_shm_group
  238. =================
  239. hugetlb_shm_group contains group id that is allowed to create SysV
  240. shared memory segment using hugetlb page.
  241. laptop_mode
  242. ===========
  243. laptop_mode is a knob that controls "laptop mode". All the things that are
  244. controlled by this knob are discussed in Documentation/admin-guide/laptops/laptop-mode.rst.
  245. legacy_va_layout
  246. ================
  247. If non-zero, this sysctl disables the new 32-bit mmap layout - the kernel
  248. will use the legacy (2.4) layout for all processes.
  249. lowmem_reserve_ratio
  250. ====================
  251. For some specialised workloads on highmem machines it is dangerous for
  252. the kernel to allow process memory to be allocated from the "lowmem"
  253. zone. This is because that memory could then be pinned via the mlock()
  254. system call, or by unavailability of swapspace.
  255. And on large highmem machines this lack of reclaimable lowmem memory
  256. can be fatal.
  257. So the Linux page allocator has a mechanism which prevents allocations
  258. which *could* use highmem from using too much lowmem. This means that
  259. a certain amount of lowmem is defended from the possibility of being
  260. captured into pinned user memory.
  261. (The same argument applies to the old 16 megabyte ISA DMA region. This
  262. mechanism will also defend that region from allocations which could use
  263. highmem or lowmem).
  264. The `lowmem_reserve_ratio` tunable determines how aggressive the kernel is
  265. in defending these lower zones.
  266. If you have a machine which uses highmem or ISA DMA and your
  267. applications are using mlock(), or if you are running with no swap then
  268. you probably should change the lowmem_reserve_ratio setting.
  269. The lowmem_reserve_ratio is an array. You can see them by reading this file::
  270. % cat /proc/sys/vm/lowmem_reserve_ratio
  271. 256 256 32
  272. But, these values are not used directly. The kernel calculates # of protection
  273. pages for each zones from them. These are shown as array of protection pages
  274. in /proc/zoneinfo like followings. (This is an example of x86-64 box).
  275. Each zone has an array of protection pages like this::
  276. Node 0, zone DMA
  277. pages free 1355
  278. min 3
  279. low 3
  280. high 4
  281. :
  282. :
  283. numa_other 0
  284. protection: (0, 2004, 2004, 2004)
  285. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  286. pagesets
  287. cpu: 0 pcp: 0
  288. :
  289. These protections are added to score to judge whether this zone should be used
  290. for page allocation or should be reclaimed.
  291. In this example, if normal pages (index=2) are required to this DMA zone and
  292. watermark[WMARK_HIGH] is used for watermark, the kernel judges this zone should
  293. not be used because pages_free(1355) is smaller than watermark + protection[2]
  294. (4 + 2004 = 2008). If this protection value is 0, this zone would be used for
  295. normal page requirement. If requirement is DMA zone(index=0), protection[0]
  296. (=0) is used.
  297. zone[i]'s protection[j] is calculated by following expression::
  298. (i < j):
  299. zone[i]->protection[j]
  300. = (total sums of managed_pages from zone[i+1] to zone[j] on the node)
  301. / lowmem_reserve_ratio[i];
  302. (i = j):
  303. (should not be protected. = 0;
  304. (i > j):
  305. (not necessary, but looks 0)
  306. The default values of lowmem_reserve_ratio[i] are
  307. === ====================================
  308. 256 (if zone[i] means DMA or DMA32 zone)
  309. 32 (others)
  310. === ====================================
  311. As above expression, they are reciprocal number of ratio.
  312. 256 means 1/256. # of protection pages becomes about "0.39%" of total managed
  313. pages of higher zones on the node.
  314. If you would like to protect more pages, smaller values are effective.
  315. The minimum value is 1 (1/1 -> 100%). The value less than 1 completely
  316. disables protection of the pages.
  317. max_map_count:
  318. ==============
  319. This file contains the maximum number of memory map areas a process
  320. may have. Memory map areas are used as a side-effect of calling
  321. malloc, directly by mmap, mprotect, and madvise, and also when loading
  322. shared libraries.
  323. While most applications need less than a thousand maps, certain
  324. programs, particularly malloc debuggers, may consume lots of them,
  325. e.g., up to one or two maps per allocation.
  326. The default value is 65536.
  327. memory_failure_early_kill:
  328. ==========================
  329. Control how to kill processes when uncorrected memory error (typically
  330. a 2bit error in a memory module) is detected in the background by hardware
  331. that cannot be handled by the kernel. In some cases (like the page
  332. still having a valid copy on disk) the kernel will handle the failure
  333. transparently without affecting any applications. But if there is
  334. no other uptodate copy of the data it will kill to prevent any data
  335. corruptions from propagating.
  336. 1: Kill all processes that have the corrupted and not reloadable page mapped
  337. as soon as the corruption is detected. Note this is not supported
  338. for a few types of pages, like kernel internally allocated data or
  339. the swap cache, but works for the majority of user pages.
  340. 0: Only unmap the corrupted page from all processes and only kill a process
  341. who tries to access it.
  342. The kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes can
  343. handle this if they want to.
  344. This is only active on architectures/platforms with advanced machine
  345. check handling and depends on the hardware capabilities.
  346. Applications can override this setting individually with the PR_MCE_KILL prctl
  347. memory_failure_recovery
  348. =======================
  349. Enable memory failure recovery (when supported by the platform)
  350. 1: Attempt recovery.
  351. 0: Always panic on a memory failure.
  352. min_free_kbytes
  353. ===============
  354. This is used to force the Linux VM to keep a minimum number
  355. of kilobytes free. The VM uses this number to compute a
  356. watermark[WMARK_MIN] value for each lowmem zone in the system.
  357. Each lowmem zone gets a number of reserved free pages based
  358. proportionally on its size.
  359. Some minimal amount of memory is needed to satisfy PF_MEMALLOC
  360. allocations; if you set this to lower than 1024KB, your system will
  361. become subtly broken, and prone to deadlock under high loads.
  362. Setting this too high will OOM your machine instantly.
  363. min_slab_ratio
  364. ==============
  365. This is available only on NUMA kernels.
  366. A percentage of the total pages in each zone. On Zone reclaim
  367. (fallback from the local zone occurs) slabs will be reclaimed if more
  368. than this percentage of pages in a zone are reclaimable slab pages.
  369. This insures that the slab growth stays under control even in NUMA
  370. systems that rarely perform global reclaim.
  371. The default is 5 percent.
  372. Note that slab reclaim is triggered in a per zone / node fashion.
  373. The process of reclaiming slab memory is currently not node specific
  374. and may not be fast.
  375. min_unmapped_ratio
  376. ==================
  377. This is available only on NUMA kernels.
  378. This is a percentage of the total pages in each zone. Zone reclaim will
  379. only occur if more than this percentage of pages are in a state that
  380. zone_reclaim_mode allows to be reclaimed.
  381. If zone_reclaim_mode has the value 4 OR'd, then the percentage is compared
  382. against all file-backed unmapped pages including swapcache pages and tmpfs
  383. files. Otherwise, only unmapped pages backed by normal files but not tmpfs
  384. files and similar are considered.
  385. The default is 1 percent.
  386. mmap_min_addr
  387. =============
  388. This file indicates the amount of address space which a user process will
  389. be restricted from mmapping. Since kernel null dereference bugs could
  390. accidentally operate based on the information in the first couple of pages
  391. of memory userspace processes should not be allowed to write to them. By
  392. default this value is set to 0 and no protections will be enforced by the
  393. security module. Setting this value to something like 64k will allow the
  394. vast majority of applications to work correctly and provide defense in depth
  395. against future potential kernel bugs.
  396. mmap_rnd_bits
  397. =============
  398. This value can be used to select the number of bits to use to
  399. determine the random offset to the base address of vma regions
  400. resulting from mmap allocations on architectures which support
  401. tuning address space randomization. This value will be bounded
  402. by the architecture's minimum and maximum supported values.
  403. This value can be changed after boot using the
  404. /proc/sys/vm/mmap_rnd_bits tunable
  405. mmap_rnd_compat_bits
  406. ====================
  407. This value can be used to select the number of bits to use to
  408. determine the random offset to the base address of vma regions
  409. resulting from mmap allocations for applications run in
  410. compatibility mode on architectures which support tuning address
  411. space randomization. This value will be bounded by the
  412. architecture's minimum and maximum supported values.
  413. This value can be changed after boot using the
  414. /proc/sys/vm/mmap_rnd_compat_bits tunable
  415. nr_hugepages
  416. ============
  417. Change the minimum size of the hugepage pool.
  418. See Documentation/admin-guide/mm/hugetlbpage.rst
  419. nr_hugepages_mempolicy
  420. ======================
  421. Change the size of the hugepage pool at run-time on a specific
  422. set of NUMA nodes.
  423. See Documentation/admin-guide/mm/hugetlbpage.rst
  424. nr_overcommit_hugepages
  425. =======================
  426. Change the maximum size of the hugepage pool. The maximum is
  427. nr_hugepages + nr_overcommit_hugepages.
  428. See Documentation/admin-guide/mm/hugetlbpage.rst
  429. nr_trim_pages
  430. =============
  431. This is available only on NOMMU kernels.
  432. This value adjusts the excess page trimming behaviour of power-of-2 aligned
  433. NOMMU mmap allocations.
  434. A value of 0 disables trimming of allocations entirely, while a value of 1
  435. trims excess pages aggressively. Any value >= 1 acts as the watermark where
  436. trimming of allocations is initiated.
  437. The default value is 1.
  438. See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
  439. numa_zonelist_order
  440. ===================
  441. This sysctl is only for NUMA and it is deprecated. Anything but
  442. Node order will fail!
  443. 'where the memory is allocated from' is controlled by zonelists.
  444. (This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation.
  445. you may be able to read ZONE_DMA as ZONE_DMA32...)
  446. In non-NUMA case, a zonelist for GFP_KERNEL is ordered as following.
  447. ZONE_NORMAL -> ZONE_DMA
  448. This means that a memory allocation request for GFP_KERNEL will
  449. get memory from ZONE_DMA only when ZONE_NORMAL is not available.
  450. In NUMA case, you can think of following 2 types of order.
  451. Assume 2 node NUMA and below is zonelist of Node(0)'s GFP_KERNEL::
  452. (A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL
  453. (B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA.
  454. Type(A) offers the best locality for processes on Node(0), but ZONE_DMA
  455. will be used before ZONE_NORMAL exhaustion. This increases possibility of
  456. out-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small.
  457. Type(B) cannot offer the best locality but is more robust against OOM of
  458. the DMA zone.
  459. Type(A) is called as "Node" order. Type (B) is "Zone" order.
  460. "Node order" orders the zonelists by node, then by zone within each node.
  461. Specify "[Nn]ode" for node order
  462. "Zone Order" orders the zonelists by zone type, then by node within each
  463. zone. Specify "[Zz]one" for zone order.
  464. Specify "[Dd]efault" to request automatic configuration.
  465. On 32-bit, the Normal zone needs to be preserved for allocations accessible
  466. by the kernel, so "zone" order will be selected.
  467. On 64-bit, devices that require DMA32/DMA are relatively rare, so "node"
  468. order will be selected.
  469. Default order is recommended unless this is causing problems for your
  470. system/application.
  471. oom_dump_tasks
  472. ==============
  473. Enables a system-wide task dump (excluding kernel threads) to be produced
  474. when the kernel performs an OOM-killing and includes such information as
  475. pid, uid, tgid, vm size, rss, pgtables_bytes, swapents, oom_score_adj
  476. score, and name. This is helpful to determine why the OOM killer was
  477. invoked, to identify the rogue task that caused it, and to determine why
  478. the OOM killer chose the task it did to kill.
  479. If this is set to zero, this information is suppressed. On very
  480. large systems with thousands of tasks it may not be feasible to dump
  481. the memory state information for each one. Such systems should not
  482. be forced to incur a performance penalty in OOM conditions when the
  483. information may not be desired.
  484. If this is set to non-zero, this information is shown whenever the
  485. OOM killer actually kills a memory-hogging task.
  486. The default value is 1 (enabled).
  487. oom_kill_allocating_task
  488. ========================
  489. This enables or disables killing the OOM-triggering task in
  490. out-of-memory situations.
  491. If this is set to zero, the OOM killer will scan through the entire
  492. tasklist and select a task based on heuristics to kill. This normally
  493. selects a rogue memory-hogging task that frees up a large amount of
  494. memory when killed.
  495. If this is set to non-zero, the OOM killer simply kills the task that
  496. triggered the out-of-memory condition. This avoids the expensive
  497. tasklist scan.
  498. If panic_on_oom is selected, it takes precedence over whatever value
  499. is used in oom_kill_allocating_task.
  500. The default value is 0.
  501. overcommit_kbytes
  502. =================
  503. When overcommit_memory is set to 2, the committed address space is not
  504. permitted to exceed swap plus this amount of physical RAM. See below.
  505. Note: overcommit_kbytes is the counterpart of overcommit_ratio. Only one
  506. of them may be specified at a time. Setting one disables the other (which
  507. then appears as 0 when read).
  508. overcommit_memory
  509. =================
  510. This value contains a flag that enables memory overcommitment.
  511. When this flag is 0, the kernel attempts to estimate the amount
  512. of free memory left when userspace requests more memory.
  513. When this flag is 1, the kernel pretends there is always enough
  514. memory until it actually runs out.
  515. When this flag is 2, the kernel uses a "never overcommit"
  516. policy that attempts to prevent any overcommit of memory.
  517. Note that user_reserve_kbytes affects this policy.
  518. This feature can be very useful because there are a lot of
  519. programs that malloc() huge amounts of memory "just-in-case"
  520. and don't use much of it.
  521. The default value is 0.
  522. See Documentation/vm/overcommit-accounting.rst and
  523. mm/util.c::__vm_enough_memory() for more information.
  524. overcommit_ratio
  525. ================
  526. When overcommit_memory is set to 2, the committed address
  527. space is not permitted to exceed swap plus this percentage
  528. of physical RAM. See above.
  529. page-cluster
  530. ============
  531. page-cluster controls the number of pages up to which consecutive pages
  532. are read in from swap in a single attempt. This is the swap counterpart
  533. to page cache readahead.
  534. The mentioned consecutivity is not in terms of virtual/physical addresses,
  535. but consecutive on swap space - that means they were swapped out together.
  536. It is a logarithmic value - setting it to zero means "1 page", setting
  537. it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
  538. Zero disables swap readahead completely.
  539. The default value is three (eight pages at a time). There may be some
  540. small benefits in tuning this to a different value if your workload is
  541. swap-intensive.
  542. Lower values mean lower latencies for initial faults, but at the same time
  543. extra faults and I/O delays for following faults if they would have been part of
  544. that consecutive pages readahead would have brought in.
  545. panic_on_oom
  546. ============
  547. This enables or disables panic on out-of-memory feature.
  548. If this is set to 0, the kernel will kill some rogue process,
  549. called oom_killer. Usually, oom_killer can kill rogue processes and
  550. system will survive.
  551. If this is set to 1, the kernel panics when out-of-memory happens.
  552. However, if a process limits using nodes by mempolicy/cpusets,
  553. and those nodes become memory exhaustion status, one process
  554. may be killed by oom-killer. No panic occurs in this case.
  555. Because other nodes' memory may be free. This means system total status
  556. may be not fatal yet.
  557. If this is set to 2, the kernel panics compulsorily even on the
  558. above-mentioned. Even oom happens under memory cgroup, the whole
  559. system panics.
  560. The default value is 0.
  561. 1 and 2 are for failover of clustering. Please select either
  562. according to your policy of failover.
  563. panic_on_oom=2+kdump gives you very strong tool to investigate
  564. why oom happens. You can get snapshot.
  565. percpu_pagelist_fraction
  566. ========================
  567. This is the fraction of pages at most (high mark pcp->high) in each zone that
  568. are allocated for each per cpu page list. The min value for this is 8. It
  569. means that we don't allow more than 1/8th of pages in each zone to be
  570. allocated in any single per_cpu_pagelist. This entry only changes the value
  571. of hot per cpu pagelists. User can specify a number like 100 to allocate
  572. 1/100th of each zone to each per cpu page list.
  573. The batch value of each per cpu pagelist is also updated as a result. It is
  574. set to pcp->high/4. The upper limit of batch is (PAGE_SHIFT * 8)
  575. The initial value is zero. Kernel does not use this value at boot time to set
  576. the high water marks for each per cpu page list. If the user writes '0' to this
  577. sysctl, it will revert to this default behavior.
  578. stat_interval
  579. =============
  580. The time interval between which vm statistics are updated. The default
  581. is 1 second.
  582. stat_refresh
  583. ============
  584. Any read or write (by root only) flushes all the per-cpu vm statistics
  585. into their global totals, for more accurate reports when testing
  586. e.g. cat /proc/sys/vm/stat_refresh /proc/meminfo
  587. As a side-effect, it also checks for negative totals (elsewhere reported
  588. as 0) and "fails" with EINVAL if any are found, with a warning in dmesg.
  589. (At time of writing, a few stats are known sometimes to be found negative,
  590. with no ill effects: errors and warnings on these stats are suppressed.)
  591. numa_stat
  592. =========
  593. This interface allows runtime configuration of numa statistics.
  594. When page allocation performance becomes a bottleneck and you can tolerate
  595. some possible tool breakage and decreased numa counter precision, you can
  596. do::
  597. echo 0 > /proc/sys/vm/numa_stat
  598. When page allocation performance is not a bottleneck and you want all
  599. tooling to work, you can do::
  600. echo 1 > /proc/sys/vm/numa_stat
  601. swappiness
  602. ==========
  603. This control is used to define the rough relative IO cost of swapping
  604. and filesystem paging, as a value between 0 and 200. At 100, the VM
  605. assumes equal IO cost and will thus apply memory pressure to the page
  606. cache and swap-backed pages equally; lower values signify more
  607. expensive swap IO, higher values indicates cheaper.
  608. Keep in mind that filesystem IO patterns under memory pressure tend to
  609. be more efficient than swap's random IO. An optimal value will require
  610. experimentation and will also be workload-dependent.
  611. The default value is 60.
  612. For in-memory swap, like zram or zswap, as well as hybrid setups that
  613. have swap on faster devices than the filesystem, values beyond 100 can
  614. be considered. For example, if the random IO against the swap device
  615. is on average 2x faster than IO from the filesystem, swappiness should
  616. be 133 (x + 2x = 200, 2x = 133.33).
  617. At 0, the kernel will not initiate swap until the amount of free and
  618. file-backed pages is less than the high watermark in a zone.
  619. unprivileged_userfaultfd
  620. ========================
  621. This flag controls the mode in which unprivileged users can use the
  622. userfaultfd system calls. Set this to 0 to restrict unprivileged users
  623. to handle page faults in user mode only. In this case, users without
  624. SYS_CAP_PTRACE must pass UFFD_USER_MODE_ONLY in order for userfaultfd to
  625. succeed. Prohibiting use of userfaultfd for handling faults from kernel
  626. mode may make certain vulnerabilities more difficult to exploit.
  627. Set this to 1 to allow unprivileged users to use the userfaultfd system
  628. calls without any restrictions.
  629. The default value is 0.
  630. user_reserve_kbytes
  631. ===================
  632. When overcommit_memory is set to 2, "never overcommit" mode, reserve
  633. min(3% of current process size, user_reserve_kbytes) of free memory.
  634. This is intended to prevent a user from starting a single memory hogging
  635. process, such that they cannot recover (kill the hog).
  636. user_reserve_kbytes defaults to min(3% of the current process size, 128MB).
  637. If this is reduced to zero, then the user will be allowed to allocate
  638. all free memory with a single process, minus admin_reserve_kbytes.
  639. Any subsequent attempts to execute a command will result in
  640. "fork: Cannot allocate memory".
  641. Changing this takes effect whenever an application requests memory.
  642. vfs_cache_pressure
  643. ==================
  644. This percentage value controls the tendency of the kernel to reclaim
  645. the memory which is used for caching of directory and inode objects.
  646. At the default value of vfs_cache_pressure=100 the kernel will attempt to
  647. reclaim dentries and inodes at a "fair" rate with respect to pagecache and
  648. swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer
  649. to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will
  650. never reclaim dentries and inodes due to memory pressure and this can easily
  651. lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100
  652. causes the kernel to prefer to reclaim dentries and inodes.
  653. Increasing vfs_cache_pressure significantly beyond 100 may have negative
  654. performance impact. Reclaim code needs to take various locks to find freeable
  655. directory and inode objects. With vfs_cache_pressure=1000, it will look for
  656. ten times more freeable objects than there are.
  657. watermark_boost_factor
  658. ======================
  659. This factor controls the level of reclaim when memory is being fragmented.
  660. It defines the percentage of the high watermark of a zone that will be
  661. reclaimed if pages of different mobility are being mixed within pageblocks.
  662. The intent is that compaction has less work to do in the future and to
  663. increase the success rate of future high-order allocations such as SLUB
  664. allocations, THP and hugetlbfs pages.
  665. To make it sensible with respect to the watermark_scale_factor
  666. parameter, the unit is in fractions of 10,000. The default value of
  667. 15,000 on !DISCONTIGMEM configurations means that up to 150% of the high
  668. watermark will be reclaimed in the event of a pageblock being mixed due
  669. to fragmentation. The level of reclaim is determined by the number of
  670. fragmentation events that occurred in the recent past. If this value is
  671. smaller than a pageblock then a pageblocks worth of pages will be reclaimed
  672. (e.g. 2MB on 64-bit x86). A boost factor of 0 will disable the feature.
  673. watermark_scale_factor
  674. ======================
  675. This factor controls the aggressiveness of kswapd. It defines the
  676. amount of memory left in a node/system before kswapd is woken up and
  677. how much memory needs to be free before kswapd goes back to sleep.
  678. The unit is in fractions of 10,000. The default value of 10 means the
  679. distances between watermarks are 0.1% of the available memory in the
  680. node/system. The maximum value is 1000, or 10% of memory.
  681. A high rate of threads entering direct reclaim (allocstall) or kswapd
  682. going to sleep prematurely (kswapd_low_wmark_hit_quickly) can indicate
  683. that the number of free pages kswapd maintains for latency reasons is
  684. too small for the allocation bursts occurring in the system. This knob
  685. can then be used to tune kswapd aggressiveness accordingly.
  686. zone_reclaim_mode
  687. =================
  688. Zone_reclaim_mode allows someone to set more or less aggressive approaches to
  689. reclaim memory when a zone runs out of memory. If it is set to zero then no
  690. zone reclaim occurs. Allocations will be satisfied from other zones / nodes
  691. in the system.
  692. This is value OR'ed together of
  693. = ===================================
  694. 1 Zone reclaim on
  695. 2 Zone reclaim writes dirty pages out
  696. 4 Zone reclaim swaps pages
  697. = ===================================
  698. zone_reclaim_mode is disabled by default. For file servers or workloads
  699. that benefit from having their data cached, zone_reclaim_mode should be
  700. left disabled as the caching effect is likely to be more important than
  701. data locality.
  702. Consider enabling one or more zone_reclaim mode bits if it's known that the
  703. workload is partitioned such that each partition fits within a NUMA node
  704. and that accessing remote memory would cause a measurable performance
  705. reduction. The page allocator will take additional actions before
  706. allocating off node pages.
  707. Allowing zone reclaim to write out pages stops processes that are
  708. writing large amounts of data from dirtying pages on other nodes. Zone
  709. reclaim will write out dirty pages if a zone fills up and so effectively
  710. throttle the process. This may decrease the performance of a single process
  711. since it cannot use all of system memory to buffer the outgoing writes
  712. anymore but it preserve the memory on other nodes so that the performance
  713. of other processes running on other nodes will not be affected.
  714. Allowing regular swap effectively restricts allocations to the local
  715. node unless explicitly overridden by memory policies or cpuset
  716. configurations.