18c2ecf20Sopenharmony_ci=============================== 28c2ecf20Sopenharmony_ciDocumentation for /proc/sys/vm/ 38c2ecf20Sopenharmony_ci=============================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_cikernel version 2.6.29 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciCopyright (c) 1998, 1999, Rik van Riel <riel@nl.linux.org> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciCopyright (c) 2008 Peter W. Morreale <pmorreale@novell.com> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciFor general info and legal blurb, please look in index.rst. 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci------------------------------------------------------------------------------ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciThis file contains the documentation for the sysctl files in 168c2ecf20Sopenharmony_ci/proc/sys/vm and is valid for Linux kernel version 2.6.29. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciThe files in this directory can be used to tune the operation 198c2ecf20Sopenharmony_ciof the virtual memory (VM) subsystem of the Linux kernel and 208c2ecf20Sopenharmony_cithe writeout of dirty data to disk. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciDefault values and initialization routines for most of these 238c2ecf20Sopenharmony_cifiles can be found in mm/swap.c. 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciCurrently, these files are in /proc/sys/vm: 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci- admin_reserve_kbytes 288c2ecf20Sopenharmony_ci- compact_memory 298c2ecf20Sopenharmony_ci- compaction_proactiveness 308c2ecf20Sopenharmony_ci- compact_unevictable_allowed 318c2ecf20Sopenharmony_ci- dirty_background_bytes 328c2ecf20Sopenharmony_ci- dirty_background_ratio 338c2ecf20Sopenharmony_ci- dirty_bytes 348c2ecf20Sopenharmony_ci- dirty_expire_centisecs 358c2ecf20Sopenharmony_ci- dirty_ratio 368c2ecf20Sopenharmony_ci- dirtytime_expire_seconds 378c2ecf20Sopenharmony_ci- dirty_writeback_centisecs 388c2ecf20Sopenharmony_ci- drop_caches 398c2ecf20Sopenharmony_ci- extfrag_threshold 408c2ecf20Sopenharmony_ci- highmem_is_dirtyable 418c2ecf20Sopenharmony_ci- hugetlb_shm_group 428c2ecf20Sopenharmony_ci- laptop_mode 438c2ecf20Sopenharmony_ci- legacy_va_layout 448c2ecf20Sopenharmony_ci- lowmem_reserve_ratio 458c2ecf20Sopenharmony_ci- max_map_count 468c2ecf20Sopenharmony_ci- memory_failure_early_kill 478c2ecf20Sopenharmony_ci- memory_failure_recovery 488c2ecf20Sopenharmony_ci- min_free_kbytes 498c2ecf20Sopenharmony_ci- min_slab_ratio 508c2ecf20Sopenharmony_ci- min_unmapped_ratio 518c2ecf20Sopenharmony_ci- mmap_min_addr 528c2ecf20Sopenharmony_ci- mmap_rnd_bits 538c2ecf20Sopenharmony_ci- mmap_rnd_compat_bits 548c2ecf20Sopenharmony_ci- nr_hugepages 558c2ecf20Sopenharmony_ci- nr_hugepages_mempolicy 568c2ecf20Sopenharmony_ci- nr_overcommit_hugepages 578c2ecf20Sopenharmony_ci- nr_trim_pages (only if CONFIG_MMU=n) 588c2ecf20Sopenharmony_ci- numa_zonelist_order 598c2ecf20Sopenharmony_ci- oom_dump_tasks 608c2ecf20Sopenharmony_ci- oom_kill_allocating_task 618c2ecf20Sopenharmony_ci- overcommit_kbytes 628c2ecf20Sopenharmony_ci- overcommit_memory 638c2ecf20Sopenharmony_ci- overcommit_ratio 648c2ecf20Sopenharmony_ci- page-cluster 658c2ecf20Sopenharmony_ci- panic_on_oom 668c2ecf20Sopenharmony_ci- percpu_pagelist_fraction 678c2ecf20Sopenharmony_ci- stat_interval 688c2ecf20Sopenharmony_ci- stat_refresh 698c2ecf20Sopenharmony_ci- numa_stat 708c2ecf20Sopenharmony_ci- swappiness 718c2ecf20Sopenharmony_ci- unprivileged_userfaultfd 728c2ecf20Sopenharmony_ci- user_reserve_kbytes 738c2ecf20Sopenharmony_ci- vfs_cache_pressure 748c2ecf20Sopenharmony_ci- watermark_boost_factor 758c2ecf20Sopenharmony_ci- watermark_scale_factor 768c2ecf20Sopenharmony_ci- zone_reclaim_mode 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciadmin_reserve_kbytes 808c2ecf20Sopenharmony_ci==================== 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciThe amount of free memory in the system that should be reserved for users 838c2ecf20Sopenharmony_ciwith the capability cap_sys_admin. 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciadmin_reserve_kbytes defaults to min(3% of free pages, 8MB) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ciThat should provide enough for the admin to log in and kill a process, 888c2ecf20Sopenharmony_ciif necessary, under the default overcommit 'guess' mode. 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciSystems running under overcommit 'never' should increase this to account 918c2ecf20Sopenharmony_cifor the full Virtual Memory Size of programs used to recover. Otherwise, 928c2ecf20Sopenharmony_ciroot may not be able to log in to recover the system. 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciHow do you calculate a minimum useful reserve? 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cisshd or login + bash (or some other shell) + top (or ps, kill, etc.) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciFor overcommit 'guess', we can sum resident set sizes (RSS). 998c2ecf20Sopenharmony_ciOn x86_64 this is about 8MB. 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciFor overcommit 'never', we can take the max of their virtual sizes (VSZ) 1028c2ecf20Sopenharmony_ciand add the sum of their RSS. 1038c2ecf20Sopenharmony_ciOn x86_64 this is about 128MB. 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciChanging this takes effect whenever an application requests memory. 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cicompact_memory 1098c2ecf20Sopenharmony_ci============== 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciAvailable only when CONFIG_COMPACTION is set. When 1 is written to the file, 1128c2ecf20Sopenharmony_ciall zones are compacted such that free memory is available in contiguous 1138c2ecf20Sopenharmony_ciblocks where possible. This can be important for example in the allocation of 1148c2ecf20Sopenharmony_cihuge pages although processes will also directly compact memory as required. 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cicompaction_proactiveness 1178c2ecf20Sopenharmony_ci======================== 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ciThis tunable takes a value in the range [0, 100] with a default value of 1208c2ecf20Sopenharmony_ci20. This tunable determines how aggressively compaction is done in the 1218c2ecf20Sopenharmony_cibackground. Setting it to 0 disables proactive compaction. 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciNote that compaction has a non-trivial system-wide impact as pages 1248c2ecf20Sopenharmony_cibelonging to different processes are moved around, which could also lead 1258c2ecf20Sopenharmony_cito latency spikes in unsuspecting applications. The kernel employs 1268c2ecf20Sopenharmony_civarious heuristics to avoid wasting CPU cycles if it detects that 1278c2ecf20Sopenharmony_ciproactive compaction is not being effective. 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciBe careful when setting it to extreme values like 100, as that may 1308c2ecf20Sopenharmony_cicause excessive background compaction activity. 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cicompact_unevictable_allowed 1338c2ecf20Sopenharmony_ci=========================== 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ciAvailable only when CONFIG_COMPACTION is set. When set to 1, compaction is 1368c2ecf20Sopenharmony_ciallowed to examine the unevictable lru (mlocked pages) for pages to compact. 1378c2ecf20Sopenharmony_ciThis should be used on systems where stalls for minor page faults are an 1388c2ecf20Sopenharmony_ciacceptable trade for large contiguous free memory. Set to 0 to prevent 1398c2ecf20Sopenharmony_cicompaction from moving pages that are unevictable. Default value is 1. 1408c2ecf20Sopenharmony_ciOn CONFIG_PREEMPT_RT the default value is 0 in order to avoid a page fault, due 1418c2ecf20Sopenharmony_cito compaction, which would block the task from becomming active until the fault 1428c2ecf20Sopenharmony_ciis resolved. 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cidirty_background_bytes 1468c2ecf20Sopenharmony_ci====================== 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ciContains the amount of dirty memory at which the background kernel 1498c2ecf20Sopenharmony_ciflusher threads will start writeback. 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciNote: 1528c2ecf20Sopenharmony_ci dirty_background_bytes is the counterpart of dirty_background_ratio. Only 1538c2ecf20Sopenharmony_ci one of them may be specified at a time. When one sysctl is written it is 1548c2ecf20Sopenharmony_ci immediately taken into account to evaluate the dirty memory limits and the 1558c2ecf20Sopenharmony_ci other appears as 0 when read. 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cidirty_background_ratio 1598c2ecf20Sopenharmony_ci====================== 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ciContains, as a percentage of total available memory that contains free pages 1628c2ecf20Sopenharmony_ciand reclaimable pages, the number of pages at which the background kernel 1638c2ecf20Sopenharmony_ciflusher threads will start writing out dirty data. 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ciThe total available memory is not equal to total system memory. 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cidirty_bytes 1698c2ecf20Sopenharmony_ci=========== 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ciContains the amount of dirty memory at which a process generating disk writes 1728c2ecf20Sopenharmony_ciwill itself start writeback. 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ciNote: dirty_bytes is the counterpart of dirty_ratio. Only one of them may be 1758c2ecf20Sopenharmony_cispecified at a time. When one sysctl is written it is immediately taken into 1768c2ecf20Sopenharmony_ciaccount to evaluate the dirty memory limits and the other appears as 0 when 1778c2ecf20Sopenharmony_ciread. 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ciNote: the minimum value allowed for dirty_bytes is two pages (in bytes); any 1808c2ecf20Sopenharmony_civalue lower than this limit will be ignored and the old configuration will be 1818c2ecf20Sopenharmony_ciretained. 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_cidirty_expire_centisecs 1858c2ecf20Sopenharmony_ci====================== 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ciThis tunable is used to define when dirty data is old enough to be eligible 1888c2ecf20Sopenharmony_cifor writeout by the kernel flusher threads. It is expressed in 100'ths 1898c2ecf20Sopenharmony_ciof a second. Data which has been dirty in-memory for longer than this 1908c2ecf20Sopenharmony_ciinterval will be written out next time a flusher thread wakes up. 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cidirty_ratio 1948c2ecf20Sopenharmony_ci=========== 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ciContains, as a percentage of total available memory that contains free pages 1978c2ecf20Sopenharmony_ciand reclaimable pages, the number of pages at which a process which is 1988c2ecf20Sopenharmony_cigenerating disk writes will itself start writing out dirty data. 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ciThe total available memory is not equal to total system memory. 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cidirtytime_expire_seconds 2048c2ecf20Sopenharmony_ci======================== 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ciWhen a lazytime inode is constantly having its pages dirtied, the inode with 2078c2ecf20Sopenharmony_cian updated timestamp will never get chance to be written out. And, if the 2088c2ecf20Sopenharmony_cionly thing that has happened on the file system is a dirtytime inode caused 2098c2ecf20Sopenharmony_ciby an atime update, a worker will be scheduled to make sure that inode 2108c2ecf20Sopenharmony_cieventually gets pushed out to disk. This tunable is used to define when dirty 2118c2ecf20Sopenharmony_ciinode is old enough to be eligible for writeback by the kernel flusher threads. 2128c2ecf20Sopenharmony_ciAnd, it is also used as the interval to wakeup dirtytime_writeback thread. 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_cidirty_writeback_centisecs 2168c2ecf20Sopenharmony_ci========================= 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ciThe kernel flusher threads will periodically wake up and write `old` data 2198c2ecf20Sopenharmony_ciout to disk. This tunable expresses the interval between those wakeups, in 2208c2ecf20Sopenharmony_ci100'ths of a second. 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ciSetting this to zero disables periodic writeback altogether. 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_cidrop_caches 2268c2ecf20Sopenharmony_ci=========== 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ciWriting to this will cause the kernel to drop clean caches, as well as 2298c2ecf20Sopenharmony_cireclaimable slab objects like dentries and inodes. Once dropped, their 2308c2ecf20Sopenharmony_cimemory becomes free. 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ciTo free pagecache:: 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci echo 1 > /proc/sys/vm/drop_caches 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ciTo free reclaimable slab objects (includes dentries and inodes):: 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci echo 2 > /proc/sys/vm/drop_caches 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ciTo free slab objects and pagecache:: 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci echo 3 > /proc/sys/vm/drop_caches 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ciThis is a non-destructive operation and will not free any dirty objects. 2458c2ecf20Sopenharmony_ciTo increase the number of objects freed by this operation, the user may run 2468c2ecf20Sopenharmony_ci`sync` prior to writing to /proc/sys/vm/drop_caches. This will minimize the 2478c2ecf20Sopenharmony_cinumber of dirty objects on the system and create more candidates to be 2488c2ecf20Sopenharmony_cidropped. 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ciThis file is not a means to control the growth of the various kernel caches 2518c2ecf20Sopenharmony_ci(inodes, dentries, pagecache, etc...) These objects are automatically 2528c2ecf20Sopenharmony_cireclaimed by the kernel when memory is needed elsewhere on the system. 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ciUse of this file can cause performance problems. Since it discards cached 2558c2ecf20Sopenharmony_ciobjects, it may cost a significant amount of I/O and CPU to recreate the 2568c2ecf20Sopenharmony_cidropped objects, especially if they were under heavy use. Because of this, 2578c2ecf20Sopenharmony_ciuse outside of a testing or debugging environment is not recommended. 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ciYou may see informational messages in your kernel log when this file is 2608c2ecf20Sopenharmony_ciused:: 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci cat (1234): drop_caches: 3 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ciThese are informational only. They do not mean that anything is wrong 2658c2ecf20Sopenharmony_ciwith your system. To disable them, echo 4 (bit 2) into drop_caches. 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ciextfrag_threshold 2698c2ecf20Sopenharmony_ci================= 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ciThis parameter affects whether the kernel will compact memory or direct 2728c2ecf20Sopenharmony_cireclaim to satisfy a high-order allocation. The extfrag/extfrag_index file in 2738c2ecf20Sopenharmony_cidebugfs shows what the fragmentation index for each order is in each zone in 2748c2ecf20Sopenharmony_cithe system. Values tending towards 0 imply allocations would fail due to lack 2758c2ecf20Sopenharmony_ciof memory, values towards 1000 imply failures are due to fragmentation and -1 2768c2ecf20Sopenharmony_ciimplies that the allocation will succeed as long as watermarks are met. 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ciThe kernel will not compact memory in a zone if the 2798c2ecf20Sopenharmony_cifragmentation index is <= extfrag_threshold. The default value is 500. 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_cihighmem_is_dirtyable 2838c2ecf20Sopenharmony_ci==================== 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ciAvailable only for systems with CONFIG_HIGHMEM enabled (32b systems). 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ciThis parameter controls whether the high memory is considered for dirty 2888c2ecf20Sopenharmony_ciwriters throttling. This is not the case by default which means that 2898c2ecf20Sopenharmony_cionly the amount of memory directly visible/usable by the kernel can 2908c2ecf20Sopenharmony_cibe dirtied. As a result, on systems with a large amount of memory and 2918c2ecf20Sopenharmony_cilowmem basically depleted writers might be throttled too early and 2928c2ecf20Sopenharmony_cistreaming writes can get very slow. 2938c2ecf20Sopenharmony_ci 2948c2ecf20Sopenharmony_ciChanging the value to non zero would allow more memory to be dirtied 2958c2ecf20Sopenharmony_ciand thus allow writers to write more data which can be flushed to the 2968c2ecf20Sopenharmony_cistorage more effectively. Note this also comes with a risk of pre-mature 2978c2ecf20Sopenharmony_ciOOM killer because some writers (e.g. direct block device writes) can 2988c2ecf20Sopenharmony_cionly use the low memory and they can fill it up with dirty data without 2998c2ecf20Sopenharmony_ciany throttling. 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cihugetlb_shm_group 3038c2ecf20Sopenharmony_ci================= 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_cihugetlb_shm_group contains group id that is allowed to create SysV 3068c2ecf20Sopenharmony_cishared memory segment using hugetlb page. 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_cilaptop_mode 3108c2ecf20Sopenharmony_ci=========== 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_cilaptop_mode is a knob that controls "laptop mode". All the things that are 3138c2ecf20Sopenharmony_cicontrolled by this knob are discussed in Documentation/admin-guide/laptops/laptop-mode.rst. 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cilegacy_va_layout 3178c2ecf20Sopenharmony_ci================ 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ciIf non-zero, this sysctl disables the new 32-bit mmap layout - the kernel 3208c2ecf20Sopenharmony_ciwill use the legacy (2.4) layout for all processes. 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_cilowmem_reserve_ratio 3248c2ecf20Sopenharmony_ci==================== 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ciFor some specialised workloads on highmem machines it is dangerous for 3278c2ecf20Sopenharmony_cithe kernel to allow process memory to be allocated from the "lowmem" 3288c2ecf20Sopenharmony_cizone. This is because that memory could then be pinned via the mlock() 3298c2ecf20Sopenharmony_cisystem call, or by unavailability of swapspace. 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ciAnd on large highmem machines this lack of reclaimable lowmem memory 3328c2ecf20Sopenharmony_cican be fatal. 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ciSo the Linux page allocator has a mechanism which prevents allocations 3358c2ecf20Sopenharmony_ciwhich *could* use highmem from using too much lowmem. This means that 3368c2ecf20Sopenharmony_cia certain amount of lowmem is defended from the possibility of being 3378c2ecf20Sopenharmony_cicaptured into pinned user memory. 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci(The same argument applies to the old 16 megabyte ISA DMA region. This 3408c2ecf20Sopenharmony_cimechanism will also defend that region from allocations which could use 3418c2ecf20Sopenharmony_cihighmem or lowmem). 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ciThe `lowmem_reserve_ratio` tunable determines how aggressive the kernel is 3448c2ecf20Sopenharmony_ciin defending these lower zones. 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ciIf you have a machine which uses highmem or ISA DMA and your 3478c2ecf20Sopenharmony_ciapplications are using mlock(), or if you are running with no swap then 3488c2ecf20Sopenharmony_ciyou probably should change the lowmem_reserve_ratio setting. 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ciThe lowmem_reserve_ratio is an array. You can see them by reading this file:: 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_ci % cat /proc/sys/vm/lowmem_reserve_ratio 3538c2ecf20Sopenharmony_ci 256 256 32 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ciBut, these values are not used directly. The kernel calculates # of protection 3568c2ecf20Sopenharmony_cipages for each zones from them. These are shown as array of protection pages 3578c2ecf20Sopenharmony_ciin /proc/zoneinfo like followings. (This is an example of x86-64 box). 3588c2ecf20Sopenharmony_ciEach zone has an array of protection pages like this:: 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci Node 0, zone DMA 3618c2ecf20Sopenharmony_ci pages free 1355 3628c2ecf20Sopenharmony_ci min 3 3638c2ecf20Sopenharmony_ci low 3 3648c2ecf20Sopenharmony_ci high 4 3658c2ecf20Sopenharmony_ci : 3668c2ecf20Sopenharmony_ci : 3678c2ecf20Sopenharmony_ci numa_other 0 3688c2ecf20Sopenharmony_ci protection: (0, 2004, 2004, 2004) 3698c2ecf20Sopenharmony_ci ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3708c2ecf20Sopenharmony_ci pagesets 3718c2ecf20Sopenharmony_ci cpu: 0 pcp: 0 3728c2ecf20Sopenharmony_ci : 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ciThese protections are added to score to judge whether this zone should be used 3758c2ecf20Sopenharmony_cifor page allocation or should be reclaimed. 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ciIn this example, if normal pages (index=2) are required to this DMA zone and 3788c2ecf20Sopenharmony_ciwatermark[WMARK_HIGH] is used for watermark, the kernel judges this zone should 3798c2ecf20Sopenharmony_cinot be used because pages_free(1355) is smaller than watermark + protection[2] 3808c2ecf20Sopenharmony_ci(4 + 2004 = 2008). If this protection value is 0, this zone would be used for 3818c2ecf20Sopenharmony_cinormal page requirement. If requirement is DMA zone(index=0), protection[0] 3828c2ecf20Sopenharmony_ci(=0) is used. 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_cizone[i]'s protection[j] is calculated by following expression:: 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci (i < j): 3878c2ecf20Sopenharmony_ci zone[i]->protection[j] 3888c2ecf20Sopenharmony_ci = (total sums of managed_pages from zone[i+1] to zone[j] on the node) 3898c2ecf20Sopenharmony_ci / lowmem_reserve_ratio[i]; 3908c2ecf20Sopenharmony_ci (i = j): 3918c2ecf20Sopenharmony_ci (should not be protected. = 0; 3928c2ecf20Sopenharmony_ci (i > j): 3938c2ecf20Sopenharmony_ci (not necessary, but looks 0) 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ciThe default values of lowmem_reserve_ratio[i] are 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci === ==================================== 3988c2ecf20Sopenharmony_ci 256 (if zone[i] means DMA or DMA32 zone) 3998c2ecf20Sopenharmony_ci 32 (others) 4008c2ecf20Sopenharmony_ci === ==================================== 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ciAs above expression, they are reciprocal number of ratio. 4038c2ecf20Sopenharmony_ci256 means 1/256. # of protection pages becomes about "0.39%" of total managed 4048c2ecf20Sopenharmony_cipages of higher zones on the node. 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ciIf you would like to protect more pages, smaller values are effective. 4078c2ecf20Sopenharmony_ciThe minimum value is 1 (1/1 -> 100%). The value less than 1 completely 4088c2ecf20Sopenharmony_cidisables protection of the pages. 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_cimax_map_count: 4128c2ecf20Sopenharmony_ci============== 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ciThis file contains the maximum number of memory map areas a process 4158c2ecf20Sopenharmony_cimay have. Memory map areas are used as a side-effect of calling 4168c2ecf20Sopenharmony_cimalloc, directly by mmap, mprotect, and madvise, and also when loading 4178c2ecf20Sopenharmony_cishared libraries. 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ciWhile most applications need less than a thousand maps, certain 4208c2ecf20Sopenharmony_ciprograms, particularly malloc debuggers, may consume lots of them, 4218c2ecf20Sopenharmony_cie.g., up to one or two maps per allocation. 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ciThe default value is 65536. 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_cimemory_failure_early_kill: 4278c2ecf20Sopenharmony_ci========================== 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ciControl how to kill processes when uncorrected memory error (typically 4308c2ecf20Sopenharmony_cia 2bit error in a memory module) is detected in the background by hardware 4318c2ecf20Sopenharmony_cithat cannot be handled by the kernel. In some cases (like the page 4328c2ecf20Sopenharmony_cistill having a valid copy on disk) the kernel will handle the failure 4338c2ecf20Sopenharmony_citransparently without affecting any applications. But if there is 4348c2ecf20Sopenharmony_cino other uptodate copy of the data it will kill to prevent any data 4358c2ecf20Sopenharmony_cicorruptions from propagating. 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci1: Kill all processes that have the corrupted and not reloadable page mapped 4388c2ecf20Sopenharmony_cias soon as the corruption is detected. Note this is not supported 4398c2ecf20Sopenharmony_cifor a few types of pages, like kernel internally allocated data or 4408c2ecf20Sopenharmony_cithe swap cache, but works for the majority of user pages. 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci0: Only unmap the corrupted page from all processes and only kill a process 4438c2ecf20Sopenharmony_ciwho tries to access it. 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ciThe kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes can 4468c2ecf20Sopenharmony_cihandle this if they want to. 4478c2ecf20Sopenharmony_ci 4488c2ecf20Sopenharmony_ciThis is only active on architectures/platforms with advanced machine 4498c2ecf20Sopenharmony_cicheck handling and depends on the hardware capabilities. 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ciApplications can override this setting individually with the PR_MCE_KILL prctl 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_cimemory_failure_recovery 4558c2ecf20Sopenharmony_ci======================= 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ciEnable memory failure recovery (when supported by the platform) 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci1: Attempt recovery. 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci0: Always panic on a memory failure. 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_cimin_free_kbytes 4658c2ecf20Sopenharmony_ci=============== 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ciThis is used to force the Linux VM to keep a minimum number 4688c2ecf20Sopenharmony_ciof kilobytes free. The VM uses this number to compute a 4698c2ecf20Sopenharmony_ciwatermark[WMARK_MIN] value for each lowmem zone in the system. 4708c2ecf20Sopenharmony_ciEach lowmem zone gets a number of reserved free pages based 4718c2ecf20Sopenharmony_ciproportionally on its size. 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ciSome minimal amount of memory is needed to satisfy PF_MEMALLOC 4748c2ecf20Sopenharmony_ciallocations; if you set this to lower than 1024KB, your system will 4758c2ecf20Sopenharmony_cibecome subtly broken, and prone to deadlock under high loads. 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ciSetting this too high will OOM your machine instantly. 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_cimin_slab_ratio 4818c2ecf20Sopenharmony_ci============== 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ciThis is available only on NUMA kernels. 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ciA percentage of the total pages in each zone. On Zone reclaim 4868c2ecf20Sopenharmony_ci(fallback from the local zone occurs) slabs will be reclaimed if more 4878c2ecf20Sopenharmony_cithan this percentage of pages in a zone are reclaimable slab pages. 4888c2ecf20Sopenharmony_ciThis insures that the slab growth stays under control even in NUMA 4898c2ecf20Sopenharmony_cisystems that rarely perform global reclaim. 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ciThe default is 5 percent. 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ciNote that slab reclaim is triggered in a per zone / node fashion. 4948c2ecf20Sopenharmony_ciThe process of reclaiming slab memory is currently not node specific 4958c2ecf20Sopenharmony_ciand may not be fast. 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_cimin_unmapped_ratio 4998c2ecf20Sopenharmony_ci================== 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ciThis is available only on NUMA kernels. 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_ciThis is a percentage of the total pages in each zone. Zone reclaim will 5048c2ecf20Sopenharmony_cionly occur if more than this percentage of pages are in a state that 5058c2ecf20Sopenharmony_cizone_reclaim_mode allows to be reclaimed. 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ciIf zone_reclaim_mode has the value 4 OR'd, then the percentage is compared 5088c2ecf20Sopenharmony_ciagainst all file-backed unmapped pages including swapcache pages and tmpfs 5098c2ecf20Sopenharmony_cifiles. Otherwise, only unmapped pages backed by normal files but not tmpfs 5108c2ecf20Sopenharmony_cifiles and similar are considered. 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ciThe default is 1 percent. 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_cimmap_min_addr 5168c2ecf20Sopenharmony_ci============= 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ciThis file indicates the amount of address space which a user process will 5198c2ecf20Sopenharmony_cibe restricted from mmapping. Since kernel null dereference bugs could 5208c2ecf20Sopenharmony_ciaccidentally operate based on the information in the first couple of pages 5218c2ecf20Sopenharmony_ciof memory userspace processes should not be allowed to write to them. By 5228c2ecf20Sopenharmony_cidefault this value is set to 0 and no protections will be enforced by the 5238c2ecf20Sopenharmony_cisecurity module. Setting this value to something like 64k will allow the 5248c2ecf20Sopenharmony_civast majority of applications to work correctly and provide defense in depth 5258c2ecf20Sopenharmony_ciagainst future potential kernel bugs. 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_cimmap_rnd_bits 5298c2ecf20Sopenharmony_ci============= 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ciThis value can be used to select the number of bits to use to 5328c2ecf20Sopenharmony_cidetermine the random offset to the base address of vma regions 5338c2ecf20Sopenharmony_ciresulting from mmap allocations on architectures which support 5348c2ecf20Sopenharmony_cituning address space randomization. This value will be bounded 5358c2ecf20Sopenharmony_ciby the architecture's minimum and maximum supported values. 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_ciThis value can be changed after boot using the 5388c2ecf20Sopenharmony_ci/proc/sys/vm/mmap_rnd_bits tunable 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_cimmap_rnd_compat_bits 5428c2ecf20Sopenharmony_ci==================== 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ciThis value can be used to select the number of bits to use to 5458c2ecf20Sopenharmony_cidetermine the random offset to the base address of vma regions 5468c2ecf20Sopenharmony_ciresulting from mmap allocations for applications run in 5478c2ecf20Sopenharmony_cicompatibility mode on architectures which support tuning address 5488c2ecf20Sopenharmony_cispace randomization. This value will be bounded by the 5498c2ecf20Sopenharmony_ciarchitecture's minimum and maximum supported values. 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ciThis value can be changed after boot using the 5528c2ecf20Sopenharmony_ci/proc/sys/vm/mmap_rnd_compat_bits tunable 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cinr_hugepages 5568c2ecf20Sopenharmony_ci============ 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ciChange the minimum size of the hugepage pool. 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ciSee Documentation/admin-guide/mm/hugetlbpage.rst 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_cinr_hugepages_mempolicy 5648c2ecf20Sopenharmony_ci====================== 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ciChange the size of the hugepage pool at run-time on a specific 5678c2ecf20Sopenharmony_ciset of NUMA nodes. 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ciSee Documentation/admin-guide/mm/hugetlbpage.rst 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_cinr_overcommit_hugepages 5738c2ecf20Sopenharmony_ci======================= 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ciChange the maximum size of the hugepage pool. The maximum is 5768c2ecf20Sopenharmony_cinr_hugepages + nr_overcommit_hugepages. 5778c2ecf20Sopenharmony_ci 5788c2ecf20Sopenharmony_ciSee Documentation/admin-guide/mm/hugetlbpage.rst 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_cinr_trim_pages 5828c2ecf20Sopenharmony_ci============= 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ciThis is available only on NOMMU kernels. 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ciThis value adjusts the excess page trimming behaviour of power-of-2 aligned 5878c2ecf20Sopenharmony_ciNOMMU mmap allocations. 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ciA value of 0 disables trimming of allocations entirely, while a value of 1 5908c2ecf20Sopenharmony_citrims excess pages aggressively. Any value >= 1 acts as the watermark where 5918c2ecf20Sopenharmony_citrimming of allocations is initiated. 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ciThe default value is 1. 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ciSee Documentation/admin-guide/mm/nommu-mmap.rst for more information. 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_cinuma_zonelist_order 5998c2ecf20Sopenharmony_ci=================== 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_ciThis sysctl is only for NUMA and it is deprecated. Anything but 6028c2ecf20Sopenharmony_ciNode order will fail! 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_ci'where the memory is allocated from' is controlled by zonelists. 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci(This documentation ignores ZONE_HIGHMEM/ZONE_DMA32 for simple explanation. 6078c2ecf20Sopenharmony_ciyou may be able to read ZONE_DMA as ZONE_DMA32...) 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ciIn non-NUMA case, a zonelist for GFP_KERNEL is ordered as following. 6108c2ecf20Sopenharmony_ciZONE_NORMAL -> ZONE_DMA 6118c2ecf20Sopenharmony_ciThis means that a memory allocation request for GFP_KERNEL will 6128c2ecf20Sopenharmony_ciget memory from ZONE_DMA only when ZONE_NORMAL is not available. 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ciIn NUMA case, you can think of following 2 types of order. 6158c2ecf20Sopenharmony_ciAssume 2 node NUMA and below is zonelist of Node(0)'s GFP_KERNEL:: 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci (A) Node(0) ZONE_NORMAL -> Node(0) ZONE_DMA -> Node(1) ZONE_NORMAL 6188c2ecf20Sopenharmony_ci (B) Node(0) ZONE_NORMAL -> Node(1) ZONE_NORMAL -> Node(0) ZONE_DMA. 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ciType(A) offers the best locality for processes on Node(0), but ZONE_DMA 6218c2ecf20Sopenharmony_ciwill be used before ZONE_NORMAL exhaustion. This increases possibility of 6228c2ecf20Sopenharmony_ciout-of-memory(OOM) of ZONE_DMA because ZONE_DMA is tend to be small. 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ciType(B) cannot offer the best locality but is more robust against OOM of 6258c2ecf20Sopenharmony_cithe DMA zone. 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ciType(A) is called as "Node" order. Type (B) is "Zone" order. 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci"Node order" orders the zonelists by node, then by zone within each node. 6308c2ecf20Sopenharmony_ciSpecify "[Nn]ode" for node order 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_ci"Zone Order" orders the zonelists by zone type, then by node within each 6338c2ecf20Sopenharmony_cizone. Specify "[Zz]one" for zone order. 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ciSpecify "[Dd]efault" to request automatic configuration. 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ciOn 32-bit, the Normal zone needs to be preserved for allocations accessible 6388c2ecf20Sopenharmony_ciby the kernel, so "zone" order will be selected. 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ciOn 64-bit, devices that require DMA32/DMA are relatively rare, so "node" 6418c2ecf20Sopenharmony_ciorder will be selected. 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ciDefault order is recommended unless this is causing problems for your 6448c2ecf20Sopenharmony_cisystem/application. 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_cioom_dump_tasks 6488c2ecf20Sopenharmony_ci============== 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ciEnables a system-wide task dump (excluding kernel threads) to be produced 6518c2ecf20Sopenharmony_ciwhen the kernel performs an OOM-killing and includes such information as 6528c2ecf20Sopenharmony_cipid, uid, tgid, vm size, rss, pgtables_bytes, swapents, oom_score_adj 6538c2ecf20Sopenharmony_ciscore, and name. This is helpful to determine why the OOM killer was 6548c2ecf20Sopenharmony_ciinvoked, to identify the rogue task that caused it, and to determine why 6558c2ecf20Sopenharmony_cithe OOM killer chose the task it did to kill. 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ciIf this is set to zero, this information is suppressed. On very 6588c2ecf20Sopenharmony_cilarge systems with thousands of tasks it may not be feasible to dump 6598c2ecf20Sopenharmony_cithe memory state information for each one. Such systems should not 6608c2ecf20Sopenharmony_cibe forced to incur a performance penalty in OOM conditions when the 6618c2ecf20Sopenharmony_ciinformation may not be desired. 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ciIf this is set to non-zero, this information is shown whenever the 6648c2ecf20Sopenharmony_ciOOM killer actually kills a memory-hogging task. 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_ciThe default value is 1 (enabled). 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_cioom_kill_allocating_task 6708c2ecf20Sopenharmony_ci======================== 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ciThis enables or disables killing the OOM-triggering task in 6738c2ecf20Sopenharmony_ciout-of-memory situations. 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ciIf this is set to zero, the OOM killer will scan through the entire 6768c2ecf20Sopenharmony_citasklist and select a task based on heuristics to kill. This normally 6778c2ecf20Sopenharmony_ciselects a rogue memory-hogging task that frees up a large amount of 6788c2ecf20Sopenharmony_cimemory when killed. 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ciIf this is set to non-zero, the OOM killer simply kills the task that 6818c2ecf20Sopenharmony_citriggered the out-of-memory condition. This avoids the expensive 6828c2ecf20Sopenharmony_citasklist scan. 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ciIf panic_on_oom is selected, it takes precedence over whatever value 6858c2ecf20Sopenharmony_ciis used in oom_kill_allocating_task. 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ciThe default value is 0. 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci 6908c2ecf20Sopenharmony_ciovercommit_kbytes 6918c2ecf20Sopenharmony_ci================= 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ciWhen overcommit_memory is set to 2, the committed address space is not 6948c2ecf20Sopenharmony_cipermitted to exceed swap plus this amount of physical RAM. See below. 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ciNote: overcommit_kbytes is the counterpart of overcommit_ratio. Only one 6978c2ecf20Sopenharmony_ciof them may be specified at a time. Setting one disables the other (which 6988c2ecf20Sopenharmony_cithen appears as 0 when read). 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ciovercommit_memory 7028c2ecf20Sopenharmony_ci================= 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ciThis value contains a flag that enables memory overcommitment. 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ciWhen this flag is 0, the kernel attempts to estimate the amount 7078c2ecf20Sopenharmony_ciof free memory left when userspace requests more memory. 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ciWhen this flag is 1, the kernel pretends there is always enough 7108c2ecf20Sopenharmony_cimemory until it actually runs out. 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ciWhen this flag is 2, the kernel uses a "never overcommit" 7138c2ecf20Sopenharmony_cipolicy that attempts to prevent any overcommit of memory. 7148c2ecf20Sopenharmony_ciNote that user_reserve_kbytes affects this policy. 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ciThis feature can be very useful because there are a lot of 7178c2ecf20Sopenharmony_ciprograms that malloc() huge amounts of memory "just-in-case" 7188c2ecf20Sopenharmony_ciand don't use much of it. 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ciThe default value is 0. 7218c2ecf20Sopenharmony_ci 7228c2ecf20Sopenharmony_ciSee Documentation/vm/overcommit-accounting.rst and 7238c2ecf20Sopenharmony_cimm/util.c::__vm_enough_memory() for more information. 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ciovercommit_ratio 7278c2ecf20Sopenharmony_ci================ 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ciWhen overcommit_memory is set to 2, the committed address 7308c2ecf20Sopenharmony_cispace is not permitted to exceed swap plus this percentage 7318c2ecf20Sopenharmony_ciof physical RAM. See above. 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_cipage-cluster 7358c2ecf20Sopenharmony_ci============ 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_cipage-cluster controls the number of pages up to which consecutive pages 7388c2ecf20Sopenharmony_ciare read in from swap in a single attempt. This is the swap counterpart 7398c2ecf20Sopenharmony_cito page cache readahead. 7408c2ecf20Sopenharmony_ciThe mentioned consecutivity is not in terms of virtual/physical addresses, 7418c2ecf20Sopenharmony_cibut consecutive on swap space - that means they were swapped out together. 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ciIt is a logarithmic value - setting it to zero means "1 page", setting 7448c2ecf20Sopenharmony_ciit to 1 means "2 pages", setting it to 2 means "4 pages", etc. 7458c2ecf20Sopenharmony_ciZero disables swap readahead completely. 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ciThe default value is three (eight pages at a time). There may be some 7488c2ecf20Sopenharmony_cismall benefits in tuning this to a different value if your workload is 7498c2ecf20Sopenharmony_ciswap-intensive. 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ciLower values mean lower latencies for initial faults, but at the same time 7528c2ecf20Sopenharmony_ciextra faults and I/O delays for following faults if they would have been part of 7538c2ecf20Sopenharmony_cithat consecutive pages readahead would have brought in. 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_cipanic_on_oom 7578c2ecf20Sopenharmony_ci============ 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ciThis enables or disables panic on out-of-memory feature. 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ciIf this is set to 0, the kernel will kill some rogue process, 7628c2ecf20Sopenharmony_cicalled oom_killer. Usually, oom_killer can kill rogue processes and 7638c2ecf20Sopenharmony_cisystem will survive. 7648c2ecf20Sopenharmony_ci 7658c2ecf20Sopenharmony_ciIf this is set to 1, the kernel panics when out-of-memory happens. 7668c2ecf20Sopenharmony_ciHowever, if a process limits using nodes by mempolicy/cpusets, 7678c2ecf20Sopenharmony_ciand those nodes become memory exhaustion status, one process 7688c2ecf20Sopenharmony_cimay be killed by oom-killer. No panic occurs in this case. 7698c2ecf20Sopenharmony_ciBecause other nodes' memory may be free. This means system total status 7708c2ecf20Sopenharmony_cimay be not fatal yet. 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ciIf this is set to 2, the kernel panics compulsorily even on the 7738c2ecf20Sopenharmony_ciabove-mentioned. Even oom happens under memory cgroup, the whole 7748c2ecf20Sopenharmony_cisystem panics. 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ciThe default value is 0. 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci1 and 2 are for failover of clustering. Please select either 7798c2ecf20Sopenharmony_ciaccording to your policy of failover. 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_cipanic_on_oom=2+kdump gives you very strong tool to investigate 7828c2ecf20Sopenharmony_ciwhy oom happens. You can get snapshot. 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_cipercpu_pagelist_fraction 7868c2ecf20Sopenharmony_ci======================== 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ciThis is the fraction of pages at most (high mark pcp->high) in each zone that 7898c2ecf20Sopenharmony_ciare allocated for each per cpu page list. The min value for this is 8. It 7908c2ecf20Sopenharmony_cimeans that we don't allow more than 1/8th of pages in each zone to be 7918c2ecf20Sopenharmony_ciallocated in any single per_cpu_pagelist. This entry only changes the value 7928c2ecf20Sopenharmony_ciof hot per cpu pagelists. User can specify a number like 100 to allocate 7938c2ecf20Sopenharmony_ci1/100th of each zone to each per cpu page list. 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ciThe batch value of each per cpu pagelist is also updated as a result. It is 7968c2ecf20Sopenharmony_ciset to pcp->high/4. The upper limit of batch is (PAGE_SHIFT * 8) 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_ciThe initial value is zero. Kernel does not use this value at boot time to set 7998c2ecf20Sopenharmony_cithe high water marks for each per cpu page list. If the user writes '0' to this 8008c2ecf20Sopenharmony_cisysctl, it will revert to this default behavior. 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_cistat_interval 8048c2ecf20Sopenharmony_ci============= 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ciThe time interval between which vm statistics are updated. The default 8078c2ecf20Sopenharmony_ciis 1 second. 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_cistat_refresh 8118c2ecf20Sopenharmony_ci============ 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ciAny read or write (by root only) flushes all the per-cpu vm statistics 8148c2ecf20Sopenharmony_ciinto their global totals, for more accurate reports when testing 8158c2ecf20Sopenharmony_cie.g. cat /proc/sys/vm/stat_refresh /proc/meminfo 8168c2ecf20Sopenharmony_ci 8178c2ecf20Sopenharmony_ciAs a side-effect, it also checks for negative totals (elsewhere reported 8188c2ecf20Sopenharmony_cias 0) and "fails" with EINVAL if any are found, with a warning in dmesg. 8198c2ecf20Sopenharmony_ci(At time of writing, a few stats are known sometimes to be found negative, 8208c2ecf20Sopenharmony_ciwith no ill effects: errors and warnings on these stats are suppressed.) 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci 8238c2ecf20Sopenharmony_cinuma_stat 8248c2ecf20Sopenharmony_ci========= 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ciThis interface allows runtime configuration of numa statistics. 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ciWhen page allocation performance becomes a bottleneck and you can tolerate 8298c2ecf20Sopenharmony_cisome possible tool breakage and decreased numa counter precision, you can 8308c2ecf20Sopenharmony_cido:: 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci echo 0 > /proc/sys/vm/numa_stat 8338c2ecf20Sopenharmony_ci 8348c2ecf20Sopenharmony_ciWhen page allocation performance is not a bottleneck and you want all 8358c2ecf20Sopenharmony_citooling to work, you can do:: 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_ci echo 1 > /proc/sys/vm/numa_stat 8388c2ecf20Sopenharmony_ci 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ciswappiness 8418c2ecf20Sopenharmony_ci========== 8428c2ecf20Sopenharmony_ci 8438c2ecf20Sopenharmony_ciThis control is used to define the rough relative IO cost of swapping 8448c2ecf20Sopenharmony_ciand filesystem paging, as a value between 0 and 200. At 100, the VM 8458c2ecf20Sopenharmony_ciassumes equal IO cost and will thus apply memory pressure to the page 8468c2ecf20Sopenharmony_cicache and swap-backed pages equally; lower values signify more 8478c2ecf20Sopenharmony_ciexpensive swap IO, higher values indicates cheaper. 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ciKeep in mind that filesystem IO patterns under memory pressure tend to 8508c2ecf20Sopenharmony_cibe more efficient than swap's random IO. An optimal value will require 8518c2ecf20Sopenharmony_ciexperimentation and will also be workload-dependent. 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ciThe default value is 60. 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_ciFor in-memory swap, like zram or zswap, as well as hybrid setups that 8568c2ecf20Sopenharmony_cihave swap on faster devices than the filesystem, values beyond 100 can 8578c2ecf20Sopenharmony_cibe considered. For example, if the random IO against the swap device 8588c2ecf20Sopenharmony_ciis on average 2x faster than IO from the filesystem, swappiness should 8598c2ecf20Sopenharmony_cibe 133 (x + 2x = 200, 2x = 133.33). 8608c2ecf20Sopenharmony_ci 8618c2ecf20Sopenharmony_ciAt 0, the kernel will not initiate swap until the amount of free and 8628c2ecf20Sopenharmony_cifile-backed pages is less than the high watermark in a zone. 8638c2ecf20Sopenharmony_ci 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ciunprivileged_userfaultfd 8668c2ecf20Sopenharmony_ci======================== 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ciThis flag controls whether unprivileged users can use the userfaultfd 8698c2ecf20Sopenharmony_cisystem calls. Set this to 1 to allow unprivileged users to use the 8708c2ecf20Sopenharmony_ciuserfaultfd system calls, or set this to 0 to restrict userfaultfd to only 8718c2ecf20Sopenharmony_ciprivileged users (with SYS_CAP_PTRACE capability). 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_ciThe default value is 1. 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci 8768c2ecf20Sopenharmony_ciuser_reserve_kbytes 8778c2ecf20Sopenharmony_ci=================== 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_ciWhen overcommit_memory is set to 2, "never overcommit" mode, reserve 8808c2ecf20Sopenharmony_cimin(3% of current process size, user_reserve_kbytes) of free memory. 8818c2ecf20Sopenharmony_ciThis is intended to prevent a user from starting a single memory hogging 8828c2ecf20Sopenharmony_ciprocess, such that they cannot recover (kill the hog). 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ciuser_reserve_kbytes defaults to min(3% of the current process size, 128MB). 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_ciIf this is reduced to zero, then the user will be allowed to allocate 8878c2ecf20Sopenharmony_ciall free memory with a single process, minus admin_reserve_kbytes. 8888c2ecf20Sopenharmony_ciAny subsequent attempts to execute a command will result in 8898c2ecf20Sopenharmony_ci"fork: Cannot allocate memory". 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_ciChanging this takes effect whenever an application requests memory. 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci 8948c2ecf20Sopenharmony_civfs_cache_pressure 8958c2ecf20Sopenharmony_ci================== 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_ciThis percentage value controls the tendency of the kernel to reclaim 8988c2ecf20Sopenharmony_cithe memory which is used for caching of directory and inode objects. 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ciAt the default value of vfs_cache_pressure=100 the kernel will attempt to 9018c2ecf20Sopenharmony_cireclaim dentries and inodes at a "fair" rate with respect to pagecache and 9028c2ecf20Sopenharmony_ciswapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer 9038c2ecf20Sopenharmony_cito retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will 9048c2ecf20Sopenharmony_cinever reclaim dentries and inodes due to memory pressure and this can easily 9058c2ecf20Sopenharmony_cilead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100 9068c2ecf20Sopenharmony_cicauses the kernel to prefer to reclaim dentries and inodes. 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ciIncreasing vfs_cache_pressure significantly beyond 100 may have negative 9098c2ecf20Sopenharmony_ciperformance impact. Reclaim code needs to take various locks to find freeable 9108c2ecf20Sopenharmony_cidirectory and inode objects. With vfs_cache_pressure=1000, it will look for 9118c2ecf20Sopenharmony_citen times more freeable objects than there are. 9128c2ecf20Sopenharmony_ci 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ciwatermark_boost_factor 9158c2ecf20Sopenharmony_ci====================== 9168c2ecf20Sopenharmony_ci 9178c2ecf20Sopenharmony_ciThis factor controls the level of reclaim when memory is being fragmented. 9188c2ecf20Sopenharmony_ciIt defines the percentage of the high watermark of a zone that will be 9198c2ecf20Sopenharmony_cireclaimed if pages of different mobility are being mixed within pageblocks. 9208c2ecf20Sopenharmony_ciThe intent is that compaction has less work to do in the future and to 9218c2ecf20Sopenharmony_ciincrease the success rate of future high-order allocations such as SLUB 9228c2ecf20Sopenharmony_ciallocations, THP and hugetlbfs pages. 9238c2ecf20Sopenharmony_ci 9248c2ecf20Sopenharmony_ciTo make it sensible with respect to the watermark_scale_factor 9258c2ecf20Sopenharmony_ciparameter, the unit is in fractions of 10,000. The default value of 9268c2ecf20Sopenharmony_ci15,000 on !DISCONTIGMEM configurations means that up to 150% of the high 9278c2ecf20Sopenharmony_ciwatermark will be reclaimed in the event of a pageblock being mixed due 9288c2ecf20Sopenharmony_cito fragmentation. The level of reclaim is determined by the number of 9298c2ecf20Sopenharmony_cifragmentation events that occurred in the recent past. If this value is 9308c2ecf20Sopenharmony_cismaller than a pageblock then a pageblocks worth of pages will be reclaimed 9318c2ecf20Sopenharmony_ci(e.g. 2MB on 64-bit x86). A boost factor of 0 will disable the feature. 9328c2ecf20Sopenharmony_ci 9338c2ecf20Sopenharmony_ci 9348c2ecf20Sopenharmony_ciwatermark_scale_factor 9358c2ecf20Sopenharmony_ci====================== 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_ciThis factor controls the aggressiveness of kswapd. It defines the 9388c2ecf20Sopenharmony_ciamount of memory left in a node/system before kswapd is woken up and 9398c2ecf20Sopenharmony_cihow much memory needs to be free before kswapd goes back to sleep. 9408c2ecf20Sopenharmony_ci 9418c2ecf20Sopenharmony_ciThe unit is in fractions of 10,000. The default value of 10 means the 9428c2ecf20Sopenharmony_cidistances between watermarks are 0.1% of the available memory in the 9438c2ecf20Sopenharmony_cinode/system. The maximum value is 3000, or 30% of memory. 9448c2ecf20Sopenharmony_ci 9458c2ecf20Sopenharmony_ciA high rate of threads entering direct reclaim (allocstall) or kswapd 9468c2ecf20Sopenharmony_cigoing to sleep prematurely (kswapd_low_wmark_hit_quickly) can indicate 9478c2ecf20Sopenharmony_cithat the number of free pages kswapd maintains for latency reasons is 9488c2ecf20Sopenharmony_citoo small for the allocation bursts occurring in the system. This knob 9498c2ecf20Sopenharmony_cican then be used to tune kswapd aggressiveness accordingly. 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci 9528c2ecf20Sopenharmony_cizone_reclaim_mode 9538c2ecf20Sopenharmony_ci================= 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_ciZone_reclaim_mode allows someone to set more or less aggressive approaches to 9568c2ecf20Sopenharmony_cireclaim memory when a zone runs out of memory. If it is set to zero then no 9578c2ecf20Sopenharmony_cizone reclaim occurs. Allocations will be satisfied from other zones / nodes 9588c2ecf20Sopenharmony_ciin the system. 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_ciThis is value OR'ed together of 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_ci= =================================== 9638c2ecf20Sopenharmony_ci1 Zone reclaim on 9648c2ecf20Sopenharmony_ci2 Zone reclaim writes dirty pages out 9658c2ecf20Sopenharmony_ci4 Zone reclaim swaps pages 9668c2ecf20Sopenharmony_ci= =================================== 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_cizone_reclaim_mode is disabled by default. For file servers or workloads 9698c2ecf20Sopenharmony_cithat benefit from having their data cached, zone_reclaim_mode should be 9708c2ecf20Sopenharmony_cileft disabled as the caching effect is likely to be more important than 9718c2ecf20Sopenharmony_cidata locality. 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ciConsider enabling one or more zone_reclaim mode bits if it's known that the 9748c2ecf20Sopenharmony_ciworkload is partitioned such that each partition fits within a NUMA node 9758c2ecf20Sopenharmony_ciand that accessing remote memory would cause a measurable performance 9768c2ecf20Sopenharmony_cireduction. The page allocator will take additional actions before 9778c2ecf20Sopenharmony_ciallocating off node pages. 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_ciAllowing zone reclaim to write out pages stops processes that are 9808c2ecf20Sopenharmony_ciwriting large amounts of data from dirtying pages on other nodes. Zone 9818c2ecf20Sopenharmony_cireclaim will write out dirty pages if a zone fills up and so effectively 9828c2ecf20Sopenharmony_cithrottle the process. This may decrease the performance of a single process 9838c2ecf20Sopenharmony_cisince it cannot use all of system memory to buffer the outgoing writes 9848c2ecf20Sopenharmony_cianymore but it preserve the memory on other nodes so that the performance 9858c2ecf20Sopenharmony_ciof other processes running on other nodes will not be affected. 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ciAllowing regular swap effectively restricts allocations to the local 9888c2ecf20Sopenharmony_cinode unless explicitly overridden by memory policies or cpuset 9898c2ecf20Sopenharmony_ciconfigurations. 990