No pages_sharing (KVM/KSM) after upgrade to 1.9

  • Thread starter Thread starter blender
  • Start date Start date
B

blender

Guest
Hi All,

I posted to the "Proxmox VE 1.9 released!" thread (http://forum.proxmox.com/threads/7023-Proxmox-VE-1-9-released!?p=42921#post42921) but received no replies so I thought I should start a new thread.

I recently upgraded two hosts to 1.9 and on both despite > 50% use of memory pages_sharing = 0.

host1:

host1:~# pveversion -v
pve-manager: 1.9-26 (pve-manager/1.9/6567)
running kernel: 2.6.32-6-pve
proxmox-ve-2.6.32: 1.9-50
pve-kernel-2.6.32-6-pve: 2.6.32-50
qemu-server: 1.1-32
pve-firmware: 1.0-14
libpve-storage-perl: 1.0-19
vncterm: 0.9-2
vzctl: 3.0.29-3pve1
vzdump: 1.2-16
vzprocps: 2.0.11-2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.15.0-1
ksm-control-daemon: 1.0-6

host1:~# free
total used free shared buffers cached
Mem: 12263176 6756768 5506408 0 269912 189720
-/+ buffers/cache: 6297136 5966040
Swap: 11534328 0 11534328

host1:~# cat /sys/kernel/mm/ksm/pages_sharing
0

host2:

host2:~# pveversion -v
pve-manager: 1.9-26 (pve-manager/1.9/6567)
running kernel: 2.6.32-6-pve
proxmox-ve-2.6.32: 1.9-50
pve-kernel-2.6.32-6-pve: 2.6.32-50
qemu-server: 1.1-32
pve-firmware: 1.0-14
libpve-storage-perl: 1.0-19
vncterm: 0.9-2
vzctl: 3.0.29-3pve1
vzdump: 1.2-16
vzprocps: 2.0.11-2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.15.0-1
ksm-control-daemon: 1.0-6

host2:~# free
total used free shared buffers cached
Mem: 8105780 6491120 1614660 0 196584 1985508
-/+ buffers/cache: 4309028 3796752
Swap: 4194296 0 4194296

host2:~# cat /sys/kernel/mm/ksm/pages_sharing
0

Both hosts have CentOS/RHEL guests.

A third host that I haven't updated yet and is running 2.6.35 kernel also with CentOS/RHEL guests has 280,000 shared pages.

Please advise.

Thanks!​


 
Looks like some people think the memory use threshold is 20% and that the documentation is wrong.

So I edited my /etc/ksmtuned.conf:

Code:
KSM_THRES_COEF=50
# KSM_THRES_COEF=20
# KSM_THRES_CONST=2048

And ran /etc/init.d/ksmtuned restart.

But despite using way more than 50% RAM:

Code:
host2:~# free             total       used       free     shared    buffers     cached
Mem:       8105780    7501504     604276          0     229092    1983928
-/+ buffers/cache:    5288484    2817296
Swap:      4194296          0    4194296

pages_sharing is still 0:

host2:~# cat /sys/kernel/mm/ksm/pages_sharing
0


Is this a bug?

Cheers

Edit: I guess it just took a little bit of time.

host2:~# cat /sys/kernel/mm/ksm/pages_sharing
197478

Working now! But it does look like the documentation is wrong.
 
Last edited by a moderator:
ksmtuned does not run KSM the moment it is started.

You have to wait KSM_MONITOR_INTERVAL until it checks to see if it needs to run or not.

If you want to make it always merge pages for the first Interval, even if you have not hit the threshold, you can do that by editing /etc/default/ksmtuned
Add a few lines like this:
Code:
echo "2048" > /sys/kernel/mm/ksm/pages_to_scan
echo "102" > /sys/kernel/mm/ksm/sleep_millisecs
echo 1 > /sys/kernel/mm/ksm/run

You can adjust them to meet your needs.

The above could be handy if you have lots of startup vms with the same OS but not using enough RAM to get KSM to kick in.
 
  • Like
Reactions: Omar Khalil

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!