linux虚拟内存内核参数

本文详细介绍了Linux内核中与虚拟内存管理相关的参数,包括admin_reserve_kbytes、block_dump、compact_memory等,涉及到内存预留、块I/O调试、内存压缩、脏页回写策略等内容,对理解Linux内存管理机制具有重要意义。
摘要由CSDN通过智能技术生成
参数说明
==============================================================
1.    admin_reserve_kbytes
给有cap_sys_admin权限的用户保留的内存数量,默认值是min(free pages * 3%, 8MB)。这些内存是为了给管理员登录和杀死进程恢复系统提供足够的内存.

2.     block_dump
block_dump enables block I/O debugging when set to a nonzero value. More information on block I/O debugging is in Documentation/laptops/laptop-mode.txt.
如果设置的是非零值,则会启用块I/O调试。更多的关于块I/O调试的信息可以参见Documentation/laptops/laptop-mode.txt。
3.    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 contiguous blocks where possible. This can be important for example in the allocation of huge pages although processes will also directly compact memory as required.
只有在启用了CONFIG_COMPACTION选项才有效。当向该文件(/proc/sys/vm/compact_memory)写入1时,所有的内存域都会被压缩,使空闲的内存尽可能形成连续的内存块。
4.    dirty_background_bytes
Contains the amount of dirty memory at which the pdflush background writeback daemon 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_bytes时,内核的flusher线程开始回写脏页。
  注意:dirty_background_bytes参数和dirty_background_ratio参数是相对的,只能指定其中一个。当其中一个参数文件被写入时,会立即开始计算脏页限制,并且会将另一个参数的值清零。
5.    dirty_background_ratio
Contains, as a percentage of total system memory, the number of pages at which the pdflush background writeback daemon will start writing out dirty data.
当脏页所占的百分比(相对于所有可用内存,即空闲内存页+可回收内存页)达到dirty_background_ratio时,内核的flusher线程开始回写脏页数据。所有可用内存不等于总的系统内存。
6.    dirty_bytes
Contains the amount of dirty memory at which a process generating disk writes will itself start writeback.
Note: dirty_bytes is the counterpart of dirty_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.
Note: the minimum value allowed for dirty_bytes is two pages (in bytes); any value lower than this limit will be ignored and the old configuration will be retained.
当脏页所占的百分比(相对于所有可用内存,即空闲内存页+可回收内存页)达到dirty_ratio时,执行磁盘写操作的进程会自己开始回写脏数据。所有可用内存不等于总的系统内存。
7.    dirty_expire_centisecs
This tunable is used to define when dirty data is old enough to be eligible for writeout by the pdflush daemons.  It is expressed in 100'ths of a second. Data which has been dirty in-memory for longer than this interval will be written out next time a pdflush daemon wakes up.
脏数据的过期时间,超过该时间后内核的flusher线程被唤醒时会将脏数据回写到磁盘上,单位是百分之一秒。

8.    dirty_ratio
Contains, as a percentage of total system memory, the number of pages at which a process which is generating disk writes will itself start writing out dirty data.
当脏页所占的百分比(相对于所有可用内存,即空闲内存页+可回收内存页)达到dirty_ratio时,执行磁盘写操作的进程会自己开始回写脏数据。所有可用内存不等于总的系统内存。
9.    dirty_writeback_centisecs
The pdflush writeback daemons will periodically wake up and write `old' data out to disk.  This tunable expresses the interval between those wakeups, in 100'ths of a second.
Setting this to zero disables periodic writeback altogether.
内核的flusher线程会周期性地唤醒,然后将老的脏数据写到磁盘上。dirty_writeback_centisecs定义了唤醒的间隔,单位是百分之一秒。如果设置为0,则禁止周期性地唤醒回写线程。
10.    drop_caches
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation and dirty objects are not freeable, the user should run `sync' first.
向/proc/sys/vm/drop_caches文件中写入数值可以使内核释放page cache,dentries和inodes缓存所占的内存。
  只释放pagecache:
      echo 1 > /proc/sys/vm/drop_caches
  只释放dentries和inodes缓存:
      echo 2 > /proc/sys/vm/drop_caches
  释放pagecache、dentries和inodes缓存:
      echo 3 > /proc/sys/vm/drop_caches
  这个操作不是破坏性操作,脏的对象(比如脏页)不会被释放,因此要首先运行sync命令。
11.    extfrag_threshold
This parameter affects whether the kernel will compact memory or direct reclaim to satisfy a high-order allocation. /proc/extfrag_index shows what the fragmentation index for each order is in each zone in the system. Values tending towards 0 imply allocations would fail due to lack of memory, values towards 1000 imply failures are due to fragmentation and -1 implies that the allocation will succeed as long as watermarks are met.
The kernel will not compact memory in a zone if the fragmentation index is <= extfrag_threshold. The default value is 500.
12.    extra_free_kbytes
Add a userspace visible knob to tell the VM to keep an extra amount
of memory free, by increasing the gap between each zone's min and
low watermarks.
    This is useful for realtime applications that call system calls and have a bound on the number of allocations that happen in any short time period. In this application, extra_free_kbytes would be left at an amount equal to or larger than than the maximum number of allocations that happen in any burst.
It may also be useful to reduce the memory use of virtual machines (temporarily?), in a way that does not cause memory fragmentation like ballooning does.

http://www.gossamer-threads.com/lists/linux/kernel/1687142
13.    hugepages_treat_as_movable
This parameter is only useful when kernelcore= is specified at boot time to create
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值