How should I configure KSM on a powerful node?

NoSum

New Member
May 15, 2021
27
0
1
36
KSM is constantly using 100% of 1 CPU I am willing to increase that to 500% (5vcpu) if that will give better results.

Node settings: https://i.gyazo.com/32618f24be8a9fb282173cd1ebb9b740.png

Right now I have only KSM_THRES_COEF=70 set in /etc/ksmtuned.conf but I am not sure if that means it will activate at 70% RAM usage or when less than 70% of RAM is free.

It says that I should also modify KSM_SLEEP_MSEC=100 to a lower value as it's a very big server but what do you suggest? and any other modifications?

If it helps most of my linux machines clear unwanted cached RAM every few hours
Code:
sync; echo 3 > /proc/sys/vm/drop_caches

Running
Code:
watch cat /sys/kernel/mm/ksm/pages_sharing
returns:
46220611

The system is also using ZFS with the following settings

Code:
#Max Ram Used by ZFS - 64GB
options zfs zfs_arc_max=68719476736
#Min Ram Used by ZFS - 20GB
options zfs zfs_arc_min=21474836480
 
"KSM_THRES_COEF=70" means KSM will kicks in when RAM utilization exceeds 30% and stops if RAM utilization drops below 30%. I don't got such a big server but I like my KSM to be enabled all the time so its always using a little bit of CPU usage instead of creating big CPU usage spikes every time KSM is switching on and off.
 
"KSM_THRES_COEF=70" means KSM will kicks in when RAM utilization exceeds 30% and stops if RAM utilization drops below 30%. I don't got such a big server but I like my KSM to be enabled all the time so its always using a little bit of CPU usage instead of creating big CPU usage spikes every time KSM is switching on and off.
Thanks for the reply and clarifying KSM_THRES_COEF but I noticed ksmd has been using 100% CPU usage non stop since around 200GB RAM usage which makes me think I need to optimize the settings?
 
Something is not right I just created a virtual machine with 100GB RAM and ran the following to reach 100% usage

Code:
stress-ng --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1

total nodes usage went from 700GB to 800GB but after turning the VPS off it's not taking the RAM back and KSM sharing is not moving from 175GB for over 24 hours.

watch cat /sys/kernel/mm/ksm/pages_sharing

Is also still returning a number near 46220611

Some loggin

