Enabling Intel® HT Technology on Azure VMs

Why is my Azure VM not correctly displaying the number of CPUs?” Let’s understand what is happening and how to fix it.

On some occasions, we may find that our virtual machines in Azure do not exhibit coherence between the vCPUs offered by the chosen SKU and the number of CPUs visible at the operating system level. This is because Microsoft employs Hyper-Threading technology in many of the virtual machine SKUs (more information here: https://learn.microsoft.com/en-us/azure/virtual-machines/acu).

If this is your case, let’s understand what is happening and how to resolve it.

Hyper-Threading (HT) is a feature developed by Intel that allows a single processor core to execute multiple threads simultaneously. Instead of having a single set of CPU architecture registers, Hyper-Threading duplicates certain components of the CPU, enabling two threads to share the execution resources of a single physical core.

 

To verify if Hyper-Threading technology is enabled on our VM, let’s follow these simple steps.

 

Validation step to check if Hyper-Threading is working correctly:

For checking this issue, follow these steps:

  1. Access the affected virtual machine and run CMD.
  2. Once in the console, execute the following command:

wmic CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List

If the number of Logical Processors is greater than the number of Cores, Hyper-Threading is enabled on our VMs and functioning correctly:

If, on the contrary, both numbers are equal, we will need to investigate why Hyper-Threading is not functioning correctly.

 

Understanding why Hyper-Threading is not working correctly:

It is possible to have incorrect configuration on the VM, we need to have the VM access, and see if we have installed Hyper V role as well.

Check the msconfig setting

  1. To launch the msconfig tool, go to CMD, type “start msconfig” and press enter.
  2. After reaching to the msconfig page select the second tab “Boot” and click “Advanced options…” as shown below:

Note: Ensure that checkbox “Make all boot settings permanent” is unchecked!

If “Number of processors” setting is set to an specific number, this will be the number of cores shown by Guest OS. For example, if it is set to 2, the OS will show 2 cores regardless if the VM has more cores depending on VM size.

So you will need to set it to “1” and uncheck the box:

Press “OK”.

Then press “Apply” and “OK” on main dialogue window and the press “Restart”.

If the Number of processors setting was already set to 1 and the checkbox was unchecked, proceed with the next step.

Enabling Hyper-Threading:

  1. Check current settings under FeatureSettingsOverride  & FeatureSettingsOverrideMask

reg query “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management”

Then change to the following:

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverride /t REG_DWORD /d 72 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" /v FeatureSettingsOverrideMask /t REG_DWORD /d 3 /f

The VM will need to be rebooted from the Azure portal or command line for the change to take effect.

Note: a reboot from within the GuestOS is not sufficient!

After reboot, ensure that the FeatureSettingsOverride value is still shows decimal 72 ( x48) and confirm that Hyper-Threading is working properly running the following command again in the CMD:

wmic CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List

 

Leave a Reply

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