Manual page proc(5) line 1967 (press h for help or q to quit)

/proc/sys/vm

This directory contains files for memory management tuning, buffer and cache management.

   /proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches, dentries and inodes from
memory, causing that memory to become free. To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to free dentries and inodes,
use echo 2 > /proc/sys/vm/drop_caches; to free pagecache, dentries and inodes, use echo
3 > /proc/sys/vm/drop_caches. Because this is a nondestructive operation and dirty objects are not freeable, the user
should run sync(8) first. /proc/sys/vm/legacy_va_layout (since Linux 2.6.9)
If nonzero, this disables the new 32-bit memory-mapping layout; the kernel will use the
legacy (2.4) layout for all processes. /proc/sys/vm/memory_failure_early_kill (since Linux 2.6.32)
Control how to kill processes when an uncorrected memory error (typically a 2-bit error
in a memory module) that cannot be handled by the kernel is detected in the background
by hardware. In some cases (like the page still having a valid copy on disk), the ker‐
nel will handle the failure transparently without affecting any applications. But if
there is no other up-to-date copy of the data, it will kill processes to prevent any
data corruptions from propagating. The file has one of the following values: 1: Kill all processes that have the corrupted-and-not-reloadable page mapped as soon as
the corruption is detected. Note this is not supported for a few types of pages,
like kernel internally allocated data or the swap cache, but works for the majority
of user pages. 0: Only unmap the corrupted page from all processes and kill only a process that tries
to access it. The kill is performed using a SIGBUS signal with si_code set to BUS_MCEERR_AO. Pro‐
cesses can handle this if they want to; see sigaction(2) for more details. This feature is active only on architectures/platforms with advanced machine check han‐
dling and depends on the hardware capabilities. Applications can override the memory_failure_early_kill setting individually with the
prctl(2) PR_MCE_KILL operation. Only present if the kernel was configured with CONFIG_MEMORY_FAILURE. /proc/sys/vm/memory_failure_recovery (since Linux 2.6.32)
Enable memory failure recovery (when supported by the platform) 1: Attempt recovery. 0: Always panic on a memory failure. Only present if the kernel was configured with CONFIG_MEMORY_FAILURE. /proc/sys/vm/oom_dump_tasks (since Linux 2.6.25)
Enables a system-wide task dump (excluding kernel threads) to be produced when the ker‐
nel performs an OOM-killing. The dump includes the following information for each task
(thread, process): thread ID, real user ID, thread group ID (process ID), virtual memory
size, resident set size, the CPU that the task is scheduled on, oom_adj score (see the
description of /proc/[pid]/oom_adj), and command name. This is helpful to determine why
the OOM-killer was invoked and to identify the rogue task that caused it. If this contains the value zero, this information is suppressed. On very large systems
with thousands of tasks, it may not be feasible to dump the memory state information for
each one. Such systems should not be forced to incur a performance penalty in OOM situ‐
ations when the information may not be desired. If this is set to nonzero, this information is shown whenever the OOM-killer actually
kills a memory-hogging task. The default value is 0. /proc/sys/vm/oom_kill_allocating_task (since Linux 2.6.24)
This enables or disables killing the OOM-triggering task in out-of-memory situations. If this is set to zero, the OOM-killer will scan through the entire tasklist and select
a task based on heuristics to kill. This normally selects a rogue memory-hogging task
that frees up a large amount of memory when killed. If this is set to nonzero, the OOM-killer simply kills the task that triggered the out-
of-memory condition. This avoids a possibly expensive tasklist scan. If /proc/sys/vm/panic_on_oom is nonzero, it takes precedence over whatever value is used
in /proc/sys/vm/oom_kill_allocating_task. The default value is 0. /proc/sys/vm/overcommit_memory
This file contains the kernel virtual memory accounting mode. Values are: 0: heuristic overcommit (this is the default)
1: always overcommit, never check
2: always check, never overcommit In mode 0, calls of mmap(2) with MAP_NORESERVE are not checked, and the default check is
very weak, leading to the risk of getting a process "OOM-killed". Under Linux 2.4 any
nonzero value implies mode 1. In mode 2 (available since Linux 2.6), the total virtual
address space on the system is limited to (SS + RAM*(r/100)), where SS is the size of
the swap space, and RAM is the size of the physical memory, and r is the contents of the
file /proc/sys/vm/overcommit_ratio. /proc/sys/vm/overcommit_ratio
See the description of /proc/sys/vm/overcommit_memory. /proc/sys/vm/panic_on_oom (since Linux 2.6.18)
This enables or disables a kernel panic in an out-of-memory situation. If this file is set to the value 0, the kernel's OOM-killer will kill some rogue
process. Usually, the OOM-killer is able to kill a rogue process and the system will
survive. If this file is set to the value 1, then the kernel normally panics when out-of-memory
happens. However, if a process limits allocations to certain nodes using memory poli‐
cies (mbind(2) MPOL_BIND) or cpusets (cpuset(7)) and those nodes reach memory exhaustion
status, one process may be killed by the OOM-killer. No panic occurs in this case:
because other nodes' memory may be free, this means the system as a whole may not have
reached an out-of-memory situation yet. If this file is set to the value 2, the kernel always panics when an out-of-memory con‐
dition occurs. The default value is 0. 1 and 2 are for failover of clustering. Select either accord‐
ing to your policy of failover. /proc/sys/vm/swappiness
The value in this file controls how aggressively the kernel will swap memory pages.
Higher values increase aggressiveness, lower values decrease aggressiveness. The
default value is 60.
/proc/sys/vm
该目录下的文件用来优化虚拟内存
比较重要的参数如下
justin_$ uname -a
Linux justin 2.6.32-100.26.2.el5 #1 SMP Tue Jan 18 20:11:49 EST 2011 x86_64 x86_64 x86_64 GNU/Linux Swappiness
justin_$ more swappiness
60
--范围从0—100,因为即便有足够空余物理内存,linux也会将部分长期没有用到的页swap,该值越高则linux越倾向于此; vfs_cache_pressure
默认值100,用于控制回收cache频率,值越小则越倾向于保留cache,0 表示从不回收cache容易导致out-of-memory
注:cache用于缓存inode/dentry,而buffer用于缓存data
justin_$ more vfs_cache_pressure
100 stat_interval
VM信息更新频率,默认每1秒更新一次
justin_$ more stat_interval
1 hugetlb_shm_group
指定group id,拥有该gid的用户可以使用huge page创建SysV共享内存段;
注:用户可通过2种方式使用huge page
Mmap:使用此API时,如果没有指定MAP_HUGETLB选项,系统必须加载hugetlbfs文件系统到/mnt/huge
SYSV共享内存system call(shmget/shmat):调用此API则需要配置hugetlb_shm_group 如果oracle使用了huge page且通过shm*调用,则将该值设为oracle用户的gid,否则可能会遭遇ORA-27125
ORA-27125: unable to create shared memory segment
Cause: shmget() call failed
Action: contact Oracle support
justin_$ more hugetlb_shm_group
0
http://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt nr_hugepages
huge页的最小数目,需要连续的物理内存;oracle使用hugepage可以降低TLB的开销,节约内存和CPU资源,但要同时设置memlock且保证其大于hugepage;其与11gAMM不兼容;
# - memlock - max locked-in-memory address space (KB)
显然此系统分配了hugepage但没有程序使用
justin_$ more nr_hugepages
5120
justin_$ more /proc/meminfo | grep -i huge
HugePages_Total: 5120
HugePages_Free: 5120
HugePages_Rsvd: 0
HugePages_Surp: 0 –当请求的页数超过nr_hugepages时可额外申请的页数,最大值由nv_overcommit_hugepages参数控制
Hugepagesize: 2048 http://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt nr_overcommit_hugepages
系统可分配最大huge page数= nr_hugepages + nr_overcommit_hugepages
justin_$ more nr_overcommit_hugepages
0 mmap_min_addr
指定用户进程通过mmap可使用的最小虚拟内存地址,以避免其在低地址空间产生映射导致安全问题;如果非0,则不允许mmap到NULL页,而此功能可在出现NULL指针时调试Kernel;mmap用于将文件映射至内存;
该设置意味着禁止用户进程访问low 4k地址空间
justin_$ more mmap_min_addr
4096
http://justanothergeek.chdir.org/2011/01/linux-security-one-year-later.html
https://blogs.oracle.com/ksplice/entry/much_ado_about_null_exploiting1
http://trac.clozure.com/ccl/wiki/PlatformNotes
http://loda.hala01.com/2012/08/android-4-1-jelly-bean%E5%AE%89%E5%85%A8%E6%A9%9F%E5%88%B6%E6%8E%A2%E8%A8%8E-2/ panic_on_oom
用于控制如何处理out-of-memory,可选值包括0/1/2,默认为0
0:当内存不足时内核调用OOM killer杀死一些rogue进程,每个进程描述符都有一个oom_score标示,oom killer会选择oom_score较大的进程
1/2:内存不足时不杀死进程,但具体策略有所差异
justin_$ more panic_on_oom
0 oom_kill_allocating_task
控制如何kill触发OOM的进程,可选值包括0/non-0,受panic_on_oom值影响
0:OOM killer扫描所有的进程寻找oom_score最高的,可通过将其kill释放大量内存
Non-0:kill出发out-of-memory的那个进程,避免进程队列扫描
justin_$ more oom_kill_allocating_task
0 lowmem_reserve_ratio
保留的lowmem,3列分别为DMA/normal/HighMem
justin_$ more lowmem_reserve_ratio
256 256 32 dirty_background_bytes/ dirty_background_ratio
当内存中脏页达到一定数量或比例时,启用pdflush将其刷新至磁盘,两者只能取其一;
[oracle@usuwsoadb05 vm]$ more dirty_background_bytes
0
[oracle@usuwsoadb05 vm]$ more dirty_background_ratio
10 dirty_bytes/ dirty_ratio
当进程的脏数据达到某个临界点则该进程自动将其刷新至磁盘,dirty_ratio是与整个系统内存相除
justin_$ more dirty_bytes
0
justin_$ more dirty_ratio
20 drop_caches
默认为0,可选值包括1/2/3
1:释放页缓存,即buffer
2:是否inode和dentries缓存,即cache
3:包含1和2
注:由于buffer/cache里的值
justin_$ more drop_caches
0 max_map_count
一个进程最多可用于的内存映射区(memory map areas),在调用malloc会用到,由mmap/mprotect生成
Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries.
大部分程序使用数量不会超过1000,默认值65536
注:该值若太小某些情况下会导致ora-4030,详情参照ID 1325100.1,
当4030跟踪文件的process map dump记录如下,此时max_map_cout设置为65536导致资源不足 ,可适当调大
----- Process Map Dump -----
00400000-0954f000 r-xp 00000000 fd:09 3131376 /e00/oracle/prod/v11.2.0/bin/oracle <<<---Line 1
0974e000-0a2be000 rwxp 0914e000 fd:09 3131376 /e00/oracle/prod/v11.2.0/bin/oracle
0a2be000-0a304000 rwxp 0a2be000 00:00 0
0c8c9000-0c950000 rwxp 0c8c9000 00:00 0 [heap]
60000000-60001000 r-xs 00000000 00:13 9374560 /dev/shm/ora_DSSP_11698195_0
60001000-70000000 rwxs 00001000 00:13 9374560 /dev/shm/ora_DSSP_11698195_0
70000000-80000000 rwxs 00000000 00:13 9374561 /dev/shm/ora_DSSP_11698195_1
80000000-90000000 rwxs 00000000 00:13 9374565 /dev/shm/ora_DSSP_11730964_0
90000000-a0000000 rwxs 00000000 00:13 9374566 /dev/shm/ora_DSSP_11730964_1
a0000000-b0000000 rwxs 00000000 00:13 9374569 /dev/shm/ora_DSSP_11763733_0
b00 2aed84a4f000-2aed86e5f000 rwxp febe2000 00:11 29160 /dev/zero
7fffea3ca000-7fffea418000 rwxp 7ffffffb1000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso] <<---End of the map dump at (Line 65537 of the Process Map Dump)
******************* End of process map dump *********** justin_$ more max_map_count
65530
http://www.enchantedage.com/node/235
http://www.cppblog.com/feixuwu/archive/2011/05/14/146395.html nr_pdflush_threads
当前pdfflush线程数量,为read-only,系统会根据脏页数自动调整,1秒增加1个直至nr_pdflush_threads_max;
justin_$ more nr_pdflush_threads
0 overcommit_memory
为一个flag,可选值包括0/1/2,用于控制内存过度分配
0:当用户空间请求更多内存时,内核则评估当前空闲内存量,如果足够则分配
1:内核假定系统中始终有足够的内存直至耗尽为止
2:内核采用”never overcommit”策略,以避免内存被耗尽
有很多程序调用malloc()请求大量内存却很少使用,该参数则十分有用
justin_$ more overcommit_memory
0
overcommit_ratio
该值为物理内存比率,当overcommit_memory=2时,进程可使用的swap空间不可超过PM * overcommit_ratio/100
justin_$ more overcommit_ratio
50 page-cluster
一次写入swap的内存页数=2的page-cluster次方,若该值为0则一次写入1个页,为1
justin_$ more page-cluster
3

