8.3.2. KSM 调整服务
ksmtuned 服务通过循环和调整 ksm,对内核相同的页面合并(KSM)配置进行微调。另外,当创建虚拟机或销毁时,libvirt 会通知 ksmtuned 服务。ksmtuned 服务没有选项。
# systemctl start ksmtuned
Starting ksmtuned: [ OK ]
可以使用
retune 参数调优 ksmtuned 服务,该参数指示 ksmtuned 手动运行调优功能。
/etc/ksmtuned.conf 文件是 ksmtuned 服务的配置文件。下面的文件输出是默认的 ksmtuned.conf 文件:
# Configuration file for ksmtuned.
# How long ksmtuned should sleep between tuning adjustments
# KSM_MONITOR_INTERVAL=60
# Millisecond sleep between ksm scans for 16Gb server.
# Smaller servers sleep more, bigger sleep less.
# KSM_SLEEP_MSEC=10
# KSM_NPAGES_BOOST - is added to the `npages` value, when `free memory` is less than `thres`.
# KSM_NPAGES_BOOST=300
# KSM_NPAGES_DECAY - is the value given is subtracted to the `npages` value, when `free memory` is greater than `thres`.
# KSM_NPAGES_DECAY=-50
# KSM_NPAGES_MIN - is the lower limit for the `npages` value.
# KSM_NPAGES_MIN=64
# KSM_NPAGES_MAX - is the upper limit for the `npages` value.
# KSM_NPAGES_MAX=1250
# KSM_THRES_COEF - is the RAM percentage to be calculated in parameter `thres`.
# KSM_THRES_COEF=20
# KSM_THRES_CONST - If this is a low memory system, and the `thres` value is less than `KSM_THRES_CONST`, then reset `thres` value to `KSM_THRES_CONST` value.
# KSM_THRES_CONST=2048
# uncomment the following to enable ksmtuned debug information
# LOGFILE=/var/log/ksmtuned
# DEBUG=1
在
/etc/ksmtuned.conf 文件中,npages 设置 ksm 在 ksm d 守护进程变为 inactive 之前将扫描多少页。这个值也会在 /sys/kernel/mm/ksm/pages_to_scan 文件中设置。
KSM_THRES_CONST 值代表激活 ksm 的可用内存量。如果发生以下情况之一,则激活 ksmd :
- 可用内存量低于阈值,在
KSM_THRES_CONST中设置。 - 所提交的内存量加上阈值
KSM_THRES_CONST超过总内存量。