Windows 11 VM suddenly really slow and cpu 100%


Cliff

Recommended Posts

I don't really know what happend but after running fine since I created my Unraid server my windows 11 VM suddenly is really slow and unresponsive and CPU is ideling at around 70% on all cores and is hitting 100% as soon as I open a browser o similar.

I am passing through gpu, nvme-drive and a usb controller.

I have tried recreating the vm with both i440fx and q35 but there is no difference in performance. And also tried deleting the VM image in the Unraid VM settings. One thing I noticed is that if I try to specify the biosfile for the gpu I have to enter it manually I can not browse the folders and navigate to the file as I could before in the VM template settings.

I have also tried running the MSI utility and selected the GPU.

I have also noticed that when I use the mouse the cpu also increases with 20-30% on all cores. So I am guessing thare is something wrong with the usb settings too. Is this also related to MSI ? and does anyone have any idé af how to solve this. The CPU govenor is already set to "on demand" and I do not have any windows hyper-v or other vm features enabled.

 

image.png.02070ed8b4b2f88e3dc962dabb0ff8c1.png

 

<?xml version='1.0' encoding='UTF-8'?>
<domain type='kvm' id='3'>
  <name>Windows 11</name>
  <uuid>25cede08-af6a-ae6d-fbfa-5907e210b2c6</uuid>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 11" icon="windows11.png" os="windowstpm"/>
  </metadata>
  <memory unit='KiB'>17301504</memory>
  <currentMemory unit='KiB'>17301504</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>8</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='1'/>
    <vcpupin vcpu='1' cpuset='7'/>
    <vcpupin vcpu='2' cpuset='3'/>
    <vcpupin vcpu='3' cpuset='9'/>
    <vcpupin vcpu='4' cpuset='4'/>
    <vcpupin vcpu='5' cpuset='10'/>
    <vcpupin vcpu='6' cpuset='5'/>
    <vcpupin vcpu='7' cpuset='11'/>
  </cputune>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-q35-6.1'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu/ovmf-x64/OVMF_CODE-pure-efi-tpm.fd</loader>
    <nvram>/etc/libvirt/qemu/nvram/25cede08-af6a-ae6d-fbfa-5907e210b2c6_VARS-pure-efi-tpm.fd</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='4' threads='2'/>
    <cache mode='passthrough'/>
    <feature policy='require' name='topoext'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/user/isos/virtio-win-0.1.208-1.iso' index='1'/>
      <backingStore/>
      <target dev='hdb' bus='sata'/>
      <readonly/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x8'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='2' port='0x9'/>
      <alias name='pci.2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0xa'/>
      <alias name='pci.3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0xb'/>
      <alias name='pci.4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
    </controller>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='5' port='0xc'/>
      <alias name='pci.5'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
    </controller>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='6' port='0xd'/>
      <alias name='pci.6'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
    </controller>
    <controller type='pci' index='7' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='7' port='0xe'/>
      <alias name='pci.7'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
    </controller>
    <controller type='pci' index='8' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='8' port='0xf'/>
      <alias name='pci.8'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
    </controller>
    <controller type='pci' index='9' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='9' port='0x10'/>
      <alias name='pci.9'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:d6:9a:aa'/>
      <source bridge='br0'/>
      <target dev='vnet2'/>
      <model type='virtio-net'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-3-Windows 11/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0' persistent_state='yes'/>
      <alias name='tpm0'/>
    </tpm>
    <audio id='1' type='none'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <rom file='/mnt/user/isos/vbios/gpu_1060_vbios.rom'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x08' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev2'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x08' slot='0x00' function='0x3'/>
      </source>
      <alias name='hostdev3'/>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x0c' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev4'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </hostdev>
    <memballoon model='none'/>
  </devices>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+0:+100</label>
    <imagelabel>+0:+100</imagelabel>
  </seclabel>
</domain>

 

Edited by Cliff
added info
Link to comment
On 2/9/2022 at 6:48 AM, Cliff said:

Is this also related to MSI ?

It should not..but who knows..from your screenshot only the 4 intel emulated controllers are using irq, all the other devices are using msi, so it's not an issue with irq.

