ksm

Manages Linux Kernel Samepage Merging (KSM)

Joshua Hoblitt

jhoblitt

9,278 downloads

9,278 latest version

3.9 quality score

Version information

  • 0.0.1 (latest)
released Oct 10th 2013

Start using this module

Documentation

jhoblitt/ksm — version 0.0.1 Oct 10th 2013

Puppet ksm Module

Build Status

Table of Contents

  1. Overview
  2. Description
  3. Words of Caution
  4. Usage
  5. Limitations
  6. Support
  7. See Also

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