Lazy Preemption "PREEMPT_LAZY" Slated To Land In Linux 6.13

Written by Michael Larabel in Linux Kernel on 6 November 2024 at 06:23 AM EST. 9 Comments
LINUX KERNEL
Yet another exciting feature expected to be merged for the upcoming Linux 6.13 cycle is the introduction of the Lazy Preemption model.

The patches for introducing the Lazy Preemption "PREEMPT_LAZY" mode were queued up yesterday into tip/tip.git's "sched/core" Git branch. With the lazy preemption patches working their way into a TIP branch, they should be submitted for the Linux 6.13 merge window opening up later this month.

PREEMPT_LAZY patches


Linux developer Peter Zijlstra explains in the patch adding the Lazy Preemption model:
"sched: Add Lazy preemption model

Change fair to use resched_curr_lazy(), which, when the lazy preemption model is selected, will set TIF_NEED_RESCHED_LAZY.

This LAZY bit will be promoted to the full NEED_RESCHED bit on tick. As such, the average delay between setting LAZY and actually rescheduling will be TICK_NSEC/2.

In short, Lazy preemption will delay preemption for fair class but will function as Full preemption for all the other classes, most notably the realtime (RR/FIFO/DEADLINE) classes.

The goal is to bridge the performance gap with Voluntary, such that we might eventually remove that option entirely."

The Kconfig option for introducing this new option is PREEMPT_LAZY. The PREEMPT_LAZY Kconfig text sums up this new preemption mode as:
"This option provides a scheduler driven preemption model that is fundamentally similar to full preemption, but is less eager to preempt SCHED_NORMAL tasks in an attempt to reduce lock holder preemption and recover some of the performance gains seen from using Voluntary preemption."

When in patch form on the mailing list, Peter also had a patch introducing the "Laziest" preemption mode too, but that wasn't picked up into sched/core but just aiming for the more robust Lazy Preemption path.

PREEMPT_LAZY Kconfig


The patches go on to enable PREEMPT_LAZY for x86/x86_64 and RISC-V architectures so far. This PREEMPT_LAZY addition comes just one kernel release after real-time "PREEMPT_RT" finally made it mainline for Linux 6.12.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week