Manages Linux Kernel Samepage Merging (KSM)
This is a puppet module for configuration of the ksm
and ksmtuned
services
that in turn manage Linux's Kernel Samepage Merging
(KSM) functionality. The KSM subsystem has
broad applicability but is typically used on hosts acting as hypervisor for
KVM virtual machines.
The typical mode of operation is that the ksmtuned
service starts and stops
the ksm
service based configurable heuristics. At present, this is the only
configuration supported by this module.
Documentation on the configuration of ksmtuned
is sparse. There is section
in RHEL6 Virtualization Administration
Guide
but it doesn't provide much help and at least the description of
pages_to_scan
is incorrect.
There is a much more useful explanation in the RHEL6 Solutions site but it is only accessible to customer paying for RHEL support.
Be advised that:
- KSM consumes both CPU time (aka electricity) and memory bandwidth.
- Under at least Linux 2.6.32/RHEL6 KSM merged pages that have been swapped out
are unshared when swapped back in. I suspect I've seen this exacerbate "swap
hell" caused by not adjusting
vm.swappiness
from the default on large memory hosts.
The defaults are probably acceptable for most use cases.
include ksm
or
class { 'ksm': }
This example:
- Disables the default 50% of memory shared page limit (
KSM_MAX_KERNEL_PAGES
) - Changes the interval that
ksmtuned
wakes up at from 60s -> 15s - Changes the default 'free' memory threshold from 20% to 25%
- Changes the default number of pages scanned per KSM cycle (typically 10msec) from 1250 -> 256
class { 'ksm':
ksm_config => {
'KSM_MAX_KERNEL_PAGES' => 0,
},
ksmtuned_config => {
'KSM_MONITOR_INTERVAL' => 15,
'KSM_THRES_COEF' => 25,
'KSM_NPAGES_MAX' => 256
},
}
The ksmtuned
debugging log is enabled at the path /var/log/ksmtuned
with
logrotate
support.
# defaults
class { 'ksm':
ksm_config => {},
ksmtuned_config => {},
}
-
ksm_config
Hash
Options to be set in
/etc/sysconfig/ksm
Valid Keys are:
KSM_MAX_KERNEL_PAGES
defaults to:
{}
-
ksmtuned_config
Hash
Options to be set in
/etc/ksmtuned.conf
Valid Keys are:
KSM_MONITOR_INTERVAL
KSM_SLEEP_MSEC
KSM_NPAGES_BOOST
KSM_NPAGES_DECAY
KSM_NPAGES_MIN
KSM_NPAGES_MAX
KSM_THRES_COEF
KSM_THRES_CONST
defaults to:
{}
At present, only support for $::osfamily == 'RedHat'
has been implemented.
- el6.x
Please log tickets and issues at github