vm.rst 41 KB

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