Enabling and Tuning KSM

Ref: https://github.com/harvester/harvester/issues/2302

Verify Steps:

  1. Install Harvester with any nodes
  2. Login to Dashboard and Navigate to hosts
  3. Edit node1’s Ksmtuned to Run and ThresCoef to 85 then Click Save
  4. Login to node1’s console, execute kubectl get ksmtuned -oyaml --field-selector metadata.name=<node1>
  5. Fields in spec should be the same as Dashboard configured
  6. Create an image for VM creation
  7. Create multiple VMs with 2Gi+ memory and schedule on <node1> (memory size reflect to ’s maximum size, total of VMs’ memory should greater than 40%)
  8. Execute watch -n1 grep . /sys/kernel/mm/ksm/* to monitor ksm’s status change
    • /sys/kernel/mm/ksm/run should be update to 1 after VMs started
    • /sys/kernel/mm/ksm/page_* should updating continuously
  9. Login to Dashboard then navigate to Hosts, click
  10. In the Tab of Ksmtuned, values in Statistics section should not be 0. (data in this section will be updated per min, so it not equals to console’s output was expected.)
  11. Stop all VMs scheduling to <node1>, the monitor data /sys/kernel/mm/ksm/run should be update to 0 (this is expected as it is designed to dynamically spawn ksm up when ThresCoef hits)
  12. Update ’s Ksmtuned to Run: Prune
  13. Monitor data in Step.8 should reflect to:
    • /sys/kernel/mm/ksm/run should be update to 2
    • /sys/kernel/mm/ksm/pages_* should be update to 0
  14. Update ’s Ksmtuned to Run: Stop
  15. Monitor data in Step.8 should reflect to:
    • /sys/kernel/mm/ksm/run should be update to 0