vm/min_free_kbytes-为什么要保留最小的保留内存? [英] vm/min_free_kbytes - Why Keep Minimum Reserved Memory?

查看:1474
本文介绍了vm/min_free_kbytes-为什么要保留最小的保留内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此文章 :

/proc/sys/vm/min_free_kbytes:这可以控制可供特殊储备(包括原子"分配)(不能等待回收的那些)免费使用的内存量

/proc/sys/vm/min_free_kbytes: This controls the amount of memory that is kept free for use by special reserves including "atomic" allocations (those which cannot wait for reclaim)

我的问题是,那些不能等待回收的人"是什么意思?换句话说,我想了解为什么需要告诉系统始终保持一定的最小内存量,并且在什么情况下会使用此内存? [它必须被某些东西使用;没有其他需求的话]

My question is that what does it mean by "those which cannot wait for reclaim"? In other words, I would like to understand why there's a need to tell the system to always keep a certain minimum amount of memory free and under what circumstances will this memory be used? [It must be used by something; don't see the need otherwise]

第二个问题:将此内存设置为大于4MB(在我的系统上)会提高性能吗?我们有一台服务器,当某些进程开始运行时,它有时会表现出非常差的外壳性能(例如ls -l执行需要10-15秒),如果将此数字设置得更高将导致更好的外壳性能?

My second question: does setting this memory to something higher than 4MB (on my system) leads to better performance? We have a server which occasionally exhibit very poor shell performance (e.g. ls -l takes 10-15 seconds to execute) when certain processes get going and if setting this number to something higher will lead to better shell performance?

推荐答案

(链接已消失,看起来现在是

(link is dead, looks like it's now here)

该文本指的是原子分配,这是在不放弃控制的情况下必须满足的内存请求(即,当前线程不能被挂起).这种情况最经常发生在中断例程中,但是它适用于在持有基本锁的同时需要内存的所有情况.这些分配必须是即时的,因为您无法等待交换器释放内存.

That text is referring to atomic allocations, which are requests for memory that must be satisfied without giving up control (i.e. the current thread can not be suspended). This happens most often in interrupt routines, but it applies to all cases where memory is needed while holding an essential lock. These allocations must be immediate, as you can't afford to wait for the swapper to free up memory.

有关更详尽的说明,请参见 Linux-MM ,但这是内存分配简而言之:

See Linux-MM for a more thorough explanation, but here is the memory allocation process in short:

  • _alloc_pages首先在每个内存区域上进行迭代,以查找第一个包含合格空闲页面的区域
  • _alloc_pages然后唤醒kswapd任务[..to ..]进入为每个区域维护的保留内存池.
  • 如果内存分配仍未成功,则_alloc页面将放弃[..] 在此过程中,_alloc_pages执行cond_resched()可能会导致睡眠,这就是为什么此分支禁止通过以下方式进行分配的原因GFP_ATOMIC .
  • _alloc_pages first iterates over each memory zone looking for the first one that contains eligible free pages
  • _alloc_pages then wakes up the kswapd task [..to..] tap into the reserve memory pools maintained for each zone.
  • If the memory allocation still does not succeed, _alloc pages will either give up [..] In this process _alloc_pages executes a cond_resched() which may cause a sleep, which is why this branch is forbidden to allocations with GFP_ATOMIC.

min_free_kbytes不太可能对所描述的"ls -l执行需要10-15秒的时间"有很大帮助.这很可能是由于一般的内存压力和交换而不是区域耗尽而引起的. min_free_kbytes设置仅需要允许足够的可用页面来处理即时请求.恢复正常操作后,即可运行交换进程以重新平衡内存区域.我唯一需要增加min_free_kbytes的时间是在不支持dma散射的网卡上启用巨型帧之后.

min_free_kbytes is unlikely to help much with the described "ls -l takes 10-15 seconds to execute"; that is likely caused by general memory pressure and swapping rather than zone exhaustion. The min_free_kbytes setting only needs to allow enough free pages to handle immediate requests. As soon as normal operation is resumed, the swapper process can be run to rebalance the memory zones. The only time I've had to increase min_free_kbytes is after enabling jumbo frames on a network card that didn't support dma scattering.

稍微扩展一下您的第二个问题,调整链接文章中提到的vm.swappiness和脏率将获得更好的结果.但是,请注意,针对"ls -l"性能进行优化可能会导致其他进程变慢.永远不要针对非主要用例进行优化.

To expand on your second question a bit, you will have better results tuning vm.swappiness and the dirty ratios mentioned in the linked article. However, be aware that optimizing for "ls -l" performance may cause other processes to become slower. Never optimize for a non-primary usecase.

这篇关于vm/min_free_kbytes-为什么要保留最小的保留内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