Jump to content

KSM (Kernel Samepage Merging) Questions


Rhynri

Recommended Posts

Posted

KVM Wiki Page on KSM

 

I see some of the files noted here present in the file system, but they are all zeroed, so I can't really tell if it is enabled or not.

 

  • If it isn't, why not, and how can one enable it? 
  • If it is, how do I instruct it to watch the memory space of my VMs, which are highly duplicated?

 

Thanks!

  • 3 weeks later...
Posted

We have ksm enable as we have the directory

/sys/kernel/mm/ksm

 

This isn't something I have tested myself but to test try making multiple VMS of the same os. So its using at least 60% memory of the server. I don't think KSM will run until more than 60% of memory is used it may be more.

You will be able to see if it is running by using the command

cat /sys/kernel/mm/ksm/run

If it is running it will return a 1 if not a 0

If it is running you can see how many pages are being shared among the guests by running the command

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

 

One other thing you will need to do.

You will see in the XML of the VMS the following lines

  <memoryBacking>
    <nosharepages/>
  </memoryBacking>

The   <nosharepages/>  stops that guest from using ksm so you would need to remove that from the XML of each guest for those guest to use ksm.

You can use memory ballooning to overprovision memory too if that helps your use-case.

Hopefully someone here more knowledgable than me may read this and give you some better info.


 

Posted

Thanks for taking a look.  I really appreciate the response.  My VM's indeed had the XML lines you posted, which I am guessing is why I've never seen any KSM activity. I'll test and let you know how it goes.  I'd rather just add 32GB of ram to the machine (or more) so each one can have an actual 16GB, but as you are probably well aware, the price of ram is insane at the moment.  

Posted

Hello Gridrunner,

 

For me the value in 

/sys/kernel/mm/ksm/run

was zero, but you can echo a 1 there to enable KSM.  I haven't seen much benefit as it seems as though it still might not be working in the VMs.  I'll keep working at it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...