Skip to content
Log In Sign Up info@muvcloud.com

Two Threads, One Core

A CPU core has execution units, caches, and a pipeline. A single thread often leaves part of that idle, for example while it waits for data from memory. With two hardware threads, the core keeps two sets of registers and state and fills idle units with work from the second thread. The threads still share the caches and execution units, so each one runs slower than it would alone.

Hyper-Threading and SMT

The general name is simultaneous multithreading (SMT). Hyper-Threading is the name Intel uses for it, and AMD calls it SMT. Most of their current server processors run two threads per core, though some models, such as Intel's efficient-core Xeon line, have one. Many Arm server processors have one thread per core and no SMT at all.

How Much Does It Help?

It depends on the workload. Many independent tasks that wait on memory, disk, or network, such as a web server handling many small requests or a build compiling many files, gain the most. Work that keeps a core busy on its own, such as tight numeric loops, gains little and can even slow down because the two threads compete for the same cache. The gain is never double; measure your own application with SMT on and off before deciding.

How Linux Shows It

lscpu | grep -E 'Thread|Core|Socket|^CPU\(s\)'

On a host with SMT, the output shows two threads per core. The number of logical CPUs equals sockets times cores per socket times threads per core. lscpu -e adds a CORE column: two CPUs with the same core number are siblings on one core. nproc counts logical CPUs.

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

The first file shows 1 when SMT is in use. The second shows the control state: on, off, forceoff, or notsupported.

vCPUs on a Cloud Server

A vCPU on a cloud server is usually one hardware thread of the host, not a whole core. Inside the virtual machine, lscpu shows whatever topology the hypervisor presents. When the host is busy, the sibling thread may run another guest, which can show up as steal time. See what is a vCPU and CPU steal time.

The Security Side

Because two threads share one core, side-channel flaws found from 2018 onward, such as L1TF and MDS, can let code on one thread infer data handled by its sibling. The kernel applies mitigations; to see the status on your system:

grep . /sys/devices/system/cpu/vulnerabilities/*

For some of these flaws on affected processors, the kernel documentation states that full protection against untrusted code on the sibling thread means switching SMT off.

Switching SMT Off

This halves the logical CPUs. Services that size their worker count from the CPU count change behavior, so test first. At runtime, until the next boot:

echo off | sudo tee /sys/devices/system/cpu/smt/control

To make it permanent, add the kernel argument nosmt: on Debian and Ubuntu in GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, followed by sudo update-grub; on AlmaLinux and Rocky Linux with sudo grubby --update-kernel ALL --args nosmt. The server firmware setup usually has a switch as well. Inside a virtual machine, none of this changes the host.

When Switching It Off Makes Sense

  • Untrusted code side by side: on your own physical server that runs workloads from different parties.
  • Measured gain: when a benchmark of your real workload is faster without it.
  • Otherwise: leave it on. Most server workloads gain from the extra threads.

Remember that load average counts logical CPUs: a load of 8 on 4 cores with 8 threads is busier than it looks. See Linux load average.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations