Simple Steps to deactive Hyper-threading in Azure VMs via registry settings

How to deactivate Hyper-threading on Azure VMs in an easy way without Microsoft support

In my current project we have the requirement to deactivate Hyper-threading on some Azure VMs. There are some Azure VMs available without Hyper-threading which can be found on the Azure compute unit site where Microsoft published a table with VM SKUs sizes where the “vCPU: Core” give a hint about VMs which are not having HT integrated. But this sizes are very limited and we have some requirements from licensing side to disable Hyper-threading and there also some applications which have a better performance when HT is disabled.

We found several arcticle in the Internet with different options like enable a Tag to disable HT for the selected VMs and some other examples. Microsoft announced in the following article “Guidance for mitigating silicon based micro-architectural and speculative execution side-channel vulnerabilities

If you’re running a hyper-threaded VM, contact Azure Support to get hyper-threading disabled.

After several of these attempts failed, we found out from Microsoft how we could solve this requirement without the help of Microsoft support or further requirements.

To see if a VM using Hyper-threading, we can use Powershell to check the current status in a Windows VM with the following parameter:

wmic CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List

The result like the following

Example for D2as_v5
Number of Logical Processors before implementing the reg settings and restart – example on a D4ads v5

There you can see the count for the number of cores and the numer of Logical processors which equals the Hyper-threading cores.

Implementation

Simple Steps to deactive Hyper-threading in Azure VMs via registry settings

To disable Hyper-threading on Azure VMs which have CPUs with enabled vCores there must be set two registry keys. This keys can be ad manually or via Command line over “reg add”.

How the registry looks before adding the settings

When you run the following two registry settings and restart the VM the vCores are disabled.

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

After the two commands have been executed in the command line, the registry looks like this:

After the registry settings have been implemented, the VM must be restarted to take effect. The settings will not take effect wihtout.

Number of Logical Processors after implement the reg settings and restart – example on a D4ads v5

This will close this article. Thanks goes out to my colleague David Laukamp for noted me in this case.

Leave a Reply

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