Enable Kernel shared Memory (KSM) on PowerKVM

Kernel Same-page Merge (KSM) is process which allows VM’s to share identical memory pages. By sharing pages, the combined memory usage of the guest is reduced. The savings are especially increased when multiple guests are running similar base operating system images.

1) Check if KSM is installed or not.

[root@powerkvm ~]# rpm -qa|grep ksm
ksm-2.0.0-2.1.pkvm2_1_1.20.38.ppc64
[root@powerkvm ~]#

2) KSMtuned status ( To control/tune KSM Services)

[root@powerkvm ~]# service ksmtuned status
Redirecting to /bin/systemctl status  ksmtuned.service
ksmtuned.service – Kernel Samepage Merging (KSM) Tuning Daemon
Loaded: loaded (/usr/lib/systemd/system/ksmtuned.service; enabled)
Active: active (running) since Wed 2014-10-22 01:41:11 PDT; 2 days ago
Process: 14123 ExecStart=/usr/sbin/ksmtuned (code=exited, status=0/SUCCESS)
Main PID: 14172 (ksmtuned)
CGroup: name=systemd:/system/ksmtuned.service
├─ 14172 /bin/bash /usr/sbin/ksmtuned
└─195606 sleep 60

[root@powerkvm4 ~]#

stop/start of KSM tuned :

service ksmtuned start

service ksmtuned stop

3) KSM Service

KSM is included in powerkvm package as shown in                                                            /boot/config-3.10.42-2017.1.pkvm2_1_1.44.ppc64

CONFIG_KSM=y

By default KSM is not started.  To view/start ksm service

[root@powerkvm ~]# cat /sys/kernel/mm/ksm/run
0

If the output is a 0, then enable ksm by running this command:

echo 1 > /sys/kernel/mm/ksm/run

4) Customize KSM tuned configure

User can set options for KSM in the /etc/ksmtuned.conf file

# 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=300
# KSM_NPAGES_DECAY=-50
# KSM_NPAGES_MIN=64
# KSM_NPAGES_MAX=1250

# KSM_THRES_COEF=20
# KSM_THRES_CONST=2048

# uncomment the following if you want ksmtuned debug info

# LOGFILE=/var/log/ksmtuned
# DEBUG=1

5) Monitor KSM

cd /sys/kernel/mm/ksm

pages_shared
The number of pages that have been merged.
pages_sharing
The number of virtual pages that are sharing a single page.
pages_unshared
Number of pages that are candidate to be shared but are not currently shared.
pages_volatile
Number of pages that are candidate to be shared but are changed frequently. These pages are not merged.
full_scan
Number of times that KSM has scanned for duplicated content
merge_across_nodes
Allows merging across NUMA nodes.
pages_to_scan
Number of pages to scan at a time. Setting this to a high value can impact performance.
sleep_milisecs
Amount of time between scans.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s