However msi for some devices can be problematic.

Not much to say unfortunately, but if I were you I:

1. disable all msi fixes and see if it changes something

2. if it doesn't change, remove all the passthroughs, except for the nvme (you have the os on it), so remove gpu and usb, and see if it changes something

3. if it's ok add again one at a time the other passthrough, first gpu, then usb, and see if it works

4. only if you have issues in the vm for specific devices (usually gpu and audio, sometimes with network), enable msi, you don't need to enable msi for all devices, having shared irq can be perfectly fine, as it is also in several bare metal builds

Link to comment
On 2/10/2022 at 5:18 PM, ghost82 said:

It should not..but who knows..from your screenshot only the 4 intel emulated controllers are using irq, all the other devices are using msi, so it's not an issue with irq.

However msi for some devices can be problematic.

Not much to say unfortunately, but if I were you I:

1. disable all msi fixes and see if it changes something

2. if it doesn't change, remove all the passthroughs, except for the nvme (you have the os on it), so remove gpu and usb, and see if it changes something

3. if it's ok add again one at a time the other passthrough, first gpu, then usb, and see if it works

4. only if you have issues in the vm for specific devices (usually gpu and audio, sometimes with network), enable msi, you don't need to enable msi for all devices, having shared irq can be perfectly fine, as it is also in several bare metal builds

 

Thanks for the tips, I tried your steps and removed all passthroughs but the nvme and created a new Win11 VM. I had some strange issues where I could not create any VM using Q35 for some reason but after changing to i440fx I was able to create the new VM. So this time I have only stubbed the nvme and the usb-controller and my VM is usable again. My CPU dpes not spike to 100% any longer as it did before but I still have the issue that when I move the mouse rapidly all cores increase with ~15-20%. 
Should I try to stub the gpu again or do I need to enable msi on the usb-controller or is there some other steps I could try to eliminate the cpu load when using the mouse?

Link to comment
13 minutes ago, Cliff said:

This is how it looks now, I have not enabled anything myself in this vm

Is this a completely new install?And it's this one that has 15-20% spikes on cpu with fast mouse movements?

It seems strange because usually msi is not enabled by default.

There's no irq sharing here, but the issue could be related with msi.

Where is your mouse attached?You could try to uncheck msi for the usb controller to which your mouse is attached.

It works like this:

in the irq column if you read a number with the minus in front of it, it is using msi.

in the irq column if you read a positive number it is using irq and the interrupt priority column applies.

in the irq column if you read positive numbers, and you have the same positive numbers for different devices, then there's an irq conflict: depending on devices you can enable msi to avoid conflicts.

linebased means irq, msi/msix means msi compatible (msix being a "more recent version" of msi)

 

Usually it is not recommended to enable msi for all the devices.

Edited by ghost82
Link to comment

Ok, thanks for the information. I have always created the VMs unsing the passed through nvme as hdd so I always use the same windows install if even if I create a new Win11 . I am passing through the entire usb controller as I am using a usb kvm switch to switch between my work-computer and my private (The windows 11 vm). And If I did not pass through the entire controller the vm would hang when switching between the computers and it lost all usb input devices. And yes this VM spikes 15-20% when moving the mouse. Ok so I should disable all msi checkboxes for now ?

Edited by Cliff
Link to comment

Ok tried disabeling all msi, rebooted and now it is unusable again it took 5 minutes to boot, only one monitor works (I have three) and I did the mistake of trying to open chrome and now all cpu cores are at 100% and the VM does not respond. I will try to force shutdown and only open the msi-app. But what devices would be the best bet to enable again to get the VM to work again ?

Link to comment
  • 1 year later...
  • 3 months later...

I had this exact same issue on a bare metal windows install that was passed through to the VM.  Booting straight into the bare metal install everything was perfect, booting the VM, hardcore mouse lag.

 

The only thing that fixed it, in my situation was to reset windows within the VM....

So I had to set my windows iso as a USB device in the template boot the VM, click troubleshooting, and reset this windows install.

 

After I did that the windows VM no longer gave me mouse lag and high CPU usage problems. Been perfect ever since

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.