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
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)
├─ 14172 /bin/bash /usr/sbin/ksmtuned
└─195606 sleep 60
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
By default KSM is not started. To view/start ksm service
[root@powerkvm ~]# cat /sys/kernel/mm/ksm/run
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
# Millisecond sleep between ksm scans for 16Gb server.
# Smaller servers sleep more, bigger sleep less.
# uncomment the following if you want ksmtuned debug info
5) Monitor KSM
- The number of pages that have been merged.
- The number of virtual pages that are sharing a single page.
- Number of pages that are candidate to be shared but are not currently shared.
- Number of pages that are candidate to be shared but are changed frequently. These pages are not merged.
- Number of times that KSM has scanned for duplicated content
- Allows merging across NUMA nodes.
- Number of pages to scan at a time. Setting this to a high value can impact performance.
- Amount of time between scans.