VMware Communities
JavaScriptDude
Contributor
Contributor

kcompacd0 using 100% CPU with VMware Workstation 16

I have been experiencing issues with the process `kcompacd0` consuming 100% of resources periodically, stalling the VM and making it unusable for minutes at a time.

My host is Ubuntu 20.04.4 on a fully loaded dual socket HP Z840. Workstation Pro version: 16.2.1 build-18811642 .

I depend on using VMWare workstation to run my business and cannot have these types of performance issues. I never noticed this problem prior to version 16.0.

At version 16.1, I was able to mitigate this by setting `vm.compaction_proactiveness=0` in the VM's vmx file, however it appears that with 16.2, this setting is now ignored.

Here is a related thread on unix.StackExchange .

I'm almost to the point of abandoning Workstation again and switching back to Virtual Box.

0 Kudos
20 Replies
JavaScriptDude
Contributor
Contributor

[+ screenshot] Take note of Time for kcompacd0 process. When `kcompacd0` in consuming 100% of resources, I often see `vmware-vmx` taking 400%. Although my machine has dual xeon processors, the host still lags significantly!

 

Screenshot from 2022-03-05 13-36-55.png

0 Kudos
ajgringo619
Hot Shot
Hot Shot

From this link - https://gist.github.com/2E0PGS/2560d054819843d1e6da76ae57378989 - I found that editing /etc/sysctl.conf (different on Arch-based, but the same principle) worked for me:

 

# Fix problem where vmware battles with kcompactd0.
vm.compaction_proactiveness=0

 

Reboot required, of course.

wila
Immortal
Immortal

Hi,

What ajgringo619 says, see also this thread for context:

https://communities.vmware.com/t5/VMware-Workstation-Player/Over-CPU-usage-in-idle/m-p/2878569

and the reply from akornilov82

--
Wil

| Author of Vimalin. The virtual machine Backup app for VMware Fusion, VMware Workstation and Player |
| More info at vimalin.com | Twitter @wilva
JavaScriptDude
Contributor
Contributor

Looks like reboot was the step needed. I'm not sure I did a reboot after I updated VMware. After reboot, I was prompted to recompile kernel module for vmware.

 

I will continue to monitor this but it appears to be fixed.

0 Kudos
JavaScriptDude
Contributor
Contributor

[Update] This issue has not come back. It appears that the reboot after updating and the vmx setting did the trick.

0 Kudos
jiaxinslee
Contributor
Contributor

Comfirm that win10 guest freezes and kcompactd0 kicks in with compaction_proactiveness=0.

Tested with:
Ubuntu 22.04 kernel 5.15.35 / 5.16.20
VMWare 16.2.3 / 16.2.0 / 16.1.2
Win10 Guest, 4GB / 6GB memory allocated

0 Kudos
JavaScriptDude
Contributor
Contributor

This issue is back with force. My Ubuntu is fully updated and VMware workstation version is 16.2.4 build-20089737. VM takes all cores assigned at 100% (600% on top) and kcompacd0 is taking 100%.

The only fix I found is to reboot my host OS 😞

Any help would be appreciated.

0 Kudos
Rondo85
Contributor
Contributor

I updated two Systems (Workstation and Laptop) from Ubuntu 20.04 to Ubuntu 22.04 LTS.

As VMware Workstation is not running on Ubuntu 20.04 I updated to VMware® Workstation 16 Pro 16.2.4 build-20089737.

VMware Guests with Windows 10 became complete unusable. Take into account that both systems worked fine with Ubuntu 20.04 and VMWare 15!
I played in a backup of Laptop to Ubuntu 20.04 and installed VMware Workstation 16.2.4

One Windows 10 Guest is on an external SSD. So I started the same guest on both systems. Result:

Ubuntu 20.04 & VMware 16 is fine. Guest does not freeze

Ubuntu 22.04 & WMware 16 is unusable. Guest freezes regularly and Host is on 100% for kcompactd0.

 

 

JavaScriptDude
Contributor
Contributor

