最近在搞 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