KSM doesn't work

floh79

Member
Jun 30, 2019
29
0
6
44
Hello,
I'm trying since 1 week and still didn't succeed to get ksm working.

I have 4 containers (6GB RAM each) based on Debian 9 (same as Proxmox is installed on) and on each there are jira and confluence installed. I enabled ksm but proxmox still tells me "KSM Sharing 0B".

Even the memory usage of the host was 95% of 16GB.

What could it be wrong?

Here are outputs, maybe you have some idea and could help me please?
Code:
root@bigboss:~# grep KSM /boot/config-`uname -r`
CONFIG_KSM=y
root@bigboss:~# grep -H '' /sys/kernel/mm/ksm/*
/sys/kernel/mm/ksm/full_scans:0
/sys/kernel/mm/ksm/max_page_sharing:256
/sys/kernel/mm/ksm/merge_across_nodes:1
/sys/kernel/mm/ksm/pages_shared:0
/sys/kernel/mm/ksm/pages_sharing:0
/sys/kernel/mm/ksm/pages_to_scan:1250
/sys/kernel/mm/ksm/pages_unshared:0
/sys/kernel/mm/ksm/pages_volatile:0
/sys/kernel/mm/ksm/run:1
/sys/kernel/mm/ksm/sleep_millisecs:10
/sys/kernel/mm/ksm/stable_node_chains:0
/sys/kernel/mm/ksm/stable_node_chains_prune_millisecs:2000
/sys/kernel/mm/ksm/stable_node_dups:0
/sys/kernel/mm/ksm/use_zero_pages:0
root@bigboss:~# ps aux | grep ksm
root        42  0.0  0.0      0     0 ?        SN   Jun28   0:00 [ksmd]
root     25408  0.0  0.0  12784  1028 pts/3    S+   21:34   0:00 grep ksm
root@bigboss:~# systemctl status ksm.service
● ksm.service - Kernel Samepage Merging
   Loaded: loaded (/lib/systemd/system/ksm.service; enabled; vendor preset: enabled)
   Active: active (exited) since Sun 2019-06-30 21:44:29 CEST; 17s ago
  Process: 31202 ExecStop=/usr/sbin/ksmctl stop (code=exited, status=0/SUCCESS)
  Process: 31209 ExecStart=/usr/sbin/ksmctl start (code=exited, status=0/SUCCESS)
 Main PID: 31209 (code=exited, status=0/SUCCESS)
      CPU: 1ms

Jun 30 21:44:29 bigboss systemd[1]: Starting Kernel Samepage Merging...
Jun 30 21:44:29 bigboss systemd[1]: Started Kernel Samepage Merging.
root@bigboss:~# free
              total        used        free      shared  buff/cache   available
Mem:       16425336    12704008      223728      139716     3497600     3239744
Swap:       3906556     2121588     1784968

Currently I'm using Proxmox Virtual Environment 5.4-7.

Best regards
Floh
 
KSM start at least 80% of RAM usage. Could you post a Screenshot from your PVE Overview.

KSM try to merge same pages, in your case of a jira and confluence application, maybe its not really possible because of use of Java, which can very different between all of your Container.
 
Hi,
I see but all of them are using exactly the same version of Java and Jira/Confluence. Also on 5 Container there are same version of mysql-server (mariadb) running, so these should be candidate for sharing memory (libraries). 3 of them have nginx-instance.

Here I attached screenshot. Is it that, what you wanted? There you can see memory usage is over 90% but still 0B Shared page. Sorry, I had to censore some container names because of data protection.

cu Floh
 

Attachments

  • PromoxKSMNotworking.png
    PromoxKSMNotworking.png
    49.1 KB · Views: 22
Already installed, I tried with both packages (not both at same time!) ksmtuned / ksm-control-daemon.

When I did post initially ksmtuned was actually not running but now it does but still didn't help:
Code:
root@bigboss:~# ps aux | grep ksm
root        42  0.0  0.0      0     0 ?        SN   Jun28   0:00 [ksmd]
root     25085  0.0  0.0  19704  2804 ?        S    23:01   0:00 /bin/bash /usr/sbin/ksmtuned
root     28153  0.0  0.0  12784   972 pts/6    S+   23:05   0:00 grep ksm

cu Floh
 
Ballon and qemu agent on VPS?
Worked with my KVM quest
gq2uU5S.png
 
What do you mean with VPS? Do you mean my containers* or the host itself?

*) There is no VM running on my Proxmox.
 
Just found out... after some time the run-file is set back to 0. What could be the cause?
Code:
root@bigboss:~# cat /sys/kernel/mm/ksm/run
0
root@bigboss:~# echo 1 > /sys/kernel/mm/ksm/run
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
1
root@bigboss:~# cat /sys/kernel/mm/ksm/run
0
Are there a way to turn on log for ksmd?

UPDATE: Never mind, its caused by ksmtuned because I just rebooted host and memory wasn't 80% yet when I was examing. :D

cu Floh
 
Short:
KVM/QEMU is optimised for KSM, everything else is not and will therefore not work.

Long:
The official documentation states when it works and when not: https://www.kernel.org/doc/Documentation/vm/ksm.txt

KSM only operates on those areas of address space which an application
has advised to be likely candidates for merging, by using the madvise(2)
system call: int madvise(addr, length, MADV_MERGEABLE).​
 
It seems that KSM does not support LxC type VM optimization. I wonder if there is any other solution?
 
It seems that KSM does not support LxC type VM optimization. I wonder if there is any other solution?

AS far as I understand this, LXC uses kernel namespaces and KSM does not cross namespace borders, so two same pages from two different namespaces are not merged.
 

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!