1002 lines · 34.4 KB · Text
RawDownload
===============================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 in index.rst. ------------------------------------------------------------------------------ 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- block_dump- compact_memory- compaction_proactiveness- compact_unevictable_allowed- dirty_background_bytes- dirty_background_ratio- dirty_bytes- dirty_expire_centisecs- dirty_ratio- dirtytime_expire_seconds- dirty_writeback_centisecs- drop_caches- extfrag_threshold- highmem_is_dirtyable- hugetlb_shm_group- laptop_mode- legacy_va_layout- lowmem_reserve_ratio- max_map_count- 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- panic_on_oom- percpu_pagelist_fraction- stat_interval- stat_refresh- numa_stat- swappiness- unprivileged_userfaultfd- user_reserve_kbytes- vfs_cache_pressure- 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.  block_dump========== block_dump enables block I/O debugging when set to a nonzero value. Moreinformation on block I/O debugging is in Documentation/admin-guide/laptops/laptop-mode.rst.  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. 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. 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.  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. Only  one of them may be specified at a time. When one sysctl is written it is  immediately taken into account to evaluate the dirty memory limits and the  other 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 write `old` 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 run`sync` 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.  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 in Documentation/admin-guide/laptops/laptop-mode.rst.  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 the mlock()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 allocationswhich *could* 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). The `lowmem_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 using mlock(), 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_ratio	256     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 followings. (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.  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 uptodate 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. 

Lines 1–500 of 1002.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t