/proc/sys/vm man手册的更多相关文章

  1. Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches

    Linux下清理内存和Cache方法 /proc/sys/vm/drop_caches 频繁的文件访问会导致系统的Cache使用量大增 $ free -m total used free shared ...

  2. /proc/sys/vm/参数

    1) /proc/sys/vm/block_dump该文件表示是否打开Block Debug模式,用于记录所有的读写及Dirty Block写回动作.缺省设置:0,禁用Block Debug模式2) ...

  3. /proc/sys/vm/ 内存参数

    linux下proc里关于磁盘性能的参数 http://blog.csdn.net/eroswang/article/details/6126646  我们在磁盘写操作持续繁忙的服务器上曾经碰到一个特 ...

  4. linux内存——/proc/sys/vm/drop_caches

      原贴:http://www.linuxfly.org/post/320/ http://blog.csdn.net/chinalinuxzend/article/category/265273/2 ...

  5. 手工释放linux内存——/proc/sys/vm/drop_caches

    --手工释放linux内存——/proc/sys/vm/drop_caches 总有很多朋友对于Linux的内存管理有疑问,之前一篇日志似乎也没能清除大家的疑虑.而在新版核心中,似乎对这个问题提供了新 ...

  6. linux /proc/sys/vm/中各个文件含义

    1)      /proc/sys/vm/block_dump该文件表示是否打开Block Debug模式,用于记录所有的读写及Dirty Block写回动作. 缺省设置:0,禁用Block Debu ...

  7. (转)手工释放linux内存——/proc/sys/vm/drop_cache

    linux的内存查看: [root@localhost 0.1.0]# free -m                   total       used       free     shared ...

  8. dirty_background_ration 与 /proc/sys/vm/dirty_ratio

    wappiness的值的大小对如何使用swap分区是有着很大的联系的.swappiness=0的时候表示最大限度使用物理内存,然后才是 swap空间,swappiness=100的时候表示积极的使用s ...

  9. /proc/sys/vm/drop_caches 清理缓存

    1. 使用方法 /proc/sys/vm/drop_caches默认是0 # echo 1 > /proc/sys/vm/drop_caches; free pagecache, use# ec ...