[Update] I had my windohs VM open for quite a while with no issues (I was watching with top) but once I loaded a big project with Visual Studio, it went nuts. Therefore, it seems that disk or cpu load seems to be a factor in this bug.

0 Kudos
Harald4243
Contributor
Contributor

Same problem for me.

I tried all the kernel hacks without success.

echo 0 > /proc/sys/vm/compaction_proactiveness
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo 1 > /proc/sys/vm/swappiness

Is there still no solution for this problem?

 

Linux pingu3 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

0 Kudos
FZ2
Contributor
Contributor

It seems

vm.compaction_proactiveness = 0

works properly till Kernel 5.13. It doesn't work anymore from Kernel 5.15.

- Ubuntu 22.04 LTS use v5.15 /5.17 as default

- Ubuntu 20.04.4 LTS use v5.13
- Ubuntu 20.04.5 LTS use v5.15 <-- Released 1/9/2022

Tags (1)
JavaScriptDude
Contributor
Contributor

Is this issues something that VMware will fix on VMware Workstation 16? If not, I'm out. I will not be buying any more new licenses of VMware products. Tired of forking out big $ for new licenses after older linux versions break.

0 Kudos
pokemogu
Contributor
Contributor

Hello, I had a simular problem and resovled by executing following commands, before starting a Windows VMware instance.

 

sudo sync

sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'

sudo sh -c 'echo 1 > /proc/sys/vm/compact_memory'

 

I heard that the problem is due to a memory fragmentation of a host Linux OS and these commands defrag your memory.

JavaScriptDude
Contributor
Contributor

Another thing that may trigger this problem is when "Accelerate 3D Graphics" is enabled. Therefore, if not needed, turn this off.

0 Kudos
JavaScriptDude
Contributor
Contributor

@pokemoguYour solution hit the nail on the head. It will still come back after a couple of days but suspending VMs, shutting down vmware and following your suggestions gets it working again. At least its better than having to bounce the host.

Cheers,

- Tim

0 Kudos
JavaScriptDude
Contributor
Contributor

I've created a gist on Github with a desktop file to replace the launcher for workstation with an updated version that takes care of the steps provided by @pokemogu .

ihsorihakanekat
Contributor
Contributor

The following article in unix stachexchange was posted 1year ago and in the thread the most effective measure is decribed. No one has mentioned it here so I report it here.

The measure is to add an option to GRUB, which turns on INTEL_IOMMU function.

First, edit /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"

Second,

# update-grub

Then restart your host and you will see this problem is greatly improved.

My host is Ubuntu 20.04 on iMac mid 2011 (2core 4thread 16GByte RAM).

When Memory usage exceeded 8GByte, kcompactd0 always kicked in and it monopolized cpu resources. It continued to work and swapped in memory despite the enough memory space.

However, since intel_iommu was turned on, this problem has been greatly improved.

Still now, kcompactd0 often kicks in especially when memory usage exceeds 8GByte but it is not persistent like before.

Now I'm using original values for compaction_proactivity and swappiness, 20 and 60, respectively.

0 Kudos
Rondo85
Contributor
Contributor

This was to complex for me, so I tried the following, all in one line:

# sudo vi /usr/local/share/applications/vmware-workstation.desktop

[Desktop Entry]
Encoding=UTF-8
Name=VMware Workstation
Comment=Run and manage virtual machines
Exec=sh -c "sudo sync; sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'; sudo sh -c 'echo 1 > /proc/sys/vm/compact_memory'; /usr/bin/vmware %U"
Terminal=false
Type=Application
Icon=vmware-workstation
StartupNotify=true
Categories=System;
MimeType=application/x-vmware-vm;application/x-vmware-team;application/x-vmware-enc-vm;x-scheme-handler/vmrc;
~                                                                                                             

 I rebooted the system and it works.

After that I increased the memory of the Windows 10 Guest to 8 GB of 10 GB, activated 3D acceleration and

... it works !!!

0 Kudos
Bazagee
Contributor
Contributor

After upgrading to 16.2.5 my Win10 VM became unusable. Rondo85 script addition seems to have fix the problem for me.

Thanks.

0 Kudos