有没有熟悉 Linux 内核的人指点一下 vm.dirty_background_ratio 和 vm.dirty_ratio 的疑问?

2018-03-14 21:14:38 +08:00
 jones
最近在搞 Linux 内核优化,对写缓冲这方面的内核参数有点儿疑问,请熟悉 Linux 内核的人指点一下:

1、vm.dirty_background_ratio

针对这个内核参数,www.kernel.org 给出的官方解释为:
Contains, as a percentage of total available memory that contains free pages
and reclaimable pages, the number of pages at which the background kernel
flusher threads will start writing out dirty data.
The total available memory is not equal to total system memory.
其中重点提到了这个比例是空闲内存的占比(未被使用的内存页和可以被回收的内存页),而不是系统内存总量的占比

但是 RedHat 官方的调优文档中,又给出了另一层意思,如下:
Defines a percentage value. Writeout of dirty data begins in the background (via pdflush) when dirty data comprises this percentage of total memory. The default value is 10. For database workloads, Red Hat recommends a lower value of 3.
RedHat 官方的意思是 total memory,这个指什么,系统内存总量还是空闲内存呢?

2、vm. dirty_ratio

针对这个内核参数,www.kernel.org 给出的官方解释为:
Contains, as a percentage of total available memory that contains free pages
and reclaimable pages, the number of pages at which a process which is
generating disk writes will itself start writing out dirty data.
The total available memory is not equal to total system memory.
其中也强调了这个比例是空闲内存的占比而不是系统内存总量占比

RedHat 官方调优文档中的说明如下:
Defines a percentage value. Writeout of dirty data begins (via pdflush) when dirty data comprises this percentage of total system memory. The default value is 20.
Red Hat recommends a slightly lower value of 15 for database workloads.
RedHat 官方的意思是 total system memory,这个明显指的就是系统内存总量了吧

我想确认的是,这两个参数的比例到底是针对系统内存总量还是空闲内存总量呢? Google 半天也没找到一个确切的说法,都是众说纷纭,不知道该相信哪一个,有没有熟悉内核源码的 V 友帮忙从源码角度给定性一下呢,提前感谢了。

参考文档地址:
https://www.kernel.org/doc/Documentation/sysctl/vm.txt
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-memory-tunables
3342 次点击
所在节点    Linux
2 条回复
jyf007
2018-03-15 09:38:37 +08:00
抱歉,我不熟,我只知道 bbr
tomychen
2018-03-20 18:03:57 +08:00
物理内存总量

其实可以做测试的

sysctl 指定两个指后用 dd 写入

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/438095

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX