Disabling hyperthreading in CentOS/RHEL Linux

If you do a google search for disabling hyperthreading under CentOS/RHEL, you’ll find suggestions to disable each CPU instance that is a result of hyperthreading, because the “noht” command line parameter no longer works to disable hyperthreading. There is an easier way.

Disabling hyperthreading method 1: CPU hotplug

You can use the following method to disable a single CPU instance. However, the same architectures that enable hotplugging of CPUs using this method to disable an instance also support the “maxcpus” command line switch.

#echo 0 > /sys/devices/system/cpu/cpuX/online

Disabling hyperthreading method 2: maxcpus

Add this command line switch to your kernel’s boot parameters in /boot/grub/grub.conf, and then reboot. One can specify the number of CPUs that one wants the machine to use. I have a dual quad-core machine, so I want 8 logical processors, one for each physical core. My grub.conf contains the following line:

kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet

I changed it to the following, and then rebooted:

kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet maxcpus=8

The machine will then boot with 8 logical processors instead of the 16 that I would normally get with hyperthreading enabled in the BIOS.

This appears to be better than disabling each processor using the online hotplug file, because the kernel won’t reserve resources for the extra processors, but if one can disable hyperthreading in the BIOS, one should try that first.

You can use the lstopo command available in the hwloc package to verify the processor topology.

I highly recommend disabling hyperthreading if one wants work to be done in the order it’s queued with minimal overhead.

2 Replies to “Disabling hyperthreading in CentOS/RHEL Linux”

  1. the above command didnt work for me……………instead of /vmlinuz-2.6.18-194.el5 i have used my kernel version is that right?

    How can i disable in bios level, once i login through ILO ??

  2. Yes, you don’t add a line to your grub.conf file, you just add ” maxcpus=x” to the end of the line.

    I don’t know what BIOS you’re using, so I can’t give you step by step instructions. Please check your mainboard/VM manual to see if that feature is available in the BIOS and how to access it.

Leave a Reply

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