Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

8.4.2. The KSM Tuning Service

The ksmtuned service fine-tunes the kernel same-page merging (KSM) configuration by looping and adjusting ksm. In addition, the ksmtuned service is notified by libvirt when a guest virtual machine is created or destroyed. The ksmtuned service has no options.
# systemctl start ksmtuned
Starting ksmtuned:                                         [  OK  ]
The ksmtuned service can be tuned with the retune parameter, which instructs ksmtuned to run tuning functions manually.
The /etc/ksmtuned.conf file is the configuration file for the ksmtuned service. The file output below is the default ksmtuned.conf file:
# Configuration file for ksmtuned.
# How long ksmtuned should sleep between tuning adjustments

# Millisecond sleep between ksm scans for 16Gb server.
# Smaller servers sleep more, bigger sleep less.

# KSM_NPAGES_BOOST - is added to the `npages` value, when `free memory` is less than `thres`.

# KSM_NPAGES_DECAY - is the value given is subtracted to the `npages` value, when `free memory` is greater than `thres`.

# KSM_NPAGES_MIN - is the lower limit for the `npages` value.

# KSM_NPAGES_MAX - is the upper limit for the `npages` value.

# KSM_THRES_COEF - is the RAM percentage to be calculated in parameter `thres`.

# 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.

# uncomment the following to enable ksmtuned debug information
# LOGFILE=/var/log/ksmtuned
Within the /etc/ksmtuned.conf file, npages sets how many pages ksm will scan before the ksmd daemon becomes inactive. This value will also be set in the /sys/kernel/mm/ksm/pages_to_scan file.
The KSM_THRES_CONST value represents the amount of available memory used as a threshold to activate ksm. ksmd is activated if either of the following occurs:
  • The amount of free memory drops below the threshold, set in KSM_THRES_CONST.
  • The amount of committed memory plus the threshold, KSM_THRES_CONST, exceeds the total amount of memory.