Linux finally follows Windows and makes a CPU feature requirement mandatory

Linux & Windows logo

The Linux kernel is lastly making the Time Stamp Counter (TSC) a tough requirement for x86 processors greater than a decade after Microsoft started utilizing it as the popular foundation for high-resolution timing on appropriate Home windows methods.

A current change dedicated to the Linux kernel removes the remaining configuration logic that allowed the x86 kernel to be constructed with out TSC help. The commit, titled “x86/cpu: Make CONFIG_X86_TSC unconditional”, makes TSC help unconditional now that the remaining supported x86 CPUs are anticipated to have the characteristic. This may increasingly sound like a comparatively minor kernel cleanup, nevertheless it marks the top of an period for Linux’s help of extraordinarily previous x86 {hardware}.

For these questioning, the TSC is a particular 64-bit register that acts as a processor counter and has been round because the Intel Pentium period. It offers a high-resolution (a extremely fine-grained) approach of measuring elapsed time, and might be accessed way more rapidly (because it’s only a CPU register) than platform timers corresponding to HPET (Excessive Precision Occasion Timer) or the ACPI PM (energy administration) timer.

Efficiency enchancment has always been a key metric for software program and {hardware} progress, and so it is smart as to why TSC acquired the precedence. As such, in the present day, each fashionable Intel and AMD processor has a 64-bit TSC that may be learn utilizing directions corresponding to RDTSC and RDTSCP.

Linux, nonetheless, has traditionally needed to maintain code round for processors that both didn’t have a TSC or couldn’t reliably use one. That was largely as a result of the kernel continued supporting {hardware} going all the best way again to the i486 period. Nevertheless, that baggage has more and more develop into pointless as help for these processors has been eliminated.

Linux 7.0 dropped support for Intel 486 processors, whereas the next improvement cycle eliminated help for extra processors that prevented TSC from being handled as universally accessible. With these CPUs gone, the kernel can now safely assume that an x86 processor has a TSC.

The brand new change is subsequently much less about immediately making Linux rely upon a characteristic that fashionable PCs wouldn’t have and extra about lastly eradicating the compatibility code that has been obligatory for many years.

Curiously, Microsoft reached the same level a lot earlier, though the scenario with Home windows is far totally different.

Home windows launched QueryPerformanceCounter (QPC) with Home windows 2000 and Home windows XP as a high-resolution efficiency counter. Older methods may have issues with non-invariant or unsynchronized TSCs, so Home windows may fall again to platform timers corresponding to HPET or the ACPI PM timer when the processor’s TSC was unsuitable.

Home windows 7 and Home windows Server 2008 R2 already used constant-rate TSCs as the idea for QPC on methods the place the person processor counters could possibly be synced. Microsoft went even additional with Home windows 8, Home windows 8.1 and their corresponding server releases, which use the TSC as the idea for the efficiency counter and launched improved synchronization for bigger methods.

Regardless of that, Microsoft nonetheless paperwork checks for invariant and synchronized TSCs and says Home windows can choose one other {hardware} timer when the TSC is unsuitable. It additionally warns builders in opposition to immediately studying the TSC and recommends QPC as a substitute as a result of the abstraction handles {hardware} and virtualization variations.

There’s a good cause for Microsoft’s choice when the TSC is usable, as the corporate says studying a TSC-based QPC can take solely tens to a whole lot of CPU cycles, whereas falling again to a motherboard-based timer can push the associated fee to roughly 0.8~1.0 microseconds, and that’s important. A TSC-based QPC may keep away from a kernel transition, one thing that isn’t attainable when Home windows has to make use of options corresponding to HPET or the PM timer.

Linux has consequently spent years detecting, calibrating and dealing round TSC reliability issues. Now, nonetheless, one of many oldest items of that compatibility code is lastly being eliminated. You may take a look at the commit here on the Linux kernel’s Git repository.



Source link

Leave a Reply

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