xref: /linux/Documentation/admin-guide/sysctl/vm.rst (revision d25711a9f32ac99d5c04a48d00d802596a8a1814)
1===============================
2Documentation for /proc/sys/vm/
3===============================
4
5kernel version 2.6.29
6
7Copyright (c) 1998, 1999,  Rik van Riel <riel@nl.linux.org>
8
9Copyright (c) 2008         Peter W. Morreale <pmorreale@novell.com>
10
11For general info and legal blurb, please look in index.rst.
12
13------------------------------------------------------------------------------
14
15This file contains the documentation for the sysctl files in
16/proc/sys/vm and is valid for Linux kernel version 2.6.29.
17
18The files in this directory can be used to tune the operation
19of the virtual memory (VM) subsystem of the Linux kernel and
20the writeout of dirty data to disk.
21
22Default values and initialization routines for most of these
23files can be found in mm/swap.c.
24
25Currently, these files are in /proc/sys/vm:
26
27- admin_reserve_kbytes
28- compact_memory
29- compaction_proactiveness
30- compact_unevictable_allowed
31- defrag_mode
32- dirty_background_bytes
33- dirty_background_ratio
34- dirty_bytes
35- dirty_expire_centisecs
36- dirty_ratio
37- dirtytime_expire_seconds
38- dirty_writeback_centisecs
39- drop_caches
40- enable_soft_offline
41- extfrag_threshold
42- highmem_is_dirtyable
43- hugetlb_shm_group
44- legacy_va_layout
45- lowmem_reserve_ratio
46- max_map_count
47- mem_profiling         (only if CONFIG_MEM_ALLOC_PROFILING=y)
48- memory_failure_early_kill
49- memory_failure_recovery
50- min_free_kbytes
51- min_slab_ratio
52- min_unmapped_ratio
53- mmap_min_addr
54- mmap_rnd_bits
55- mmap_rnd_compat_bits
56- movable_gigantic_pages
57- nr_hugepages
58- nr_hugepages_mempolicy
59- nr_overcommit_hugepages
60- nr_trim_pages         (only if CONFIG_MMU=n)
61- numa_zonelist_order
62- oom_dump_tasks
63- oom_kill_allocating_task
64- overcommit_kbytes
65- overcommit_memory
66- overcommit_ratio
67- page-cluster
68- page_lock_unfairness
69- panic_on_oom
70- panic_on_unrecoverable_memory_failure
71- percpu_pagelist_high_fraction
72- stat_interval
73- stat_refresh
74- numa_stat
75- swappiness
76- unprivileged_userfaultfd
77- user_reserve_kbytes
78- vfs_cache_pressure
79- vfs_cache_pressure_denom
80- watermark_boost_factor
81- watermark_scale_factor
82- zone_reclaim_mode
83
84
85admin_reserve_kbytes
86====================
87
88The amount of free memory in the system that should be reserved for users
89with the capability cap_sys_admin.
90
91admin_reserve_kbytes defaults to min(3% of free pages, 8MB)
92
93That should provide enough for the admin to log in and kill a process,
94if necessary, under the default overcommit 'guess' mode.
95
96Systems running under overcommit 'never' should increase this to account
97for the full Virtual Memory Size of programs used to recover. Otherwise,
98root may not be able to log in to recover the system.
99
100How do you calculate a minimum useful reserve?
101
102sshd or login + bash (or some other shell) + top (or ps, kill, etc.)
103
104For overcommit 'guess', we can sum resident set sizes (RSS).
105On x86_64 this is about 8MB.
106
107For overcommit 'never', we can take the max of their virtual sizes (VSZ)
108and add the sum of their RSS.
109On x86_64 this is about 128MB.
110
111Changing this takes effect whenever an application requests memory.
112
113
114compact_memory
115==============
116
117Available only when CONFIG_COMPACTION is set. When 1 is written to the file,
118all zones are compacted such that free memory is available in contiguous
119blocks where possible. This can be important for example in the allocation of
120huge pages although processes will also directly compact memory as required.
121
122compaction_proactiveness
123========================
124
125This tunable takes a value in the range [0, 100] with a default value of
12620. This tunable determines how aggressively compaction is done in the
127background. Write of a non zero value to this tunable will immediately
128trigger the proactive compaction. Setting it to 0 disables proactive compaction.
129
130Note that compaction has a non-trivial system-wide impact as pages
131belonging to different processes are moved around, which could also lead
132to latency spikes in unsuspecting applications. The kernel employs
133various heuristics to avoid wasting CPU cycles if it detects that
134proactive compaction is not being effective.
135
136Setting the value above 80 will, in addition to lowering the acceptable level
137of fragmentation, make the compaction code more sensitive to increases in
138fragmentation, i.e. compaction will trigger more often, but reduce
139fragmentation by a smaller amount.
140This makes the fragmentation level more stable over time.
141
142Be careful when setting it to extreme values like 100, as that may
143cause excessive background compaction activity.
144
145compact_unevictable_allowed
146===========================
147
148Available only when CONFIG_COMPACTION is set. When set to 1, compaction is
149allowed to examine the unevictable lru (mlocked pages) for pages to compact.
150This should be used on systems where stalls for minor page faults are an
151acceptable trade for large contiguous free memory.  Set to 0 to prevent
152compaction from moving pages that are unevictable.  Default value is 1.
153On CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page fault, due
154to compaction, which would block the task from becoming active until the fault
155is resolved.
156
157defrag_mode
158===========
159
160When set to 1, the page allocator tries harder to avoid fragmentation
161and maintain the ability to produce huge pages / higher-order pages.
162
163It is recommended to enable this right after boot, as fragmentation,
164once it occurred, can be long-lasting or even permanent.
165
166dirty_background_bytes
167======================
168
169Contains the amount of dirty memory at which the background kernel
170flusher threads will start writeback.
171
172Note:
173  dirty_background_bytes is the counterpart of dirty_background_ratio. Only
174  one of them may be specified at a time. When one sysctl is written it is
175  immediately taken into account to evaluate the dirty memory limits and the
176  other appears as 0 when read.
177
178
179dirty_background_ratio
180======================
181
182Contains, as a percentage of total available memory that contains free pages
183and reclaimable pages, the number of pages at which the background kernel
184flusher threads will start writing out dirty data.
185
186The total available memory is not equal to total system memory.
187
188
189dirty_bytes
190===========
191
192Contains the amount of dirty memory at which a process generating disk writes
193will itself start writeback.
194
195Note: dirty_bytes is the counterpart of dirty_ratio. Only one of them may be
196specified at a time. When one sysctl is written it is immediately taken into
197account to evaluate the dirty memory limits and the other appears as 0 when
198read.
199
200Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any
201value lower than this limit will be ignored and the old configuration will be
202retained.
203
204
205dirty_expire_centisecs
206======================
207
208This tunable is used to define when dirty data is old enough to be eligible
209for writeout by the kernel flusher threads.  It is expressed in 100'ths
210of a second.  Data which has been dirty in-memory for longer than this
211interval will be written out next time a flusher thread wakes up.
212
213
214dirty_ratio
215===========
216
217Contains, as a percentage of total available memory that contains free pages
218and reclaimable pages, the number of pages at which a process which is
219generating disk writes will itself start writing out dirty data.
220
221The total available memory is not equal to total system memory.
222
223
224dirtytime_expire_seconds
225========================
226
227When a lazytime inode is constantly having its pages dirtied, the inode with
228an updated timestamp will never get chance to be written out.  And, if the
229only thing that has happened on the file system is a dirtytime inode caused
230by an atime update, a worker will be scheduled to make sure that inode
231eventually gets pushed out to disk.  This tunable is used to define when dirty
232inode is old enough to be eligible for writeback by the kernel flusher threads.
233And, it is also used as the interval to wakeup dirtytime_writeback thread.
234
235Setting this to zero disables periodic dirtytime writeback.
236
237
238dirty_writeback_centisecs
239=========================
240
241The kernel flusher threads will periodically wake up and write `old` data
242out to disk.  This tunable expresses the interval between those wakeups, in
243100'ths of a second.
244
245Setting this to zero disables periodic writeback altogether.
246
247
248drop_caches
249===========
250
251Writing to this will cause the kernel to drop clean caches, as well as
252reclaimable slab objects like dentries and inodes.  Once dropped, their
253memory becomes free.
254
255To free pagecache::
256
257	echo 1 > /proc/sys/vm/drop_caches
258
259To free reclaimable slab objects (includes dentries and inodes)::
260
261	echo 2 > /proc/sys/vm/drop_caches
262
263To free slab objects and pagecache::
264
265	echo 3 > /proc/sys/vm/drop_caches
266
267This is a non-destructive operation and will not free any dirty objects.
268To increase the number of objects freed by this operation, the user may run
269`sync` prior to writing to /proc/sys/vm/drop_caches.  This will minimize the
270number of dirty objects on the system and create more candidates to be
271dropped.
272
273This file is not a means to control the growth of the various kernel caches
274(inodes, dentries, pagecache, etc...)  These objects are automatically
275reclaimed by the kernel when memory is needed elsewhere on the system.
276
277Use of this file can cause performance problems.  Since it discards cached
278objects, it may cost a significant amount of I/O and CPU to recreate the
279dropped objects, especially if they were under heavy use.  Because of this,
280use outside of a testing or debugging environment is not recommended.
281
282You may see informational messages in your kernel log when this file is
283used::
284
285	cat (1234): drop_caches: 3
286
287These are informational only.  They do not mean that anything is wrong
288with your system.  To disable them, echo 4 (bit 2) into drop_caches.
289
290enable_soft_offline
291===================
292Correctable memory errors are very common on servers. Soft-offline is kernel's
293solution for memory pages having (excessive) corrected memory errors.
294
295For different types of page, soft-offline has different behaviors / costs.
296
297- For a raw error page, soft-offline migrates the in-use page's content to
298  a new raw page.
299
300- For a page that is part of a transparent hugepage, soft-offline splits the
301  transparent hugepage into raw pages, then migrates only the raw error page.
302  As a result, user is transparently backed by 1 less hugepage, impacting
303  memory access performance.
304
305- For a page that is part of a HugeTLB hugepage, soft-offline first migrates
306  the entire HugeTLB hugepage, during which a free hugepage will be consumed
307  as migration target.  Then the original hugepage is dissolved into raw
308  pages without compensation, reducing the capacity of the HugeTLB pool by 1.
309
310It is user's call to choose between reliability (staying away from fragile
311physical memory) vs performance / capacity implications in transparent and
312HugeTLB cases.
313
314For all architectures, enable_soft_offline controls whether to soft offline
315memory pages.  When set to 1, kernel attempts to soft offline the pages
316whenever it thinks needed.  When set to 0, kernel returns EOPNOTSUPP to
317the request to soft offline the pages.  Its default value is 1.
318
319It is worth mentioning that after setting enable_soft_offline to 0, the
320following requests to soft offline pages will not be performed:
321
322- Request to soft offline pages from RAS Correctable Errors Collector.
323
324- On ARM, the request to soft offline pages from GHES driver.
325
326- On PARISC, the request to soft offline pages from Page Deallocation Table.
327
328extfrag_threshold
329=================
330
331This parameter affects whether the kernel will compact memory or direct
332reclaim to satisfy a high-order allocation. The extfrag/extfrag_index file in
333debugfs shows what the fragmentation index for each order is in each zone in
334the system. Values tending towards 0 imply allocations would fail due to lack
335of memory, values towards 1000 imply failures are due to fragmentation and -1
336implies that the allocation will succeed as long as watermarks are met.
337
338The kernel will not compact memory in a zone if the
339fragmentation index is <= extfrag_threshold. The default value is 500.
340
341
342highmem_is_dirtyable
343====================
344
345Available only for systems with CONFIG_HIGHMEM enabled (32b systems).
346
347This parameter controls whether the high memory is considered for dirty
348writers throttling.  This is not the case by default which means that
349only the amount of memory directly visible/usable by the kernel can
350be dirtied. As a result, on systems with a large amount of memory and
351lowmem basically depleted writers might be throttled too early and
352streaming writes can get very slow.
353
354Changing the value to non zero would allow more memory to be dirtied
355and thus allow writers to write more data which can be flushed to the
356storage more effectively. Note this also comes with a risk of pre-mature
357OOM killer because some writers (e.g. direct block device writes) can
358only use the low memory and they can fill it up with dirty data without
359any throttling.
360
361
362hugetlb_shm_group
363=================
364
365hugetlb_shm_group contains group id that is allowed to create SysV
366shared memory segment using hugetlb page.
367
368
369legacy_va_layout
370================
371
372If non-zero, this sysctl disables the new 32-bit mmap layout - the kernel
373will use the legacy (2.4) layout for all processes.
374
375
376lowmem_reserve_ratio
377====================
378
379For some specialised workloads on highmem machines it is dangerous for
380the kernel to allow process memory to be allocated from the "lowmem"
381zone.  This is because that memory could then be pinned via the mlock()
382system call, or by unavailability of swapspace.
383
384And on large highmem machines this lack of reclaimable lowmem memory
385can be fatal.
386
387So the Linux page allocator has a mechanism which prevents allocations
388which *could* use highmem from using too much lowmem.  This means that
389a certain amount of lowmem is defended from the possibility of being
390captured into pinned user memory.
391
392(The same argument applies to the old 16 megabyte ISA DMA region.  This
393mechanism will also defend that region from allocations which could use
394highmem or lowmem).
395
396The `lowmem_reserve_ratio` tunable determines how aggressive the kernel is
397in defending these lower zones.
398
399If you have a machine which uses highmem or ISA DMA and your
400applications are using mlock(), or if you are running with no swap then
401you probably should change the lowmem_reserve_ratio setting.
402
403The lowmem_reserve_ratio is an array. You can see them by reading this file::
404
405	% cat /proc/sys/vm/lowmem_reserve_ratio
406	256     256     32
407
408But, these values are not used directly. The kernel calculates # of protection
409pages for each zones from them. These are shown as array of protection pages
410in /proc/zoneinfo like the following. (This is an example of x86-64 box).
411Each zone has an array of protection pages like this::
412
413  Node 0, zone      DMA
414    pages free     1355
415          min      3
416          low      3
417          high     4
418	:
419	:
420      numa_other   0
421          protection: (0, 2004, 2004, 2004)
422	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
423    pagesets
424      cpu: 0 pcp: 0
425          :
426
427These protections are added to score to judge whether this zone should be used
428for page allocation or should be reclaimed.
429
430In this example, if normal pages (index=2) are required to this DMA zone and
431watermark[WMARK_HIGH] is used for watermark, the kernel judges this zone should
432not be used because pages_free(1355) is smaller than watermark + protection[2]
433(4 + 2004 = 2008). If this protection value is 0, this zone would be used for
434normal page requirement. If requirement is DMA zone(index=0), protection[0]
435(=0) is used.
436
437zone[i]'s protection[j] is calculated by following expression::
438
439  (i < j):
440    zone[i]->protection[j]
441    = (total sums of managed_pages from zone[i+1] to zone[j] on the node)
442      / lowmem_reserve_ratio[i];
443  (i = j):
444     (should not be protected. = 0;
445  (i > j):
446     (not necessary, but looks 0)
447
448The default values of lowmem_reserve_ratio[i] are
449
450    === ====================================
451    256 (if zone[i] means DMA or DMA32 zone)
452    32  (others)
453    === ====================================
454
455As above expression, they are reciprocal number of ratio.
456256 means 1/256. # of protection pages becomes about "0.39%" of total managed
457pages of higher zones on the node.
458
459If you would like to protect more pages, smaller values are effective.
460The minimum value is 1 (1/1 -> 100%). The value less than 1 completely
461disables protection of the pages.
462
463
464max_map_count
465=============
466
467This file contains the maximum number of memory map areas a process
468may have. Memory map areas are used as a side-effect of calling
469malloc, directly by mmap, mprotect, and madvise, and also when loading
470shared libraries.
471
472While most applications need less than a thousand maps, certain
473programs, particularly malloc debuggers, may consume lots of them,
474e.g., up to one or two maps per allocation.
475
476The default value is 65530.
477
478
479mem_profiling
480==============
481
482Enable memory profiling (when CONFIG_MEM_ALLOC_PROFILING=y)
483
4841: Enable memory profiling.
485
4860: Disable memory profiling.
487
488Enabling memory profiling introduces a small performance overhead for all
489memory allocations.
490
491The default value depends on CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT.
492
493When CONFIG_MEM_ALLOC_PROFILING_DEBUG=y, this control is read-only to avoid
494warnings produced by allocations made while profiling is disabled and freed
495when it's enabled.
496
497
498memory_failure_early_kill
499=========================
500
501Control how to kill processes when uncorrected memory error (typically
502a 2bit error in a memory module) is detected in the background by hardware
503that cannot be handled by the kernel. In some cases (like the page
504still having a valid copy on disk) the kernel will handle the failure
505transparently without affecting any applications. But if there is
506no other up-to-date copy of the data it will kill to prevent any data
507corruptions from propagating.
508
5091: Kill all processes that have the corrupted and not reloadable page mapped
510as soon as the corruption is detected.  Note this is not supported
511for a few types of pages, like kernel internally allocated data or
512the swap cache, but works for the majority of user pages.
513
5140: Only unmap the corrupted page from all processes and only kill a process
515who tries to access it.
516
517The kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes can
518handle this if they want to.
519
520This is only active on architectures/platforms with advanced machine
521check handling and depends on the hardware capabilities.
522
523Applications can override this setting individually with the PR_MCE_KILL prctl
524
525
526memory_failure_recovery
527=======================
528
529Enable memory failure recovery (when supported by the platform)
530
5311: Attempt recovery.
532
5330: Always panic on a memory failure.
534
535
536min_free_kbytes
537===============
538
539This is used to force the Linux VM to keep a minimum number
540of kilobytes free.  The VM uses this number to compute a
541watermark[WMARK_MIN] value for each lowmem zone in the system.
542Each lowmem zone gets a number of reserved free pages based
543proportionally on its size.
544
545Some minimal amount of memory is needed to satisfy PF_MEMALLOC
546allocations; if you set this to lower than 1024KB, your system will
547become subtly broken, and prone to deadlock under high loads.
548
549Setting this too high will OOM your machine instantly.
550
551
552min_slab_ratio
553==============
554
555This is available only on NUMA kernels.
556
557A percentage of the total pages in each zone.  On Zone reclaim
558(fallback from the local zone occurs) slabs will be reclaimed if more
559than this percentage of pages in a zone are reclaimable slab pages.
560This insures that the slab growth stays under control even in NUMA
561systems that rarely perform global reclaim.
562
563The default is 5 percent.
564
565Note that slab reclaim is triggered in a per zone / node fashion.
566The process of reclaiming slab memory is currently not node specific
567and may not be fast.
568
569
570min_unmapped_ratio
571==================
572
573This is available only on NUMA kernels.
574
575This is a percentage of the total pages in each zone. Zone reclaim will
576only occur if more than this percentage of pages are in a state that
577zone_reclaim_mode allows to be reclaimed.
578
579If zone_reclaim_mode has the value 4 OR'd, then the percentage is compared
580against all file-backed unmapped pages including swapcache pages and tmpfs
581files. Otherwise, only unmapped pages backed by normal files but not tmpfs
582files and similar are considered.
583
584The default is 1 percent.
585
586
587mmap_min_addr
588=============
589
590This file indicates the amount of address space  which a user process will
591be restricted from mmapping.  Since kernel null dereference bugs could
592accidentally operate based on the information in the first couple of pages
593of memory userspace processes should not be allowed to write to them.  By
594default this value is set to 0 and no protections will be enforced by the
595security module.  Setting this value to something like 64k will allow the
596vast majority of applications to work correctly and provide defense in depth
597against future potential kernel bugs.
598
599
600mmap_rnd_bits
601=============
602
603This value can be used to select the number of bits to use to
604determine the random offset to the base address of vma regions
605resulting from mmap allocations on architectures which support
606tuning address space randomization.  This value will be bounded
607by the architecture's minimum and maximum supported values.
608
609This value can be changed after boot using the
610/proc/sys/vm/mmap_rnd_bits tunable
611
612
613mmap_rnd_compat_bits
614====================
615
616This value can be used to select the number of bits to use to
617determine the random offset to the base address of vma regions
618resulting from mmap allocations for applications run in
619compatibility mode on architectures which support tuning address
620space randomization.  This value will be bounded by the
621architecture's minimum and maximum supported values.
622
623This value can be changed after boot using the
624/proc/sys/vm/mmap_rnd_compat_bits tunable
625
626
627movable_gigantic_pages
628======================
629
630This parameter controls whether gigantic pages may be allocated from
631ZONE_MOVABLE. If set to non-zero, gigantic pages can be allocated
632from ZONE_MOVABLE. ZONE_MOVABLE memory may be created via the kernel
633boot parameter `kernelcore` or via memory hotplug as discussed in
634Documentation/admin-guide/mm/memory-hotplug.rst.
635
636Support may depend on specific architecture.
637
638Note that using ZONE_MOVABLE gigantic pages make memory hotremove unreliable.
639
640Memory hot-remove operations will block indefinitely until the admin reserves
641sufficient gigantic pages to service migration requests associated with the
642memory offlining process.  As HugeTLB gigantic page reservation is a manual
643process (via `nodeN/hugepages/.../nr_hugepages` interfaces) this may not be
644obvious when just attempting to offline a block of memory.
645
646Additionally, as multiple gigantic pages may be reserved on a single block,
647it may appear that gigantic pages are available for migration when in reality
648they are in the process of being removed. For example if `memoryN` contains
649two gigantic pages, one reserved and one allocated, and an admin attempts to
650offline that block, this operations may hang indefinitely unless another
651reserved gigantic page is available on another block `memoryM`.
652
653
654nr_hugepages
655============
656
657Change the minimum size of the hugepage pool.
658
659See Documentation/admin-guide/mm/hugetlbpage.rst
660
661
662hugetlb_optimize_vmemmap
663========================
664
665This knob is not available when the size of 'struct page' (a structure defined
666in include/linux/mm_types.h) is not power of two (an unusual system config could
667result in this).
668
669Enable (set to 1) or disable (set to 0) HugeTLB Vmemmap Optimization (HVO).
670
671Once enabled, the vmemmap pages of subsequent allocation of HugeTLB pages from
672buddy allocator will be optimized (7 pages per 2MB HugeTLB page and 4095 pages
673per 1GB HugeTLB page), whereas already allocated HugeTLB pages will not be
674optimized.  When those optimized HugeTLB pages are freed from the HugeTLB pool
675to the buddy allocator, the vmemmap pages representing that range needs to be
676remapped again and the vmemmap pages discarded earlier need to be rellocated
677again.  If your use case is that HugeTLB pages are allocated 'on the fly' (e.g.
678never explicitly allocating HugeTLB pages with 'nr_hugepages' but only set
679'nr_overcommit_hugepages', those overcommitted HugeTLB pages are allocated 'on
680the fly') instead of being pulled from the HugeTLB pool, you should weigh the
681benefits of memory savings against the more overhead (~2x slower than before)
682of allocation or freeing HugeTLB pages between the HugeTLB pool and the buddy
683allocator.  Another behavior to note is that if the system is under heavy memory
684pressure, it could prevent the user from freeing HugeTLB pages from the HugeTLB
685pool to the buddy allocator since the allocation of vmemmap pages could be
686failed, you have to retry later if your system encounter this situation.
687
688Once disabled, the vmemmap pages of subsequent allocation of HugeTLB pages from
689buddy allocator will not be optimized meaning the extra overhead at allocation
690time from buddy allocator disappears, whereas already optimized HugeTLB pages
691will not be affected.  If you want to make sure there are no optimized HugeTLB
692pages, you can set "nr_hugepages" to 0 first and then disable this.  Note that
693writing 0 to nr_hugepages will make any "in use" HugeTLB pages become surplus
694pages.  So, those surplus pages are still optimized until they are no longer
695in use.  You would need to wait for those surplus pages to be released before
696there are no optimized pages in the system.
697
698
699nr_hugepages_mempolicy
700======================
701
702Change the size of the hugepage pool at run-time on a specific
703set of NUMA nodes.
704
705See Documentation/admin-guide/mm/hugetlbpage.rst
706
707
708nr_overcommit_hugepages
709=======================
710
711Change the maximum size of the hugepage pool. The maximum is
712nr_hugepages + nr_overcommit_hugepages.
713
714See Documentation/admin-guide/mm/hugetlbpage.rst
715
716
717nr_trim_pages
718=============
719
720This is available only on NOMMU kernels.
721
722This value adjusts the excess page trimming behaviour of power-of-2 aligned
723NOMMU mmap allocations.
724
725A value of 0 disables trimming of allocations entirely, while a value of 1
726trims excess pages aggressively. Any value >= 1 acts as the watermark where
727trimming of allocations is initiated.
728
729The default value is 1.
730
731See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
732
733
734numa_zonelist_order
735===================
736
737This sysctl is only for NUMA and it is deprecated. Anything but
738Node order will fail!
739
740'where the memory is allocated from' is controlled by zonelists.
741
742(This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation.
743you may be able to read ZONE_DMA as ZONE_DMA32...)
744
745In non-NUMA case, a zonelist for GFP_KERNEL is ordered as following.
746ZONE_NORMAL -> ZONE_DMA
747This means that a memory allocation request for GFP_KERNEL will
748get memory from ZONE_DMA only when ZONE_NORMAL is not available.
749
750In NUMA case, you can think of following 2 types of order.
751Assume 2 node NUMA and below is zonelist of Node(0)'s GFP_KERNEL::
752
753  (A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL
754  (B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA.
755
756Type(A) offers the best locality for processes on Node(0), but ZONE_DMA
757will be used before ZONE_NORMAL exhaustion. This increases possibility of
758out-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small.
759
760Type(B) cannot offer the best locality but is more robust against OOM of
761the DMA zone.
762
763Type(A) is called as "Node" order. Type (B) is "Zone" order.
764
765"Node order" orders the zonelists by node, then by zone within each node.
766Specify "[Nn]ode" for node order
767
768"Zone Order" orders the zonelists by zone type, then by node within each
769zone.  Specify "[Zz]one" for zone order.
770
771Specify "[Dd]efault" to request automatic configuration.
772
773On 32-bit, the Normal zone needs to be preserved for allocations accessible
774by the kernel, so "zone" order will be selected.
775
776On 64-bit, devices that require DMA32/DMA are relatively rare, so "node"
777order will be selected.
778
779Default order is recommended unless this is causing problems for your
780system/application.
781
782
783oom_dump_tasks
784==============
785
786Enables a system-wide task dump (excluding kernel threads) to be produced
787when the kernel performs an OOM-killing and includes such information as
788pid, uid, tgid, vm size, rss, pgtables_bytes, swapents, oom_score_adj
789score, and name.  This is helpful to determine why the OOM killer was
790invoked, to identify the rogue task that caused it, and to determine why
791the OOM killer chose the task it did to kill.
792
793If this is set to zero, this information is suppressed.  On very
794large systems with thousands of tasks it may not be feasible to dump
795the memory state information for each one.  Such systems should not
796be forced to incur a performance penalty in OOM conditions when the
797information may not be desired.
798
799If this is set to non-zero, this information is shown whenever the
800OOM killer actually kills a memory-hogging task.
801
802The default value is 1 (enabled).
803
804
805oom_kill_allocating_task
806========================
807
808This enables or disables killing the OOM-triggering task in
809out-of-memory situations.
810
811If this is set to zero, the OOM killer will scan through the entire
812tasklist and select a task based on heuristics to kill.  This normally
813selects a rogue memory-hogging task that frees up a large amount of
814memory when killed.
815
816If this is set to non-zero, the OOM killer simply kills the task that
817triggered the out-of-memory condition.  This avoids the expensive
818tasklist scan.
819
820If panic_on_oom is selected, it takes precedence over whatever value
821is used in oom_kill_allocating_task.
822
823The default value is 0.
824
825
826overcommit_kbytes
827=================
828
829When overcommit_memory is set to 2, the committed address space is not
830permitted to exceed swap plus this amount of physical RAM. See below.
831
832Note: overcommit_kbytes is the counterpart of overcommit_ratio. Only one
833of them may be specified at a time. Setting one disables the other (which
834then appears as 0 when read).
835
836
837overcommit_memory
838=================
839
840This value contains a flag that enables memory overcommitment.
841
842When this flag is 0, the kernel compares the userspace memory request
843size against total memory plus swap and rejects obvious overcommits.
844
845When this flag is 1, the kernel pretends there is always enough
846memory until it actually runs out.
847
848When this flag is 2, the kernel uses a "never overcommit"
849policy that attempts to prevent any overcommit of memory.
850Note that user_reserve_kbytes affects this policy.
851
852This feature can be very useful because there are a lot of
853programs that malloc() huge amounts of memory "just-in-case"
854and don't use much of it.
855
856The default value is 0.
857
858See Documentation/mm/overcommit-accounting.rst and
859mm/util.c::__vm_enough_memory() for more information.
860
861
862overcommit_ratio
863================
864
865When overcommit_memory is set to 2, the committed address
866space is not permitted to exceed swap plus this percentage
867of physical RAM.  See above.
868
869
870page-cluster
871============
872
873page-cluster controls the number of pages up to which consecutive pages
874are read in from swap in a single attempt. This is the swap counterpart
875to page cache readahead.
876The mentioned consecutivity is not in terms of virtual/physical addresses,
877but consecutive on swap space - that means they were swapped out together.
878
879It is a logarithmic value - setting it to zero means "1 page", setting
880it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
881Zero disables swap readahead completely.
882
883The default value is three (eight pages at a time).  There may be some
884small benefits in tuning this to a different value if your workload is
885swap-intensive.
886
887Lower values mean lower latencies for initial faults, but at the same time
888extra faults and I/O delays for following faults if they would have been part of
889that consecutive pages readahead would have brought in.
890
891
892page_lock_unfairness
893====================
894
895This value determines the number of times that the page lock can be
896stolen from under a waiter. After the lock is stolen the number of times
897specified in this file (default is 5), the "fair lock handoff" semantics
898will apply, and the waiter will only be awakened if the lock can be taken.
899
900panic_on_oom
901============
902
903This enables or disables panic on out-of-memory feature.
904
905If this is set to 0, the kernel will kill some rogue process,
906called oom_killer.  Usually, oom_killer can kill rogue processes and
907system will survive.
908
909If this is set to 1, the kernel panics when out-of-memory happens.
910However, if a process limits using nodes by mempolicy/cpusets,
911and those nodes become memory exhaustion status, one process
912may be killed by oom-killer. No panic occurs in this case.
913Because other nodes' memory may be free. This means system total status
914may be not fatal yet.
915
916If this is set to 2, the kernel panics compulsorily even on the
917above-mentioned. Even oom happens under memory cgroup, the whole
918system panics.
919
920The default value is 0.
921
9221 and 2 are for failover of clustering. Please select either
923according to your policy of failover.
924
925panic_on_oom=2+kdump gives you very strong tool to investigate
926why oom happens. You can get snapshot.
927
928
929panic_on_unrecoverable_memory_failure
930======================================
931
932When a hardware memory error (e.g. multi-bit ECC) hits a kernel page
933that cannot be recovered by the memory failure handler, the default
934behaviour is to ignore the error and continue operation.  This is
935dangerous because the corrupted data remains accessible to the kernel,
936risking silent data corruption or a delayed crash when the poisoned
937memory is next accessed.
938
939When enabled, this sysctl triggers a panic on memory failure events
940hitting kernel-owned pages that the handler cannot recover:
941``PageReserved`` (firmware reservations, kernel image, vDSO, zero
942page, and similar memblock-reserved regions), ``PageSlab``,
943``PageTable``, and ``PageLargeKmalloc``.  These are owned by the
944kernel and the memory failure handler cannot reliably evict their
945contents.
946
947Other unrecoverable kernel-owned populations (vmalloc allocations,
948kernel stack pages, ...) are not currently covered because the
949handler has no page-type signal that distinguishes them from a
950userspace folio temporarily off the LRU during migration or
951compaction.  Such pages still go through the standard
952MF_MSG_GET_HWPOISON path: ``PG_hwpoison`` is set on them and a
953delayed crash on the next access remains possible.  Coverage may
954grow as the handler gains stronger kernel-ownership signals.
955
956Recoverable failure paths are also intentionally left out: in-flight
957buddy allocations and other transient races with the page allocator
958can reach the same diagnostic, and panicking on them would risk
959killing the box for a page destined for userspace where the standard
960SIGBUS recovery path applies.  Pages whose state could not be
961classified at all are not covered either, since an unknown state is
962not a sound basis for a panic decision.
963
964For many environments it is preferable to panic immediately with a clean
965crash dump that captures the original error context, rather than to
966continue and face a random crash later whose cause is difficult to
967diagnose.
968
969Use cases
970---------
971
972This option is most useful in environments where unattributed crashes
973are expensive to debug or where data integrity must take precedence
974over availability:
975
976* Large fleets, where multi-bit ECC errors on kernel pages are observed
977  regularly and post-mortem analysis of an unrelated downstream crash
978  (often seconds to minutes after the original error) consumes
979  significant engineering effort.
980
981* Systems configured with kdump, where panicking at the moment of the
982  hardware error produces a vmcore that still contains the faulting
983  address, the affected page state, and the originating MCE/GHES
984  record — context that is typically lost by the time a delayed crash
985  occurs.
986
987* High-availability clusters that rely on fast, deterministic node
988  failure for failover, and prefer an immediate panic over silent data
989  corruption propagating to replicas or persistent storage.
990
991* Kernel and platform developers reproducing hwpoison issues with
992  tools such as ``mce-inject`` or error-injection debugfs interfaces,
993  where panicking on the unrecoverable path makes regressions
994  immediately visible instead of surfacing as later, unrelated
995  failures.
996
997= =====================================================================
9980 Try to continue operation (default).
9991 Panic immediately.  If the ``panic`` sysctl is also non-zero then the
1000  machine will be rebooted.
1001= =====================================================================
1002
1003Example::
1004
1005     echo 1 > /proc/sys/vm/panic_on_unrecoverable_memory_failure
1006
1007
1008percpu_pagelist_high_fraction
1009=============================
1010
1011This is the fraction of pages in each zone that are can be stored to
1012per-cpu page lists. It is an upper boundary that is divided depending
1013on the number of online CPUs. The min value for this is 8 which means
1014that we do not allow more than 1/8th of pages in each zone to be stored
1015on per-cpu page lists. This entry only changes the value of hot per-cpu
1016page lists. A user can specify a number like 100 to allocate 1/100th of
1017each zone between per-cpu lists.
1018
1019The batch value of each per-cpu page list remains the same regardless of
1020the value of the high fraction so allocation latencies are unaffected.
1021
1022The initial value is zero. Kernel uses this value to set the high pcp->high
1023mark based on the low watermark for the zone and the number of local
1024online CPUs.  If the user writes '0' to this sysctl, it will revert to
1025this default behavior.
1026
1027
1028stat_interval
1029=============
1030
1031The time interval between which vm statistics are updated.  The default
1032is 1 second.
1033
1034
1035stat_refresh
1036============
1037
1038Any read or write (by root only) flushes all the per-cpu vm statistics
1039into their global totals, for more accurate reports when testing
1040e.g. cat /proc/sys/vm/stat_refresh /proc/meminfo
1041
1042As a side-effect, it also checks for negative totals (elsewhere reported
1043as 0) and "fails" with EINVAL if any are found, with a warning in dmesg.
1044(At time of writing, a few stats are known sometimes to be found negative,
1045with no ill effects: errors and warnings on these stats are suppressed.)
1046
1047
1048numa_stat
1049=========
1050
1051This interface allows runtime configuration of numa statistics.
1052
1053When page allocation performance becomes a bottleneck and you can tolerate
1054some possible tool breakage and decreased numa counter precision, you can
1055do::
1056
1057	echo 0 > /proc/sys/vm/numa_stat
1058
1059When page allocation performance is not a bottleneck and you want all
1060tooling to work, you can do::
1061
1062	echo 1 > /proc/sys/vm/numa_stat
1063
1064
1065swappiness
1066==========
1067
1068This control is used to define the rough relative IO cost of swapping
1069and filesystem paging, as a value between 0 and 200. At 100, the VM
1070assumes equal IO cost and will thus apply memory pressure to the page
1071cache and swap-backed pages equally; lower values signify more
1072expensive swap IO, higher values indicates cheaper.
1073
1074Keep in mind that filesystem IO patterns under memory pressure tend to
1075be more efficient than swap's random IO. An optimal value will require
1076experimentation and will also be workload-dependent.
1077
1078The default value is 60.
1079
1080For in-memory swap, like zram or zswap, as well as hybrid setups that
1081have swap on faster devices than the filesystem, values beyond 100 can
1082be considered. For example, if the random IO against the swap device
1083is on average 2x faster than IO from the filesystem, swappiness should
1084be 133 (x + 2x = 200, 2x = 133.33).
1085
1086At 0, the kernel will not initiate swap until the amount of free and
1087file-backed pages is less than the high watermark in a zone.
1088
1089
1090unprivileged_userfaultfd
1091========================
1092
1093This flag controls the mode in which unprivileged users can use the
1094userfaultfd system calls. Set this to 0 to restrict unprivileged users
1095to handle page faults in user mode only. In this case, users without
1096SYS_CAP_PTRACE must pass UFFD_USER_MODE_ONLY in order for userfaultfd to
1097succeed. Prohibiting use of userfaultfd for handling faults from kernel
1098mode may make certain vulnerabilities more difficult to exploit.
1099
1100Set this to 1 to allow unprivileged users to use the userfaultfd system
1101calls without any restrictions.
1102
1103The default value is 0.
1104
1105Another way to control permissions for userfaultfd is to use
1106/dev/userfaultfd instead of userfaultfd(2). See
1107Documentation/admin-guide/mm/userfaultfd.rst.
1108
1109user_reserve_kbytes
1110===================
1111
1112When overcommit_memory is set to 2, "never overcommit" mode, reserve
1113min(3% of current process size, user_reserve_kbytes) of free memory.
1114This is intended to prevent a user from starting a single memory hogging
1115process, such that they cannot recover (kill the hog).
1116
1117This setting has no effect when overcommit_memory is set to 0 or 1.
1118
1119user_reserve_kbytes defaults to min(3% of the current process size, 128MB).
1120
1121If this is reduced to zero, then the user will be allowed to allocate
1122all free memory with a single process, minus admin_reserve_kbytes.
1123Any subsequent attempts to execute a command will result in
1124"fork: Cannot allocate memory".
1125
1126Changing this takes effect whenever an application requests memory.
1127
1128
1129vfs_cache_pressure
1130==================
1131
1132This percentage value controls the tendency of the kernel to reclaim
1133the memory which is used for caching of directory and inode objects.
1134
1135At the default value of vfs_cache_pressure=vfs_cache_pressure_denom the kernel
1136will attempt to reclaim dentries and inodes at a "fair" rate with respect to
1137pagecache and swapcache reclaim.  Decreasing vfs_cache_pressure causes the
1138kernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0,
1139the kernel will never reclaim dentries and inodes due to memory pressure and
1140this can easily lead to out-of-memory conditions. Increasing vfs_cache_pressure
1141beyond vfs_cache_pressure_denom causes the kernel to prefer to reclaim dentries
1142and inodes.
1143
1144Increasing vfs_cache_pressure significantly beyond vfs_cache_pressure_denom may
1145have negative performance impact. Reclaim code needs to take various locks to
1146find freeable directory and inode objects. When vfs_cache_pressure equals
1147(10 * vfs_cache_pressure_denom), it will look for ten times more freeable
1148objects than there are.
1149
1150Note: This setting should always be used together with vfs_cache_pressure_denom.
1151
1152vfs_cache_pressure_denom
1153========================
1154
1155Defaults to 100 (minimum allowed value). Requires corresponding
1156vfs_cache_pressure setting to take effect.
1157
1158watermark_boost_factor
1159======================
1160
1161This factor controls the level of reclaim when memory is being fragmented.
1162It defines the percentage of the high watermark of a zone that will be
1163reclaimed if pages of different mobility are being mixed within pageblocks.
1164The intent is that compaction has less work to do in the future and to
1165increase the success rate of future high-order allocations such as SLUB
1166allocations, THP and hugetlbfs pages.
1167
1168To make it sensible with respect to the watermark_scale_factor
1169parameter, the unit is in fractions of 10,000. The default value of
117015,000 means that up to 150% of the high watermark will be reclaimed in the
1171event of a pageblock being mixed due to fragmentation. The level of reclaim
1172is determined by the number of fragmentation events that occurred in the
1173recent past. If this value is smaller than a pageblock then a pageblocks
1174worth of pages will be reclaimed (e.g.  2MB on 64-bit x86). A boost factor
1175of 0 will disable the feature.
1176
1177
1178watermark_scale_factor
1179======================
1180
1181This factor controls the aggressiveness of kswapd. It defines the
1182amount of memory left in a node/system before kswapd is woken up and
1183how much memory needs to be free before kswapd goes back to sleep.
1184
1185The unit is in fractions of 10,000. The default value of 10 means the
1186distances between watermarks are 0.1% of the available memory in the
1187node/system. The maximum value is 3000, or 30% of memory.
1188
1189A high rate of threads entering direct reclaim (allocstall) or kswapd
1190going to sleep prematurely (kswapd_low_wmark_hit_quickly) can indicate
1191that the number of free pages kswapd maintains for latency reasons is
1192too small for the allocation bursts occurring in the system. This knob
1193can then be used to tune kswapd aggressiveness accordingly.
1194
1195
1196zone_reclaim_mode
1197=================
1198
1199Zone_reclaim_mode allows someone to set more or less aggressive approaches to
1200reclaim memory when a zone runs out of memory. If it is set to zero then no
1201zone reclaim occurs. Allocations will be satisfied from other zones / nodes
1202in the system.
1203
1204This is value OR'ed together of
1205
1206=	===================================
12071	Zone reclaim on
12082	Zone reclaim writes dirty pages out
12094	Zone reclaim swaps pages
1210=	===================================
1211
1212zone_reclaim_mode is disabled by default.  For file servers or workloads
1213that benefit from having their data cached, zone_reclaim_mode should be
1214left disabled as the caching effect is likely to be more important than
1215data locality.
1216
1217Consider enabling one or more zone_reclaim mode bits if it's known that the
1218workload is partitioned such that each partition fits within a NUMA node
1219and that accessing remote memory would cause a measurable performance
1220reduction.  The page allocator will take additional actions before
1221allocating off node pages.
1222
1223Allowing zone reclaim to write out pages stops processes that are
1224writing large amounts of data from dirtying pages on other nodes. Zone
1225reclaim will write out dirty pages if a zone fills up and so effectively
1226throttle the process. This may decrease the performance of a single process
1227since it cannot use all of system memory to buffer the outgoing writes
1228anymore but it preserve the memory on other nodes so that the performance
1229of other processes running on other nodes will not be affected.
1230
1231Allowing regular swap effectively restricts allocations to the local
1232node unless explicitly overridden by memory policies or cpuset
1233configurations.
1234