Monday, April 19, 2021

ksmtuned Is Using High CPU on Oracle Linux 8

 On a server running Oracle Linux 8 I noticed process ksmtuned is using 100% CPU





 

What is ksmtuned for?

ksmtuned is part of Kernel same-page Merging (KSM) service, it's a Linux feature used by KVM hypervisor, it examines the memory allocated by the running programs, if it finds identical memory pages it will merge them in a single memory page, the thing will reduce the used memory pages and hence the overall memory utilization on the system.
This service will only come to the picture utilizing high CPU when the free memory in the system become limited. As you can see in the above snapshot, free memory is 1.5 GB and Swap space started to be used.
In a nutshell; This service help reduce memory utilization on KVM machine when memory become under pressure.

When to stop ksmtuned & KSM service:

- If the impacted machine is not a KVM hypervisor (which means it's not running guest virtual machines).
- If the impacted machine is a KVM hypervisor running guest VMs, but you think that memory is sufficient, and want to release CPU resources used by KSM.

How to stop KSM service:

Because my machine is not a Hypervisor host, where it's not running any guest VMs, this service has no benefit to the memory utilization and hence I've stopped it to release CPU resources using the following commands:

# systemctl stop ksmtuned
# systemctl stop ksm

In addition, I've disabled KSM services to avoid getting it loaded after system reboot:

# systemctl disable ksmtuned
# systemctl disable ksm

References:

Kernel Same-page Merging (KSM)

6 comments: