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

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.

Show the threads per core, cores per socket and sockets
lscpu | grep -E '^(Thread|Core|Socket)'

The smt control file gives the state directly.

Show the hyper-threading state
cat /sys/devices/system/cpu/smt/control

Note: 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

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.

  1. 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.

  2. Read the hyper-threading state directly.

    cat /sys/devices/system/cpu/smt/control

    What 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.