Hyper-threading on or off in firmware
Video 095 of 140 in Virtualization Foundations, in the unit “Firmware settings that matter on a virtualization host”. 3:02, with English and Hindi audio.
A modern processor core can often run two streams of work at once. Firmware decides whether that second stream is offered to Linux. This article explains what the hyper-threading switch changes, how it sets the number of logical processors, how big the gain really is, when teams turn it off, and how to read the setting from Linux.
What you will learn
- Hyper-threading lets one physical core offer two hardware threads to Linux.
- With it on, a host shows twice as many logical processors as it has cores.
- The gain is real but modest, and it depends on the workload, so measure it.
- Security concerns and steady speed are the usual reasons to turn it off.
- Read the threads-per-core line in lscpu, or the smt control file, to check it.
What hyper-threading is, and what it is called
Hyper-threading is the name Intel gives this feature. One physical core runs two hardware threads, so the system sees two processors for that core. Intel calls it Hyper-Threading. AMD calls the same idea SMT, which stands for simultaneous multithreading.
What the switch changes on one core
With hyper-threading off, one core serves one thread, so that program gets the whole core. Turn it on, and the core offers a second thread. Linux then sees two processors for that one core.
Both threads share the core's parts. When both are busy, the core does up to about thirty percent more work, not twice as much. That extra work is the gain, and for some workloads the gain is small, so the choice should be measured, not assumed.
Counting the logical processors on a Harbor Point host
Each PROD-A host at Harbor Point has two sockets, with twenty-four cores in each socket. Hyper-threading is on, so every core shows up as two processors to Linux. That makes 96 logical processors on one host, and each one can run a thread of work.
Read the setting from Linux
The lscpu command shows the threads per core. A value of 2 means hyper-threading is on.
lscpu | grep -E '^(Thread|Core|Socket)'The smt control file gives the state directly.
cat /sys/devices/system/cpu/smt/controlNote: The values depend on the host. The same control file can also switch hyper-threading off while Linux runs.
Why a team might turn it off
- Usually a gain: the second thread adds from zero up to about thirty percent more work, so measure before deciding.
- Security choice: some processor security problems found in 2018 and 2019 led operators to turn it off, to be safe.
- Steady speed: where a job must never wait for a neighbour on the same core, some teams turn it off for predictable speed.
Read the threads per core and the SMT state
You need a Linux host and a shell. The values will differ from the example, which shows a PROD-A host.
Show the threads per core, cores per socket and sockets.
lscpu | grep -E '^(Thread|Core|Socket)'What you should see: Two threads per core means hyper-threading is on. The example shows 24 cores per socket and 2 sockets.
Read the hyper-threading state directly.
cat /sys/devices/system/cpu/smt/controlWhat you should see: The file prints on or off, the state of hyper-threading now.
Terms
- Hyper-threading
- Intel's name for a feature in which one physical core runs two hardware threads, so the system sees two processors for it.
- SMT
- Simultaneous multithreading: AMD's name for the same idea as hyper-threading.
Check yourself
How many logical processors does a PROD-A host show with hyper-threading on?
96: two sockets with 24 cores each, and two threads per core.
How big is the gain from the second thread?
It is real but modest. It adds from zero up to about thirty percent more work, so measure it for your workload.
Which file gives the hyper-threading state directly?
The file /sys/devices/system/cpu/smt/control, which prints on or off.
Previous: SR-IOV in firmware. Next: Power profiles, C-states and P-states.