Linux follows Windows and makes a CPU feature requirement mandatory

XzetaU81 pts0 comments

Linux finally follows Windows and makes a CPU feature requirement mandatory - Neowin

DEALS

Software

Gaming

Reviews

Guides

Hands On

Specs Appeal

Opinion

Windows 11

Write for us?

Send news tip

-->

The Linux kernel is finally making the Time Stamp Counter (TSC) a hard requirement for x86 processors more than a decade after Microsoft began using it as the preferred basis for high-resolution timing on suitable Windows systems.

A recent change committed to the Linux kernel removes the remaining configuration logic that allowed the x86 kernel to be built without TSC support. The commit, titled "x86/cpu: Make CONFIG_X86_TSC unconditional", makes TSC support unconditional now that the remaining supported x86 CPUs are expected to have the feature. This may sound like a relatively minor kernel cleanup, but it marks the end of an era for Linux's support of extremely old x86 hardware.

For those wondering, the TSC is a special 64-bit register that acts as a processor counter and has been around since the Intel Pentium era. It provides a high-resolution (a highly fine-grained) way of measuring elapsed time, and can be accessed much more quickly (as it's just a CPU register) than platform timers such as HPET (High Precision Event Timer) or the ACPI PM (power management) timer.

Performance improvement has always been a key metric for software and hardware progress, and so it makes sense as to why TSC got the priority. As such, today, every modern Intel and AMD processor has a 64-bit TSC that can be read using instructions such as RDTSC and RDTSCP.

Linux, however, has historically had to keep code around for processors that either did not have a TSC or could not reliably use one. That was largely because the kernel continued supporting hardware going all the way back to the i486 era. However, that baggage has increasingly become unnecessary as support for these processors has been removed.

Linux 7.0 dropped support for Intel 486 processors, while the following development cycle removed support for additional processors that prevented TSC from being treated as universally available. With those CPUs gone, the kernel can now safely assume that an x86 processor has a TSC.

The new change is therefore less about suddenly making Linux depend on a feature that modern PCs do not have and more about finally removing the compatibility code that has been necessary for decades.

Interestingly, Microsoft reached a similar point much earlier, although the situation with Windows is much different.

Windows introduced QueryPerformanceCounter (QPC) with Windows 2000 and Windows XP as a high-resolution performance counter. Older systems could have problems with non-invariant or unsynchronized TSCs, so Windows could fall back to platform timers such as HPET or the ACPI PM timer when the processor's TSC was unsuitable.

Windows 7 and Windows Server 2008 R2 already used constant-rate TSCs as the basis for QPC on systems where the individual processor counters could be synced. Microsoft went even further with Windows 8, Windows 8.1 and their corresponding server releases, which use the TSC as the basis for the performance counter and introduced improved synchronization for larger systems.

Despite that, Microsoft still documents checks for invariant and synchronized TSCs and says Windows can select another hardware timer when the TSC is unsuitable. It also warns developers against directly reading the TSC and recommends QPC instead because the abstraction handles hardware and virtualization differences.

There is a good reason for Microsoft's preference when the TSC is usable, as the company says reading a TSC-based QPC can take only tens to hundreds of CPU cycles, while falling back to a motherboard-based timer can push the cost to roughly 0.8~1.0 microseconds, and that is significant. A TSC-based QPC can also avoid a kernel transition, something that is not possible when Windows has to use alternatives such as HPET or the PM timer.

Linux has consequently spent years detecting, calibrating and working around TSC reliability problems. Now, however, one of the oldest pieces of that compatibility code is finally being removed. You can check out the commit here on the Linux kernel's Git repository.

Tags

The linux foundation

Linux

Tsc

Windows hardware

Performance management

Microsoft

Windows 11

Windows 10

System requirements

Cpu support

Follow us onGoogle News

Add as a preferredsource on Google

Follow@NeowinFeed

Post

Like

Share

Share

Share

RSS

Report a problemwith this article

Related Stories

Get the Neowin newsletter

Subscribe

We'll send you a confirmation link. You can unsubscribe at any time.

🛍️ Shop on Amazon using our link:

shop at Amazon at no extra cost

☕️ Support us with a virtual coffee:

2.00 Dollars ($)<br>5.00 Dollars ($)<br>10.00 Dollars ($)<br>20.00 Dollars ($)<br>25.00 Dollars ($)<br>50.00 Dollars ($)<br>100.00 Dollars ($)

🏦 Or support us with a bank transfer

Community Activity

Refresh

Nest Protect...

windows linux support kernel dollars microsoft

Related Articles