KSM on Proxmox

listerthrawn

New Member
Jan 14, 2010
19
1
1
Manchester, UK
Hi,

I'm using 1.5 and have just installed the right kernel to let me use it, but I notice that it's not being used. Do I need to do anything special to use KSM or should it 'just work'?

I have 2 Win2k3 servers running and no memory is being shared.

Code:
pve01:~# cat /sys/kernel/mm/ksm/pages_shared 
0
pve01:~#


Thanks

Chris

Code:
pve-manager: 1.5-5 (pve-manager/1.5/4627)
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-1-pve: 2.6.18-4
qemu-server: 1.1-11
pve-firmware: 1.0-3
libpve-storage-perl: 1.0-8
vncterm: 0.9-2
vzctl: 3.0.23-1pve6
vzdump: 1.2-5
vzprocps: 2.0.11-1dso2
vzquota: 3.0.11-1
pve-qemu-kvm: 0.11.1-1
ksm-control-daemon: 1.0-2
 
Hi,

I'm using 1.5 and have just installed the right kernel to let me use it, but I notice that it's not being used. Do I need to do anything special to use KSM or should it 'just work'?

It should start as soon as you use more than half of your physical memory.
 
Hi,

It hasn't reduced any actually.

I've upped the memory on my 2 servers to 4Gig each (10Gig in the server) and it's showing 8Gig used. The servers are just vanilla installs, no apps installed so they aren't using much.

I'm right in thinking that this is expected for Windows servers because they zero out the memory aren't i?

Still zero shared pages...

Thanks
 
Well,

I've done nothing but go out for lunch and when I've come back it's working. 8Gb of server memory but using only 800Mb of system memory.

Lovely...

Thanks for your help.
 
It should start as soon as you use more than half of your physical memory.

/usr/sbin/ksmtuned script has a hardcoded "qemu" binary name - where Proxmox VE uses "kvm" binary.

So this code will never give any results:

Code:
committed_memory () {
    # calculate how much memory is committed to running qemu processes
    local progname
    progname=${1:-qemu}
    ps -o vsz `pgrep $progname` | awk '{ sum += $1 }; END { print sum }'
}
 
Hmm, do we need this?

Code:
--- /usr/sbin/ksmtuned.orig     2010-02-01 13:03:29.000000000 +0100
+++ /usr/sbin/ksmtuned  2010-02-01 13:16:15.000000000 +0100
@@ -63,7 +63,7 @@
 committed_memory () {
     # calculate how much memory is committed to running qemu processes
     local progname
-    progname=${1:-qemu}
+    progname=${1:-kvm}
     ps -o vsz `pgrep $progname` | awk '{ sum += $1 }; END { print sum }'
 }
 
That code looks quite buggy - especially when pgrep returns an empty string.

It returns an empty string when "qemu" is there. With "kvm", it works fine:

++ committed_memory
++ local progname
++ progname=kvm
++ awk '{ sum += $1 }; END { print sum }'
+++ pgrep kvm
++ ps -o vsz 3721 3961 3991 4020 4051 4071 4102 4120
 
Yes, because pgrep always finds [kvm-irqfd-clean] - not sure it that is the intention.

It's not intended - as in original ksmtuned, the script looks for "qemu".

Here, we look for "kvm" processes, and find "kvm-irqfd-clean", too.

However as kvm-irqfd-clean is a kernel thread, "ps -o vsz" for this process returns 0 VSZ, so it's "neutral".


We might well use this to get rid of "kvm-irqfd-clean" and make sure only "kvm" is matched :

Code:
--- /usr/sbin/ksmtuned.orig     2010-02-01 13:03:29.000000000 +0100
+++ /usr/sbin/ksmtuned  2010-02-01 14:34:30.000000000 +0100
@@ -63,8 +63,8 @@
 committed_memory () {
     # calculate how much memory is committed to running qemu processes
     local progname
-    progname=${1:-qemu}
-    ps -o vsz `pgrep $progname` | awk '{ sum += $1 }; END { print sum }'
+    progname=${1:-kvm}
+    ps -o vsz `pgrep -x $progname` | awk '{ sum += $1 }; END { print sum }'
 }

 free_memory () {
 
And even better:

Code:
committed_memory () {
    # calculate how much memory is committed to running qemu processes
    local progname
    progname=${1:-kvm}
    local plist
    plist=$(pgrep -d ' ' -x $progname);
    [ -z "$plist" ] && echo 0 && return
    ps -o vsz $plist | awk '{ sum += $1 }; END { print sum }'
}
 

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!