KSM is using about 30% of CPU time

Taliesin

New Member
Feb 11, 2010
18
0
1
Hi,

after upgrading to newest proxmox with ksm we've noticed increased load on host about 2 times more than before,. Top shows that ksmd eats abou 40-50 % of CPU.

4 x Intel(R) Xeon(R) CPU E5405 @ 2.00GHz
4GB RAM
Hardware raid5 SAS disks

unta:~# pveperf /var/lib/vz
CPU BOGOMIPS: 15960.68
REGEX/SECOND: 657810
HD SIZE: 447.11 GB (/dev/mapper/pve-data)
BUFFERED READS: 102.19 MB/sec
AVERAGE SEEK TIME: 6.18 ms
FSYNCS/SECOND: 700.82
DNS EXT: 80.26 ms
DNS INT: 48.44 ms


its a feature or it's a bug ?

unta:~# pveversion -v
pve-manager: 1.5-9 (pve-manager/1.5/4728)
running kernel: 2.6.32-2-pve
proxmox-ve-2.6.32: 1.5-7
pve-kernel-2.6.32-2-pve: 2.6.32-7
qemu-server: 1.1-14
pve-firmware: 1.0-4
libpve-storage-perl: 1.0-12
vncterm: 0.9-2
vzctl: 3.0.23-1pve10
vzdump: 1.2-5
vzprocps: 2.0.11-1dso2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.12.3-1
ksm-control-daemon: 1.0-3
 
Same behaviour here while using Kernel 2.6.32-pve (on a dual core Intel):

ksmd uses between 25% and 35% of cpu disregarding actual load on the VM's

model name : Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00GHz

pve-manager: 1.5-8 (pve-manager/1.5/4674)
running kernel: 2.6.32-1-pve
proxmox-ve-2.6.32: 1.5-4
pve-kernel-2.6.32-1-pve: 2.6.32-4
pve-kernel-2.6.24-9-pve: 2.6.24-18
pve-kernel-2.6.24-8-pve: 2.6.24-16
qemu-server: 1.1-11
pve-firmware: 1.0-3
libpve-storage-perl: 1.0-10
vncterm: 0.9-2
vzctl: 3.0.23-1pve8
vzdump: 1.2-5
vzprocps: 2.0.11-1dso2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.11.1-2
ksm-control-daemon: 1.0-3

?This seems to be a known bug? See
https://bugzilla.redhat.com/show_bug.cgi?id=541230
 
Last edited:
hi
just verified it - all machines on same release - bug exists - any solution here?

pve-manager: 1.5-8 (pve-manager/1.5/4674)
running kernel: 2.6.32-1-pve
proxmox-ve-2.6.32: 1.5-4
pve-kernel-2.6.32-1-pve: 2.6.32-4
pve-kernel-2.6.18-2-pve: 2.6.18-5
qemu-server: 1.1-11
pve-firmware: 1.0-3
libpve-storage-perl: 1.0-10
vncterm: 0.9-2
vzctl: 3.0.23-1pve8
vzdump: 1.2-5
vzprocps: 2.0.11-1dso2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.11.1-2
ksm-control-daemon: 1.0-3
 
hi
just verified it - all machines on same release - bug exists - any solution here?

Sorry, but this is expected behavior - KSM need to scan the whole memory all the time, so this need CPU (how much can be controlled in the KSM configuration).
 
after upgrading to newest proxmox with ksm we've noticed increased load on host about 2 times more than before,. Top shows that ksmd eats abou 40-50 % of CPU.

KSM is quite new, so I guess they changed something in the internal implementation. But you can try to tune /etc/ksmtuned.conf
 
hello,
any proxmox best-practices / suggestions for the ksmtuned.conf?

No, because this is totally dependend on your workload.

Note: RAM is cheap - so KSM does not always have advantages. The question is what consumes more power - KSM with increased CPU load, or additional RAM(hardware), ....
 
Well, good point.
What is the proper way to disable ksmd? Fallback to the 2.6.24 kernel? Or can it be switched on and off according to someones needs?
 
I was using previous 2.6.32 kernel with ksmd, and saw KSM using 50-60% of CPU.

I recently upgraded to new proxmox 2.6.32-2 kernel with KVM 0.12.4, and I hardly see ksmd now in top (so less than 0.1%), as reported in another thread.

Perhaps new kernels solved a bug, use a different configuration than previous ones ?

Alain
 
For me the update was no solution. I switch it off, because the cpu consumption in top was 70% and more with 3 vm's.
Code:
# uname -r
2.6.32-2-pve
# kvm -version
QEMU PC emulator version 0.12.4 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard
# pveversion 
pve-manager/1.5/4728
Best Regards
 
Same versions here, but KSM is running with default configuration :
# ps aux |grep ksm
root 150 0.0 0.0 0 0 ? SN May23 0:00 [ksmd]
root 16836 0.0 0.0 17396 904 ? S May23 0:01 /bin/bash /usr/sbin/ksmtuned

But in top :
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
17039 root 20 0 2250m 2.0g 1460 S 14 8.6 364:55.70 kvm
17322 root 20 0 773m 527m 1524 S 10 2.2 239:08.49 kvm
17350 root 20 0 449m 113m 1500 S 6 0.5 99:44.55 kvm
....

KSM was previously first in the list, with 50-60% of CPU usage.

I could have also turned off KSM as this machine has 24 GB RAM and I am using only ~6 GB for VMs, but I would like to add more machine in the future (with some 2008 servers) and KSM could help, so I would be happy if it was working well.
 
Same versions here, but KSM is running with default configuration : (...)
What's your default configuration?

My /etc/ksmtuned.conf looks like this:
Code:
# cat /etc/ksmtuned.conf
# 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
It seemed very default. :confused:

Best Regards
 
It is exactly the same. I don't know why it works differently in my case than in yours. Perhaps you are using relatively more memory for your VMs ? Perhaps something changed in newer releases, not using KSM when there is a lot a of memory still available ?

Alain
 
Then, there was a problem previously. ksmd was using a lot of CPU on my three servers, even if there was a lot of memory available. I am not sure it was the default behaviour...
 
That is the default behavior!
I've update from the default Kernel 2.6.18 Proxmox 1.5 to the Kernel 2.6.32. Memory size is 16 GB, 2 vm's have 1GB each, one vm 4GB.
After reboot KSM was running per default with approx. 60-70% CPU-load in top.

Best Regards
 

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!