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