vm.rst 39 KB

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