A Decade In The Making, Time Slice Extension Could Be Merged For Linux 7.0
#Infrastructure

A Decade In The Making, Time Slice Extension Could Be Merged For Linux 7.0

Chips Reporter
5 min read

After over ten years of development and multiple failed attempts, a time slice extension mechanism using Restartable Sequences (RSEQ) is poised for inclusion in the next Linux kernel release, potentially Linux 7.0. The feature aims to reduce latency spikes by allowing user-space threads to opportunistically extend their CPU time slice during critical sections, preventing costly preemption when holding shared resources.

The Linux kernel's scheduler has long grappled with a fundamental tension: balancing fairness and throughput against the need for low-latency, deterministic behavior. A user-space thread executing a critical section—such as updating a shared data structure—can be preempted at any moment. If that thread holds a lock or a resource, the preempting thread (or others waiting for that resource) may spin or block, wasting CPU cycles and introducing unpredictable delays. This problem is particularly acute with user-space spinlocks, which, despite being generally discouraged, remain in use for certain high-performance applications.

For over a decade, kernel developers have sought a solution. Various proposals for "time slice extensions"—allowing a thread to temporarily extend its CPU time slice without being preempted—have surfaced and vanished. The core idea is to provide an opportunistic "priority ceiling" without the overhead and complexity of full real-time scheduling protocols. It's a compromise: no hard guarantees, but a significant reduction in worst-case latency for common workloads.

The breakthrough came with the integration of the mechanism into the existing Restartable Sequences (RSEQ) infrastructure. RSEQ, merged into Linux 4.18 in 2018, provides a framework for user-space to perform atomic operations without kernel intervention in the common case. Thomas Gleixner of Intel-owned Linutronix, a key figure in real-time Linux, has been driving the recent efforts. As he explained in patch submissions last year, the goal is to "avoid situations where a user space thread is interrupted in a critical section and scheduled out, while holding a resource on which the preempting thread or other threads in the system might block on."

The latest iteration of the patches, after several revisions over the past few months, has been queued into the tip/tip.git repository's sched/core branch. This is a critical milestone. The tip tree, maintained by Ingo Molnár, is the primary staging area for scheduler and core kernel changes destined for the mainline Linux kernel. By landing here, the time slice extension patches are now on the fast track for the next merge window.

Twitter image

How the Time Slice Extension Works

The mechanism operates at the intersection of user-space and kernel-space scheduling. When a thread enters a critical section, it can invoke a system call (or an RSEQ-based fast path) to request an extension of its current time slice. The kernel's scheduler, specifically the CFS (Completely Fair Scheduler), evaluates this request.

The extension is not a guarantee. It's opportunistic. The scheduler will grant the extension if:

  1. The requesting thread's priority is appropriate.
  2. The system is not under severe load where fairness must be enforced.
  3. The requested extension duration is within a reasonable bound.

If granted, the thread's sched_slice is temporarily increased, and its vruntime (virtual runtime, used by CFS for fairness calculations) is adjusted accordingly. This effectively delays its next preemption point. The thread must then explicitly yield the extension (or it will be revoked at the next scheduling point).

The integration with RSEQ is crucial for performance. RSEQ allows the critical section to be defined in user-space with minimal kernel involvement. The time slice extension can be requested as part of the same RSEQ abort handler, making the entire sequence efficient. Without RSEQ, the overhead of a separate system call for extension would likely negate the benefits for fine-grained critical sections.

Technical Trade-offs and Implications

This feature is not a silver bullet. It introduces new complexity into the scheduler and has inherent trade-offs:

  • Fairness vs. Latency: The extension inherently favors the requesting thread, potentially starving others. The opportunistic nature is designed to mitigate this, but in a highly contended system, aggressive use could lead to unfairness. The kernel must carefully balance the extension grant logic.
  • No Hard Guarantees: Unlike real-time scheduling policies (e.g., SCHED_FIFO), this does not provide deterministic latency bounds. It's a best-effort mechanism. Applications requiring strict real-time guarantees should still use proper RT scheduling.
  • Complexity in the Scheduler: Adding another dimension to the scheduler's decision-making process increases code complexity and the potential for subtle bugs. The patches have undergone extensive review on the Linux Kernel Mailing List (LKML) to address these concerns.

The primary beneficiaries will be applications with fine-grained locking or synchronization in user-space, such as certain databases, high-frequency trading systems, and specialized compute workloads. For the average desktop or server workload, the impact may be negligible, but the reduction in worst-case latency spikes can be significant for latency-sensitive applications.

Market and Supply Chain Context

From a semiconductor and system architecture perspective, this change reflects the ongoing evolution of operating systems to better exploit modern multi-core processors. As core counts increase and inter-core communication latency remains a bottleneck, minimizing unnecessary context switches and preemption becomes more critical.

Intel has been a major proponent of RSEQ and related technologies, as they align with the company's focus on high-performance computing and real-time capabilities in its CPUs. The involvement of Linutronix, a company specializing in real-time Linux solutions, underscores the enterprise and embedded market demand for such features. This development could influence future processor designs, where hardware support for opportunistic scheduling extensions might be considered to further reduce overhead.

The supply chain for Linux kernel development is largely a meritocracy of code, but corporate backing from companies like Intel, Google, and Red Hat accelerates the integration of features that serve their strategic interests. The time slice extension, while a general-purpose improvement, has clear value for Intel's data center and embedded product lines.

What's Next

With the patches in the tip tree, the next step is the Linux 6.20 or 7.0 merge window, expected in early 2026. Linus Torvalds will have the final say on merging the patches and deciding the next kernel version number. If merged, the feature will be available for testing in the first release candidate (RC) of the new kernel.

Developers interested in the technical details can review the patch series on the LKML archive and the RSEQ documentation (though RSEQ-specific documentation is still evolving). The implementation will be part of the kernel's scheduler core, and its behavior can be tuned via existing scheduler tunables and potentially new ones added with the patchset.

This decade-long journey highlights the meticulous, consensus-driven nature of Linux kernel development. A feature that seems conceptually simple—extending a time slice—requires deep integration with the scheduler, careful consideration of fairness, and a performance-optimized implementation. Its eventual merger into mainline Linux marks a significant step in making the kernel more adaptable to the diverse and demanding workloads of modern computing.

Comments

Loading comments...