Documentation for /proc/sys/vm/¶
kernel version 2.6.29
Copyright (c) 1998, 1999, Rik van Riel <riel@nl.linux.org>
Copyright (c) 2008 Peter W. Morreale <pmorreale@novell.com>
For general info and legal blurb, please look inDocumentation for /proc/sys.
This file contains the documentation for the sysctl files in/proc/sys/vm and is valid for Linux kernel version 2.6.29.
The files in this directory can be used to tune the operationof the virtual memory (VM) subsystem of the Linux kernel andthe writeout of dirty data to disk.
Default values and initialization routines for most of thesefiles can be found in mm/swap.c.
Currently, these files are in /proc/sys/vm:
admin_reserve_kbytes
compact_memory
compaction_proactiveness
compact_unevictable_allowed
defrag_mode
dirty_background_bytes
dirty_background_ratio
dirty_bytes
dirty_expire_centisecs
dirty_ratio
dirtytime_expire_seconds
dirty_writeback_centisecs
drop_caches
enable_soft_offline
extfrag_threshold
highmem_is_dirtyable
hugetlb_shm_group
laptop_mode
legacy_va_layout
lowmem_reserve_ratio
max_map_count
mem_profiling (only if CONFIG_MEM_ALLOC_PROFILING=y)
memory_failure_early_kill
memory_failure_recovery
min_free_kbytes
min_slab_ratio
min_unmapped_ratio
mmap_min_addr
mmap_rnd_bits
mmap_rnd_compat_bits
nr_hugepages
nr_hugepages_mempolicy
nr_overcommit_hugepages
nr_trim_pages (only if CONFIG_MMU=n)
numa_zonelist_order
oom_dump_tasks
oom_kill_allocating_task
overcommit_kbytes
overcommit_memory
overcommit_ratio
page-cluster
page_lock_unfairness
panic_on_oom
percpu_pagelist_high_fraction
stat_interval
stat_refresh
numa_stat
swappiness
unprivileged_userfaultfd
user_reserve_kbytes
vfs_cache_pressure
vfs_cache_pressure_denom
watermark_boost_factor
watermark_scale_factor
zone_reclaim_mode
admin_reserve_kbytes¶
The amount of free memory in the system that should be reserved for userswith the capability cap_sys_admin.
admin_reserve_kbytes defaults to min(3% of free pages, 8MB)
That should provide enough for the admin to log in and kill a process,if necessary, under the default overcommit ‘guess’ mode.
Systems running under overcommit ‘never’ should increase this to accountfor the full Virtual Memory Size of programs used to recover. Otherwise,root may not be able to log in to recover the system.
How do you calculate a minimum useful reserve?
sshd or login + bash (or some other shell) + top (or ps, kill, etc.)
For overcommit ‘guess’, we can sum resident set sizes (RSS).On x86_64 this is about 8MB.
For overcommit ‘never’, we can take the max of their virtual sizes (VSZ)and add the sum of their RSS.On x86_64 this is about 128MB.
Changing this takes effect whenever an application requests memory.
compact_memory¶
Available only when CONFIG_COMPACTION is set. When 1 is written to the file,all zones are compacted such that free memory is available in contiguousblocks where possible. This can be important for example in the allocation ofhuge pages although processes will also directly compact memory as required.
compaction_proactiveness¶
This tunable takes a value in the range [0, 100] with a default value of20. This tunable determines how aggressively compaction is done in thebackground. Write of a non zero value to this tunable will immediatelytrigger the proactive compaction. Setting it to 0 disables proactive compaction.
Note that compaction has a non-trivial system-wide impact as pagesbelonging to different processes are moved around, which could also leadto latency spikes in unsuspecting applications. The kernel employsvarious heuristics to avoid wasting CPU cycles if it detects thatproactive compaction is not being effective.
Setting the value above 80 will, in addition to lowering the acceptable levelof fragmentation, make the compaction code more sensitive to increases infragmentation, i.e. compaction will trigger more often, but reducefragmentation by a smaller amount.This makes the fragmentation level more stable over time.
Be careful when setting it to extreme values like 100, as that maycause excessive background compaction activity.
compact_unevictable_allowed¶
Available only when CONFIG_COMPACTION is set. When set to 1, compaction isallowed to examine the unevictable lru (mlocked pages) for pages to compact.This should be used on systems where stalls for minor page faults are anacceptable trade for large contiguous free memory. Set to 0 to preventcompaction from moving pages that are unevictable. Default value is 1.On CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page fault, dueto compaction, which would block the task from becoming active until the faultis resolved.
defrag_mode¶
When set to 1, the page allocator tries harder to avoid fragmentationand maintain the ability to produce huge pages / higher-order pages.
It is recommended to enable this right after boot, as fragmentation,once it occurred, can be long-lasting or even permanent.
dirty_background_bytes¶
Contains the amount of dirty memory at which the background kernelflusher threads will start writeback.
- Note:
dirty_background_bytes is the counterpart of dirty_background_ratio. Onlyone of them may be specified at a time. When one sysctl is written it isimmediately taken into account to evaluate the dirty memory limits and theother appears as 0 when read.
dirty_background_ratio¶
Contains, as a percentage of total available memory that contains free pagesand reclaimable pages, the number of pages at which the background kernelflusher threads will start writing out dirty data.
The total available memory is not equal to total system memory.
dirty_bytes¶
Contains the amount of dirty memory at which a process generating disk writeswill itself start writeback.
Note: dirty_bytes is the counterpart of dirty_ratio. Only one of them may bespecified at a time. When one sysctl is written it is immediately taken intoaccount to evaluate the dirty memory limits and the other appears as 0 whenread.
Note: the minimum value allowed for dirty_bytes is two pages (in bytes); anyvalue lower than this limit will be ignored and the old configuration will beretained.
dirty_expire_centisecs¶
This tunable is used to define when dirty data is old enough to be eligiblefor writeout by the kernel flusher threads. It is expressed in 100’thsof a second. Data which has been dirty in-memory for longer than thisinterval will be written out next time a flusher thread wakes up.
dirty_ratio¶
Contains, as a percentage of total available memory that contains free pagesand reclaimable pages, the number of pages at which a process which isgenerating disk writes will itself start writing out dirty data.
The total available memory is not equal to total system memory.
dirtytime_expire_seconds¶
When a lazytime inode is constantly having its pages dirtied, the inode withan updated timestamp will never get chance to be written out. And, if theonly thing that has happened on the file system is a dirtytime inode causedby an atime update, a worker will be scheduled to make sure that inodeeventually gets pushed out to disk. This tunable is used to define when dirtyinode is old enough to be eligible for writeback by the kernel flusher threads.And, it is also used as the interval to wakeup dirtytime_writeback thread.
dirty_writeback_centisecs¶
The kernel flusher threads will periodically wake up and writeold dataout to disk. This tunable expresses the interval between those wakeups, in100’ths of a second.
Setting this to zero disables periodic writeback altogether.
drop_caches¶
Writing to this will cause the kernel to drop clean caches, as well asreclaimable slab objects like dentries and inodes. Once dropped, theirmemory becomes free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
echo 3 > /proc/sys/vm/drop_caches
This is a non-destructive operation and will not free any dirty objects.To increase the number of objects freed by this operation, the user may runsync prior to writing to /proc/sys/vm/drop_caches. This will minimize thenumber of dirty objects on the system and create more candidates to bedropped.
This file is not a means to control the growth of the various kernel caches(inodes, dentries, pagecache, etc...) These objects are automaticallyreclaimed by the kernel when memory is needed elsewhere on the system.
Use of this file can cause performance problems. Since it discards cachedobjects, it may cost a significant amount of I/O and CPU to recreate thedropped objects, especially if they were under heavy use. Because of this,use outside of a testing or debugging environment is not recommended.
You may see informational messages in your kernel log when this file isused:
cat (1234): drop_caches: 3
These are informational only. They do not mean that anything is wrongwith your system. To disable them, echo 4 (bit 2) into drop_caches.
enable_soft_offline¶
Correctable memory errors are very common on servers. Soft-offline is kernel’ssolution for memory pages having (excessive) corrected memory errors.
For different types of page, soft-offline has different behaviors / costs.
For a raw error page, soft-offline migrates the in-use page’s content toa new raw page.
For a page that is part of a transparent hugepage, soft-offline splits thetransparent hugepage into raw pages, then migrates only the raw error page.As a result, user is transparently backed by 1 less hugepage, impactingmemory access performance.
For a page that is part of a HugeTLB hugepage, soft-offline first migratesthe entire HugeTLB hugepage, during which a free hugepage will be consumedas migration target. Then the original hugepage is dissolved into rawpages without compensation, reducing the capacity of the HugeTLB pool by 1.
It is user’s call to choose between reliability (staying away from fragilephysical memory) vs performance / capacity implications in transparent andHugeTLB cases.
For all architectures, enable_soft_offline controls whether to soft offlinememory pages. When set to 1, kernel attempts to soft offline the pageswhenever it thinks needed. When set to 0, kernel returns EOPNOTSUPP tothe request to soft offline the pages. Its default value is 1.
It is worth mentioning that after setting enable_soft_offline to 0, thefollowing requests to soft offline pages will not be performed:
Request to soft offline pages from RAS Correctable Errors Collector.
On ARM, the request to soft offline pages from GHES driver.
On PARISC, the request to soft offline pages from Page Deallocation Table.
extfrag_threshold¶
This parameter affects whether the kernel will compact memory or directreclaim to satisfy a high-order allocation. The extfrag/extfrag_index file indebugfs shows what the fragmentation index for each order is in each zone inthe system. Values tending towards 0 imply allocations would fail due to lackof memory, values towards 1000 imply failures are due to fragmentation and -1implies that the allocation will succeed as long as watermarks are met.
The kernel will not compact memory in a zone if thefragmentation index is <= extfrag_threshold. The default value is 500.
highmem_is_dirtyable¶
Available only for systems with CONFIG_HIGHMEM enabled (32b systems).
This parameter controls whether the high memory is considered for dirtywriters throttling. This is not the case by default which means thatonly the amount of memory directly visible/usable by the kernel canbe dirtied. As a result, on systems with a large amount of memory andlowmem basically depleted writers might be throttled too early andstreaming writes can get very slow.
Changing the value to non zero would allow more memory to be dirtiedand thus allow writers to write more data which can be flushed to thestorage more effectively. Note this also comes with a risk of pre-matureOOM killer because some writers (e.g. direct block device writes) canonly use the low memory and they can fill it up with dirty data withoutany throttling.
hugetlb_shm_group¶
hugetlb_shm_group contains group id that is allowed to create SysVshared memory segment using hugetlb page.
laptop_mode¶
laptop_mode is a knob that controls “laptop mode”. All the things that arecontrolled by this knob are discussed inHow to conserve battery power using laptop-mode.
legacy_va_layout¶
If non-zero, this sysctl disables the new 32-bit mmap layout - the kernelwill use the legacy (2.4) layout for all processes.
lowmem_reserve_ratio¶
For some specialised workloads on highmem machines it is dangerous forthe kernel to allow process memory to be allocated from the “lowmem”zone. This is because that memory could then be pinned via themlock()system call, or by unavailability of swapspace.
And on large highmem machines this lack of reclaimable lowmem memorycan be fatal.
So the Linux page allocator has a mechanism which prevents allocationswhichcould use highmem from using too much lowmem. This means thata certain amount of lowmem is defended from the possibility of beingcaptured into pinned user memory.
(The same argument applies to the old 16 megabyte ISA DMA region. Thismechanism will also defend that region from allocations which could usehighmem or lowmem).
Thelowmem_reserve_ratio tunable determines how aggressive the kernel isin defending these lower zones.
If you have a machine which uses highmem or ISA DMA and yourapplications are usingmlock(), or if you are running with no swap thenyou probably should change the lowmem_reserve_ratio setting.
The lowmem_reserve_ratio is an array. You can see them by reading this file:
% cat /proc/sys/vm/lowmem_reserve_ratio256 256 32
But, these values are not used directly. The kernel calculates # of protectionpages for each zones from them. These are shown as array of protection pagesin /proc/zoneinfo like the following. (This is an example of x86-64 box).Each zone has an array of protection pages like this:
Node 0, zone DMA pages free 1355 min 3 low 3 high 4 : : numa_other 0 protection: (0, 2004, 2004, 2004) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pagesets cpu: 0 pcp: 0 :
These protections are added to score to judge whether this zone should be usedfor page allocation or should be reclaimed.
In this example, if normal pages (index=2) are required to this DMA zone andwatermark[WMARK_HIGH] is used for watermark, the kernel judges this zone shouldnot be used because pages_free(1355) is smaller than watermark + protection[2](4 + 2004 = 2008). If this protection value is 0, this zone would be used fornormal page requirement. If requirement is DMA zone(index=0), protection[0](=0) is used.
zone[i]’s protection[j] is calculated by following expression:
(i < j): zone[i]->protection[j] = (total sums of managed_pages from zone[i+1] to zone[j] on the node) / lowmem_reserve_ratio[i];(i = j): (should not be protected. = 0;(i > j): (not necessary, but looks 0)
The default values of lowmem_reserve_ratio[i] are
256
(if zone[i] means DMA or DMA32 zone)
32
(others)
As above expression, they are reciprocal number of ratio.256 means 1/256. # of protection pages becomes about “0.39%” of total managedpages of higher zones on the node.
If you would like to protect more pages, smaller values are effective.The minimum value is 1 (1/1 -> 100%). The value less than 1 completelydisables protection of the pages.
max_map_count¶
This file contains the maximum number of memory map areas a processmay have. Memory map areas are used as a side-effect of callingmalloc, directly by mmap, mprotect, and madvise, and also when loadingshared libraries.
While most applications need less than a thousand maps, certainprograms, particularly malloc debuggers, may consume lots of them,e.g., up to one or two maps per allocation.
The default value is 65530.
mem_profiling¶
Enable memory profiling (when CONFIG_MEM_ALLOC_PROFILING=y)
1: Enable memory profiling.
0: Disable memory profiling.
Enabling memory profiling introduces a small performance overhead for allmemory allocations.
The default value depends on CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT.
memory_failure_early_kill¶
Control how to kill processes when uncorrected memory error (typicallya 2bit error in a memory module) is detected in the background by hardwarethat cannot be handled by the kernel. In some cases (like the pagestill having a valid copy on disk) the kernel will handle the failuretransparently without affecting any applications. But if there isno other up-to-date copy of the data it will kill to prevent any datacorruptions from propagating.
1: Kill all processes that have the corrupted and not reloadable page mappedas soon as the corruption is detected. Note this is not supportedfor a few types of pages, like kernel internally allocated data orthe swap cache, but works for the majority of user pages.
0: Only unmap the corrupted page from all processes and only kill a processwho tries to access it.
The kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes canhandle this if they want to.
This is only active on architectures/platforms with advanced machinecheck handling and depends on the hardware capabilities.
Applications can override this setting individually with the PR_MCE_KILL prctl
memory_failure_recovery¶
Enable memory failure recovery (when supported by the platform)
1: Attempt recovery.
0: Always panic on a memory failure.
min_free_kbytes¶
This is used to force the Linux VM to keep a minimum numberof kilobytes free. The VM uses this number to compute awatermark[WMARK_MIN] value for each lowmem zone in the system.Each lowmem zone gets a number of reserved free pages basedproportionally on its size.
Some minimal amount of memory is needed to satisfy PF_MEMALLOCallocations; if you set this to lower than 1024KB, your system willbecome subtly broken, and prone to deadlock under high loads.
Setting this too high will OOM your machine instantly.
min_slab_ratio¶
This is available only on NUMA kernels.
A percentage of the total pages in each zone. On Zone reclaim(fallback from the local zone occurs) slabs will be reclaimed if morethan this percentage of pages in a zone are reclaimable slab pages.This insures that the slab growth stays under control even in NUMAsystems that rarely perform global reclaim.
The default is 5 percent.
Note that slab reclaim is triggered in a per zone / node fashion.The process of reclaiming slab memory is currently not node specificand may not be fast.
min_unmapped_ratio¶
This is available only on NUMA kernels.
This is a percentage of the total pages in each zone. Zone reclaim willonly occur if more than this percentage of pages are in a state thatzone_reclaim_mode allows to be reclaimed.
If zone_reclaim_mode has the value 4 OR’d, then the percentage is comparedagainst all file-backed unmapped pages including swapcache pages and tmpfsfiles. Otherwise, only unmapped pages backed by normal files but not tmpfsfiles and similar are considered.
The default is 1 percent.
mmap_min_addr¶
This file indicates the amount of address space which a user process willbe restricted from mmapping. Since kernel null dereference bugs couldaccidentally operate based on the information in the first couple of pagesof memory userspace processes should not be allowed to write to them. Bydefault this value is set to 0 and no protections will be enforced by thesecurity module. Setting this value to something like 64k will allow thevast majority of applications to work correctly and provide defense in depthagainst future potential kernel bugs.
mmap_rnd_bits¶
This value can be used to select the number of bits to use todetermine the random offset to the base address of vma regionsresulting from mmap allocations on architectures which supporttuning address space randomization. This value will be boundedby the architecture’s minimum and maximum supported values.
This value can be changed after boot using the/proc/sys/vm/mmap_rnd_bits tunable
mmap_rnd_compat_bits¶
This value can be used to select the number of bits to use todetermine the random offset to the base address of vma regionsresulting from mmap allocations for applications run incompatibility mode on architectures which support tuning addressspace randomization. This value will be bounded by thearchitecture’s minimum and maximum supported values.
This value can be changed after boot using the/proc/sys/vm/mmap_rnd_compat_bits tunable
nr_hugepages¶
Change the minimum size of the hugepage pool.
hugetlb_optimize_vmemmap¶
This knob is not available when the size of ‘structpage’ (a structure definedin include/linux/mm_types.h) is not power of two (an unusual system config couldresult in this).
Enable (set to 1) or disable (set to 0) HugeTLB Vmemmap Optimization (HVO).
Once enabled, the vmemmap pages of subsequent allocation of HugeTLB pages frombuddy allocator will be optimized (7 pages per 2MB HugeTLB page and 4095 pagesper 1GB HugeTLB page), whereas already allocated HugeTLB pages will not beoptimized. When those optimized HugeTLB pages are freed from the HugeTLB poolto the buddy allocator, the vmemmap pages representing that range needs to beremapped again and the vmemmap pages discarded earlier need to be rellocatedagain. If your use case is that HugeTLB pages are allocated ‘on the fly’ (e.g.never explicitly allocating HugeTLB pages with ‘nr_hugepages’ but only set‘nr_overcommit_hugepages’, those overcommitted HugeTLB pages are allocated ‘onthe fly’) instead of being pulled from the HugeTLB pool, you should weigh thebenefits of memory savings against the more overhead (~2x slower than before)of allocation or freeing HugeTLB pages between the HugeTLB pool and the buddyallocator. Another behavior to note is that if the system is under heavy memorypressure, it could prevent the user from freeing HugeTLB pages from the HugeTLBpool to the buddy allocator since the allocation of vmemmap pages could befailed, you have to retry later if your system encounter this situation.
Once disabled, the vmemmap pages of subsequent allocation of HugeTLB pages frombuddy allocator will not be optimized meaning the extra overhead at allocationtime from buddy allocator disappears, whereas already optimized HugeTLB pageswill not be affected. If you want to make sure there are no optimized HugeTLBpages, you can set “nr_hugepages” to 0 first and then disable this. Note thatwriting 0 to nr_hugepages will make any “in use” HugeTLB pages become surpluspages. So, those surplus pages are still optimized until they are no longerin use. You would need to wait for those surplus pages to be released beforethere are no optimized pages in the system.
nr_hugepages_mempolicy¶
Change the size of the hugepage pool at run-time on a specificset of NUMA nodes.
nr_overcommit_hugepages¶
Change the maximum size of the hugepage pool. The maximum isnr_hugepages + nr_overcommit_hugepages.
nr_trim_pages¶
This is available only on NOMMU kernels.
This value adjusts the excess page trimming behaviour of power-of-2 alignedNOMMU mmap allocations.
A value of 0 disables trimming of allocations entirely, while a value of 1trims excess pages aggressively. Any value >= 1 acts as the watermark wheretrimming of allocations is initiated.
The default value is 1.
SeeNo-MMU memory mapping support for more information.
numa_zonelist_order¶
This sysctl is only for NUMA and it is deprecated. Anything butNode order will fail!
‘where the memory is allocated from’ is controlled by zonelists.
(This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation.you may be able to read ZONE_DMA as ZONE_DMA32...)
In non-NUMA case, a zonelist for GFP_KERNEL is ordered as following.ZONE_NORMAL -> ZONE_DMAThis means that a memory allocation request for GFP_KERNEL willget memory from ZONE_DMA only when ZONE_NORMAL is not available.
In NUMA case, you can think of following 2 types of order.Assume 2 node NUMA and below is zonelist of Node(0)’s GFP_KERNEL:
(A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL(B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA.
Type(A) offers the best locality for processes on Node(0), but ZONE_DMAwill be used before ZONE_NORMAL exhaustion. This increases possibility ofout-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small.
Type(B) cannot offer the best locality but is more robust against OOM ofthe DMA zone.
Type(A) is called as “Node” order. Type (B) is “Zone” order.
“Node order” orders the zonelists by node, then by zone within each node.Specify “[Nn]ode” for node order
“Zone Order” orders the zonelists by zone type, then by node within eachzone. Specify “[Zz]one” for zone order.
Specify “[Dd]efault” to request automatic configuration.
On 32-bit, the Normal zone needs to be preserved for allocations accessibleby the kernel, so “zone” order will be selected.
On 64-bit, devices that require DMA32/DMA are relatively rare, so “node”order will be selected.
Default order is recommended unless this is causing problems for yoursystem/application.
oom_dump_tasks¶
Enables a system-wide task dump (excluding kernel threads) to be producedwhen the kernel performs an OOM-killing and includes such information aspid, uid, tgid, vm size, rss, pgtables_bytes, swapents, oom_score_adjscore, and name. This is helpful to determine why the OOM killer wasinvoked, to identify the rogue task that caused it, and to determine whythe OOM killer chose the task it did to kill.
If this is set to zero, this information is suppressed. On verylarge systems with thousands of tasks it may not be feasible to dumpthe memory state information for each one. Such systems should notbe forced to incur a performance penalty in OOM conditions when theinformation may not be desired.
If this is set to non-zero, this information is shown whenever theOOM killer actually kills a memory-hogging task.
The default value is 1 (enabled).
oom_kill_allocating_task¶
This enables or disables killing the OOM-triggering task inout-of-memory situations.
If this is set to zero, the OOM killer will scan through the entiretasklist and select a task based on heuristics to kill. This normallyselects a rogue memory-hogging task that frees up a large amount ofmemory when killed.
If this is set to non-zero, the OOM killer simply kills the task thattriggered the out-of-memory condition. This avoids the expensivetasklist scan.
If panic_on_oom is selected, it takes precedence over whatever valueis used in oom_kill_allocating_task.
The default value is 0.
overcommit_kbytes¶
When overcommit_memory is set to 2, the committed address space is notpermitted to exceed swap plus this amount of physical RAM. See below.
Note: overcommit_kbytes is the counterpart of overcommit_ratio. Only oneof them may be specified at a time. Setting one disables the other (whichthen appears as 0 when read).
overcommit_memory¶
This value contains a flag that enables memory overcommitment.
When this flag is 0, the kernel compares the userspace memory requestsize against total memory plus swap and rejects obvious overcommits.
When this flag is 1, the kernel pretends there is always enoughmemory until it actually runs out.
When this flag is 2, the kernel uses a “never overcommit”policy that attempts to prevent any overcommit of memory.Note that user_reserve_kbytes affects this policy.
This feature can be very useful because there are a lot ofprograms thatmalloc() huge amounts of memory “just-in-case”and don’t use much of it.
The default value is 0.
SeeOvercommit Accounting andmm/util.c::__vm_enough_memory() for more information.
overcommit_ratio¶
When overcommit_memory is set to 2, the committed addressspace is not permitted to exceed swap plus this percentageof physical RAM. See above.
page-cluster¶
page-cluster controls the number of pages up to which consecutive pagesare read in from swap in a single attempt. This is the swap counterpartto page cache readahead.The mentioned consecutivity is not in terms of virtual/physical addresses,but consecutive on swap space - that means they were swapped out together.
It is a logarithmic value - setting it to zero means “1 page”, settingit to 1 means “2 pages”, setting it to 2 means “4 pages”, etc.Zero disables swap readahead completely.
The default value is three (eight pages at a time). There may be somesmall benefits in tuning this to a different value if your workload isswap-intensive.
Lower values mean lower latencies for initial faults, but at the same timeextra faults and I/O delays for following faults if they would have been part ofthat consecutive pages readahead would have brought in.
page_lock_unfairness¶
This value determines the number of times that the page lock can bestolen from under a waiter. After the lock is stolen the number of timesspecified in this file (default is 5), the “fair lock handoff” semanticswill apply, and the waiter will only be awakened if the lock can be taken.
panic_on_oom¶
This enables or disables panic on out-of-memory feature.
If this is set to 0, the kernel will kill some rogue process,called oom_killer. Usually, oom_killer can kill rogue processes andsystem will survive.
If this is set to 1, the kernel panics when out-of-memory happens.However, if a process limits using nodes by mempolicy/cpusets,and those nodes become memory exhaustion status, one processmay be killed by oom-killer. No panic occurs in this case.Because other nodes’ memory may be free. This means system total statusmay be not fatal yet.
If this is set to 2, the kernel panics compulsorily even on theabove-mentioned. Even oom happens under memory cgroup, the wholesystem panics.
The default value is 0.
1 and 2 are for failover of clustering. Please select eitheraccording to your policy of failover.
panic_on_oom=2+kdump gives you very strong tool to investigatewhy oom happens. You can get snapshot.
percpu_pagelist_high_fraction¶
This is the fraction of pages in each zone that are can be stored toper-cpu page lists. It is an upper boundary that is divided dependingon the number of online CPUs. The min value for this is 8 which meansthat we do not allow more than 1/8th of pages in each zone to be storedon per-cpu page lists. This entry only changes the value of hot per-cpupage lists. A user can specify a number like 100 to allocate 1/100th ofeach zone between per-cpu lists.
The batch value of each per-cpu page list remains the same regardless ofthe value of the high fraction so allocation latencies are unaffected.
The initial value is zero. Kernel uses this value to set the high pcp->highmark based on the low watermark for the zone and the number of localonline CPUs. If the user writes ‘0’ to this sysctl, it will revert tothis default behavior.
stat_interval¶
The time interval between which vm statistics are updated. The defaultis 1 second.
stat_refresh¶
Any read or write (by root only) flushes all the per-cpu vm statisticsinto their global totals, for more accurate reports when testinge.g. cat /proc/sys/vm/stat_refresh /proc/meminfo
As a side-effect, it also checks for negative totals (elsewhere reportedas 0) and “fails” with EINVAL if any are found, with a warning in dmesg.(At time of writing, a few stats are known sometimes to be found negative,with no ill effects: errors and warnings on these stats are suppressed.)
numa_stat¶
This interface allows runtime configuration of numa statistics.
When page allocation performance becomes a bottleneck and you can toleratesome possible tool breakage and decreased numa counter precision, you cando:
echo 0 > /proc/sys/vm/numa_stat
When page allocation performance is not a bottleneck and you want alltooling to work, you can do:
echo 1 > /proc/sys/vm/numa_stat
swappiness¶
This control is used to define the rough relative IO cost of swappingand filesystem paging, as a value between 0 and 200. At 100, the VMassumes equal IO cost and will thus apply memory pressure to the pagecache and swap-backed pages equally; lower values signify moreexpensive swap IO, higher values indicates cheaper.
Keep in mind that filesystem IO patterns under memory pressure tend tobe more efficient than swap’s random IO. An optimal value will requireexperimentation and will also be workload-dependent.
The default value is 60.
For in-memory swap, like zram or zswap, as well as hybrid setups thathave swap on faster devices than the filesystem, values beyond 100 canbe considered. For example, if the random IO against the swap deviceis on average 2x faster than IO from the filesystem, swappiness shouldbe 133 (x + 2x = 200, 2x = 133.33).
At 0, the kernel will not initiate swap until the amount of free andfile-backed pages is less than the high watermark in a zone.
unprivileged_userfaultfd¶
This flag controls the mode in which unprivileged users can use theuserfaultfd system calls. Set this to 0 to restrict unprivileged usersto handle page faults in user mode only. In this case, users withoutSYS_CAP_PTRACE must pass UFFD_USER_MODE_ONLY in order for userfaultfd tosucceed. Prohibiting use of userfaultfd for handling faults from kernelmode may make certain vulnerabilities more difficult to exploit.
Set this to 1 to allow unprivileged users to use the userfaultfd systemcalls without any restrictions.
The default value is 0.
Another way to control permissions for userfaultfd is to use/dev/userfaultfd instead of userfaultfd(2). SeeUserfaultfd.
user_reserve_kbytes¶
When overcommit_memory is set to 2, “never overcommit” mode, reservemin(3% of current process size, user_reserve_kbytes) of free memory.This is intended to prevent a user from starting a single memory hoggingprocess, such that they cannot recover (kill the hog).
user_reserve_kbytes defaults to min(3% of the current process size, 128MB).
If this is reduced to zero, then the user will be allowed to allocateall free memory with a single process, minus admin_reserve_kbytes.Any subsequent attempts to execute a command will result in“fork: Cannot allocate memory”.
Changing this takes effect whenever an application requests memory.
vfs_cache_pressure¶
This percentage value controls the tendency of the kernel to reclaimthe memory which is used for caching of directory and inode objects.
At the default value of vfs_cache_pressure=vfs_cache_pressure_denom the kernelwill attempt to reclaim dentries and inodes at a “fair” rate with respect topagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes thekernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0,the kernel will never reclaim dentries and inodes due to memory pressure andthis can easily lead to out-of-memory conditions. Increasing vfs_cache_pressurebeyond vfs_cache_pressure_denom causes the kernel to prefer to reclaim dentriesand inodes.
Increasing vfs_cache_pressure significantly beyond vfs_cache_pressure_denom mayhave negative performance impact. Reclaim code needs to take various locks tofind freeable directory and inode objects. When vfs_cache_pressure equals(10 * vfs_cache_pressure_denom), it will look for ten times more freeableobjects than there are.
Note: This setting should always be used together with vfs_cache_pressure_denom.
vfs_cache_pressure_denom¶
Defaults to 100 (minimum allowed value). Requires correspondingvfs_cache_pressure setting to take effect.
watermark_boost_factor¶
This factor controls the level of reclaim when memory is being fragmented.It defines the percentage of the high watermark of a zone that will bereclaimed if pages of different mobility are being mixed within pageblocks.The intent is that compaction has less work to do in the future and toincrease the success rate of future high-order allocations such as SLUBallocations, THP and hugetlbfs pages.
To make it sensible with respect to the watermark_scale_factorparameter, the unit is in fractions of 10,000. The default value of15,000 means that up to 150% of the high watermark will be reclaimed in theevent of a pageblock being mixed due to fragmentation. The level of reclaimis determined by the number of fragmentation events that occurred in therecent past. If this value is smaller than a pageblock then a pageblocksworth of pages will be reclaimed (e.g. 2MB on 64-bit x86). A boost factorof 0 will disable the feature.
watermark_scale_factor¶
This factor controls the aggressiveness of kswapd. It defines theamount of memory left in a node/system before kswapd is woken up andhow much memory needs to be free before kswapd goes back to sleep.
The unit is in fractions of 10,000. The default value of 10 means thedistances between watermarks are 0.1% of the available memory in thenode/system. The maximum value is 3000, or 30% of memory.
A high rate of threads entering direct reclaim (allocstall) or kswapdgoing to sleep prematurely (kswapd_low_wmark_hit_quickly) can indicatethat the number of free pages kswapd maintains for latency reasons istoo small for the allocation bursts occurring in the system. This knobcan then be used to tune kswapd aggressiveness accordingly.
zone_reclaim_mode¶
Zone_reclaim_mode allows someone to set more or less aggressive approaches toreclaim memory when a zone runs out of memory. If it is set to zero then nozone reclaim occurs. Allocations will be satisfied from other zones / nodesin the system.
This is value OR’ed together of
1 | Zone reclaim on |
2 | Zone reclaim writes dirty pages out |
4 | Zone reclaim swaps pages |
zone_reclaim_mode is disabled by default. For file servers or workloadsthat benefit from having their data cached, zone_reclaim_mode should beleft disabled as the caching effect is likely to be more important thandata locality.
Consider enabling one or more zone_reclaim mode bits if it’s known that theworkload is partitioned such that each partition fits within a NUMA nodeand that accessing remote memory would cause a measurable performancereduction. The page allocator will take additional actions beforeallocating off node pages.
Allowing zone reclaim to write out pages stops processes that arewriting large amounts of data from dirtying pages on other nodes. Zonereclaim will write out dirty pages if a zone fills up and so effectivelythrottle the process. This may decrease the performance of a single processsince it cannot use all of system memory to buffer the outgoing writesanymore but it preserve the memory on other nodes so that the performanceof other processes running on other nodes will not be affected.
Allowing regular swap effectively restricts allocations to the localnode unless explicitly overridden by memory policies or cpusetconfigurations.