Issue : high CPU usage

I created a windows VM on a linux server. Now i have an issue that the cpu usage on the host is high (50%) when its 2-4% of four cores on VM.
Can anyone say why this over consumption and also suggest if any optimization is possible in configurations?

the attached screenshot shows the cpu usage

Windows here seems to hover around 15% when usage inside the VM is at around 3%.

I suspect one difference may just be in the way this is calculated.
Presumably on the Windows side, 100% would mean all 4 cores used at 100%.
On Linux, this would be reported as 400% not 100%, I routinely see virtual machines here that exceed the 100% mark.

To get an equivalent number, I suspect you’d need to get the per-thread usage with something like ps auxH and then average the 4 vCPU threads together.

In my case, the 4 vCPU threads are at 4.2%, 3.4%, 3.4% and 3.1% so an average of 3.5% which now very closely resembles what Windows reports.

You could also divide the CPU usage reported for the total thread group by the number of vCPUs, in your case, dividing your 47% by 4, giving you 11.75%.

That’s still far higher than what Windows shows though so either you’re dealing with background operations that don’t virtualize well (disk I/O may be one) or you may be dealing with a driver issue in the VM which would use a less-ideal path on the host.

thank you @stgraber for the response.
also can set -enable-kvm as qemu parameter?

This is not needed, if you look at the qemu.conf file that LXD generates and passes to qemu, you’ll notice that it specifies accel = kvm

thanks Stephane !

I could not find the exact reason for the high cpu usage. To simplify the comparison, I used VM with 1 core. Now the cpu usage on the host is 12-14% when its 5% ( Task Manager) inside the VM.
Can you help me to find why this high usage and also suggest any solution?
The attached screenshots show the cpu usage.cpu_host