Linux Core to Utilize EBPF for CPU Planners

Linus Torvalds has expressed his readiness to accept the Linux 6.11 kernel, which is expected to be released at the end of September. The proposed patches include the implementation of the “Sched_ext” (SCX) mechanism, allowing the use of EBPF to create CPU schedulers that cover a wide range of task planning and CPU resource distribution aspects. These schedulers can be dynamically loaded and executed within the Linux kernel in the EBPF virtual machine, utilizing JIT compilation for optimal performance.

The new patches introduce the Sched_ext scheduling class, positioned in priority between the Sched_idle and Sched_normal classes. This setup prevents BPF programs associated with Sched_ext from impacting tasks managed by the standard problem scheduler. However, it enables individual tasks to be assigned to Sched_ext for processing, handling all processes with priority lower than real-time execution. Tasks moved to Sched_ext without BPF processors attached will be processed using the sched_normal scheduler. The BPF handler’s role involves analyzing task queues awaiting CPU execution to select the task that should receive CPU resources when the next CPU core becomes available.

The SCHED_EXT mechanism streamlines the creation of specific task schedulers, facilitating experimentation with different techniques and strategies while enabling the rapid development of working prototypes to replace existing schedulers in operational infrastructures. For instance, Sched_Ext allows the creation of a scheduler tailored to a particular application’s requirements, dynamically adjusting planning strategies according to system state and other variables.

Currently, several schedulers based on Sched_ext are in development, with user-defined task logic loaded onto the core as BPF programs. One such example is scs_layered, a hybrid scheduler that categorizes tasks into layers, each receiving a specific planning strategy. SCX_LAYERED can allocate certain tasks to a separate layer with guaranteed CPU resources or elevate the priority of individual applications. This scheduler, developed in Rust, relies on the META operation in user space for BPF program generation.

/Reports, release notes, official announcements.