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