随机推荐

  1. [Python]Django部署问题

    给客户部署系统 Apache + mod_wsgi + django 打开浏览器妈的死活就是pending状态 运来mod_wsgi用的32位,操作系统64位(window server 2003 r ...

  2. Java 两个整数相除保留两位小数,将小数转化为百分数

    Java 两个整数相除保留两位小数,将小数转化为百分数 源于:http://blog.sina.com.cn/s/blog_624d755d0101cvuq.html 后来学习了:http://blo ...

  3. Java API 读取HDFS的单文件

    HDFS上的单文件: -bash-3.2$ hadoop fs -ls /user/pms/ouyangyewei/data/input/combineorder/repeat_rec_categor ...

  4. 【特征匹配】SIFT原理之KD树+BBF算法解析

    转载请注明出处:http://blog.csdn.net/luoshixian099/article/details/47606159 继上一篇中已经介绍了SIFT原理与C源代码剖析,最后得到了一系列 ...

  5. ASP.NET快速开发框架不得不做的几个功能、高大上档次后台管理UI界面

    俗话说磨刀不误砍柴工,确实,一早上花一个小时去磨刀一天下来肯定能多砍很多柴.我们做软件开发也是同样的道理,有套好开发框架在手里,开发也是事半功倍.那么一套MVC快速开发框架至少得具有哪些功能才能帮我们 ...

  6. 关于Vue.js去掉#号路由

    正常启动后访问路由: 中间会自动加入一个#号 去掉#号: 在route文件夹下的index.js中加入mode: 'history', ①: ②: 关于mode说明: 默认值: ‘hash‘(浏览器) ...

  7. idea新建文件无法识别(二)

    1,出现问题的步骤: 当想新增一个Hello.java文件时候 选错了文件类型.新建了一个text文件.当回过头来把文件后缀改掉的时候发现idea无法识别,颜色一直是灰色. 2,解决问题的办法: 选择 ...

  8. POJ 1082---->一个神一般的题

    代码只有10行,反正我是看了题解才知道的. 嗯 首先 看到这个题, BFS+一堆判断(什么平年闰年跨年各种乱搞肯定能搞出来,但是Code length就不一定了)... 然后呢 就看到了这个题解 从后 ...

  9. PHP中的魔术方法和魔术常量

    看上去好像挺烦人,但只要通过例子测试一下,就明白了.不做测试,只是看,第二天还是不明白.当然我在抄其他人的日志,然后希望能是自己的理解就好,原文地址PHP的魔术方法和魔术敞亮简介和使用--LaraBo ...

  10. poj2376 Cleaning Shifts 区间贪心

    题目大意: (不说牛了) 给出n个区间,选出个数最少的区间来覆盖区间[1,t].n,t都是给出的. 题目中默认情况是[1,x],[x+1,t]也是可以的.也就是两个相邻的区间之间可以是小区间的右端与大 ...