Menu Close

Windows Server 2019 Hyper-V might only use half the available CPU’s?

I ran into this recently when migrating to a new lab Hyper-V server running Windows Server 2019.

I noticed after the migration of my VM’s from a Hyper-V 2016 to 2019 server, only half of the CPU’s were being used by my VM’s:

image

I hit up a friend who knows Hyper-V better than anyone I know – John Savill – and he pointed me in the direction of Hyper Threading as the likely source… which finally led me to this:

https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/about-hyper-v-scheduler-type-selection

In Windows Server 2019, Hyper-V now defaults to a more secure “core scheduler” where previous versions used “classic scheduler” for CPU scheduling and isolation.  What this means, is that when you migrate a VM over to Hyper-V on WS2019, you need to update the VM configuration and change some settings, or it will only use a single hardware thread per core, exhibiting the behavior you see above.

In Hyper-V on WS2016, the default setting for number of Hardware Threads per Core is “1”.  What we want is to set this to “0” which will inherit the Host’s default configuration for this.

Here are the changes I made:

#Get your Host supported VM guest configuration versions Get-VMHostSupportedVersion #Get your VM guest configuration versions Get-VM | FT Name, Version #Update all VMs configuration versions Get-VM | Update-VMVersion #Get the VM thread count per core setting Get-VM | Get-VMProcessor | FT VMName,HwThreadCountPerCore #Set the VM thread count per core setting Get-VM | Set-VMProcessor -HwThreadCountPerCore 0

Now when I start up and examine at my VM’s on the host task manager, I am making full use of all available VM’s:

image

Note – this only impacts migrated VM’s.  When a VM is created on Windows Server 2019 Hyper-V, this is not an issue as the VM’s inherits the default setting of the Host.

Leave a Reply

Your email address will not be published. Required fields are marked *