Version information
Start using this module
Add this module to your Puppetfile:
mod 'jhoblitt-ksm', '0.0.1'
Learn more about managing modules with a PuppetfileDocumentation
Puppet ksm Module
Table of Contents
Overview
Manages Linux Kernel Samepage Merging (KSM)
Description
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.
Words of Caution
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.
Usage
Simple
The defaults are probably acceptable for most use cases.
include ksm
or
class { 'ksm': }
Advanced
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
},
}
Files
The ksmtuned
debugging log is enabled at the path /var/log/ksmtuned
with
logrotate
support.
ksm
# 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:
{}
-
Limitations
At present, only support for $::osfamily == 'RedHat'
has been implemented.
Tested Platforms
- el6.x
Support
Please log tickets and issues at github
See Also
Dependencies
- puppetlabs/stdlib (>= 4.0.0)
- rodjek/logrotate (>= 1.1.1)
Copyright (C) 2013 Joshua Hoblitt <jhoblitt@cpan.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.