Code:
Wed 26 May 2021 08:50:47 AM UTC: total 1052255960
Wed 26 May 2021 08:50:47 AM UTC: sleep 10
Wed 26 May 2021 08:50:47 AM UTC: thres 736579172
Wed 26 May 2021 08:51:47 AM UTC: committed 2289615116 free 216561296
Wed 26 May 2021 08:51:48 AM UTC: 3026194288 > 1052255960, start ksm
Wed 26 May 2021 08:51:48 AM UTC: 216561296 < 736579172, boost
Wed 26 May 2021 08:51:48 AM UTC: KSMCTL start 300 10
Wed 26 May 2021 08:52:48 AM UTC: committed 2289238100 free 218762984
Wed 26 May 2021 08:52:48 AM UTC: 3025817272 > 1052255960, start ksm
Wed 26 May 2021 08:52:48 AM UTC: 218762984 < 736579172, boost
Wed 26 May 2021 08:52:49 AM UTC: KSMCTL start 600 10
Wed 26 May 2021 08:53:49 AM UTC: committed 2290074092 free 218896568
Wed 26 May 2021 08:53:49 AM UTC: 3026653264 > 1052255960, start ksm
Wed 26 May 2021 08:53:49 AM UTC: 218896568 < 736579172, boost
Wed 26 May 2021 08:53:50 AM UTC: KSMCTL start 900 10
Wed 26 May 2021 08:54:50 AM UTC: committed 2289664292 free 218652736
Wed 26 May 2021 08:54:50 AM UTC: 3026243464 > 1052255960, start ksm
Wed 26 May 2021 08:54:50 AM UTC: 218652736 < 736579172, boost
Wed 26 May 2021 08:54:52 AM UTC: KSMCTL start 1200 10
Wed 26 May 2021 08:55:52 AM UTC: committed 2289721664 free 217945952
Wed 26 May 2021 08:55:52 AM UTC: 3026300836 > 1052255960, start ksm
Wed 26 May 2021 08:55:52 AM UTC: 217945952 < 736579172, boost
Wed 26 May 2021 08:55:53 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 08:56:53 AM UTC: committed 2290246208 free 217886164
Wed 26 May 2021 08:56:53 AM UTC: 3026825380 > 1052255960, start ksm
Wed 26 May 2021 08:56:53 AM UTC: 217886164 < 736579172, boost
Wed 26 May 2021 08:56:55 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 08:57:55 AM UTC: committed 2289549548 free 217958044
Wed 26 May 2021 08:57:55 AM UTC: 3026128720 > 1052255960, start ksm
Wed 26 May 2021 08:57:55 AM UTC: 217958044 < 736579172, boost
Wed 26 May 2021 08:57:59 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 08:58:59 AM UTC: committed 2290615028 free 217754256
Wed 26 May 2021 08:58:59 AM UTC: 3027194200 > 1052255960, start ksm
Wed 26 May 2021 08:58:59 AM UTC: 217754256 < 736579172, boost
Wed 26 May 2021 08:59:00 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:00:00 AM UTC: committed 2290197032 free 217222556
Wed 26 May 2021 09:00:00 AM UTC: 3026776204 > 1052255960, start ksm
Wed 26 May 2021 09:00:00 AM UTC: 217222556 < 736579172, boost
Wed 26 May 2021 09:00:01 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:01:01 AM UTC: committed 2289467588 free 216152600
Wed 26 May 2021 09:01:01 AM UTC: 3026046760 > 1052255960, start ksm
Wed 26 May 2021 09:01:01 AM UTC: 216152600 < 736579172, boost
Wed 26 May 2021 09:01:03 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:02:03 AM UTC: committed 2290008524 free 216580264
Wed 26 May 2021 09:02:03 AM UTC: 3026587696 > 1052255960, start ksm
Wed 26 May 2021 09:02:03 AM UTC: 216580264 < 736579172, boost
Wed 26 May 2021 09:02:04 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:03:04 AM UTC: committed 2289976852 free 216641912
Wed 26 May 2021 09:03:04 AM UTC: 3026556024 > 1052255960, start ksm
Wed 26 May 2021 09:03:04 AM UTC: 216641912 < 736579172, boost
Wed 26 May 2021 09:03:06 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:04:06 AM UTC: committed 2289370516 free 215958752
Wed 26 May 2021 09:04:06 AM UTC: 3025949688 > 1052255960, start ksm
Wed 26 May 2021 09:04:06 AM UTC: 215958752 < 736579172, boost
Wed 26 May 2021 09:04:07 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:05:07 AM UTC: committed 2289804904 free 216888460
Wed 26 May 2021 09:05:07 AM UTC: 3026384076 > 1052255960, start ksm
Wed 26 May 2021 09:05:07 AM UTC: 216888460 < 736579172, boost
Wed 26 May 2021 09:05:11 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:06:11 AM UTC: committed 2289624592 free 215972476
Wed 26 May 2021 09:06:11 AM UTC: 3026203764 > 1052255960, start ksm
Wed 26 May 2021 09:06:11 AM UTC: 215972476 < 736579172, boost
Wed 26 May 2021 09:06:14 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:07:14 AM UTC: committed 2289968824 free 216036648
Wed 26 May 2021 09:07:14 AM UTC: 3026547996 > 1052255960, start ksm
Wed 26 May 2021 09:07:14 AM UTC: 216036648 < 736579172, boost
Wed 26 May 2021 09:07:14 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:08:14 AM UTC: committed 2290001608 free 216453416
Wed 26 May 2021 09:08:14 AM UTC: 3026580780 > 1052255960, start ksm
Wed 26 May 2021 09:08:14 AM UTC: 216453416 < 736579172, boost
Wed 26 May 2021 09:08:15 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:09:15 AM UTC: committed 2289854080 free 216587464
Wed 26 May 2021 09:09:15 AM UTC: 3026433252 > 1052255960, start ksm
Wed 26 May 2021 09:09:15 AM UTC: 216587464 < 736579172, boost
Wed 26 May 2021 09:09:15 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:10:15 AM UTC: committed 2289395104 free 216389728
Wed 26 May 2021 09:10:15 AM UTC: 3025974276 > 1052255960, start ksm
Wed 26 May 2021 09:10:15 AM UTC: 216389728 < 736579172, boost
Wed 26 May 2021 09:10:19 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:11:19 AM UTC: committed 2289452476 free 215518432
Wed 26 May 2021 09:11:19 AM UTC: 3026031648 > 1052255960, start ksm
Wed 26 May 2021 09:11:19 AM UTC: 215518432 < 736579172, boost
Wed 26 May 2021 09:11:21 AM UTC: KSMCTL start 1250 10
Wed 26 May 2021 09:12:21 AM UTC: committed 2289845884 free 215602796
Wed 26 May 2021 09:12:21 AM UTC: 3026425056 > 1052255960, start ksm
Wed 26 May 2021 09:12:21 AM UTC: 215602796 < 736579172, boost
Wed 26 May 2021 09:12:22 AM UTC: KSMCTL start 1250 10
 
Last edited:
The main issue is ksmd doesn't appear to be able to use multiple threads is there any work arounds? I am unable to find anything in Google searches
 

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!