Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

sched-ext

БесплатноБез исполняемых скриптовНе проверен

sched_ext skill for Linux CPU schedulers written in BPF. Use when enabling CONFIG_SCHED_CLASS_EXT, running scx schedulers such as scx_lavd or scx_bpfland…

mohitmishra786от mohitmishra786★ 307 звёзд на GitHub

Об этом скилле

sched_ext — BPF CPU Schedulers

Purpose

Guide agents through sched_ext (examples checked on Linux 7.3.5): enabling it, running existing schedulers, writing a minimal BPF scheduler, and debugging or measuring one safely.

Triggers

  • "How do I try a sched_ext scheduler like scx_lavd?"
  • "How do I write my own CPU scheduler in BPF?"
  • "Why did my BPF scheduler get disabled?"
  • "What are dispatch queues (DSQs)?"
  • "Is sched_ext safe to run in production?"
  • "How do I check which scheduler is active?"

Workflow

1. What sched_ext is

sched_ext (upstream since Linux 6.12) adds a scheduling class whose policy is a BPF struct_ops program loaded from user space. When the program exits, errors or stalls, the kernel switches all tasks back to the default fair class. Linux 7.1 added per-cgroup sub-schedulers. Meta and Google run it in production; CachyOS and SteamOS use it on desktops.

Want different scheduling behaviour?
├── Tuning knobs (nice, cgroup cpu.weight, isolcpus) enough? → use them first
├── An existing scx scheduler fits (gaming latency, throughput, NUMA)? → section 3
└── Workload-specific policy needed → write one (sections 4-5), test in a VM first

2. Kernel configuration

CONFIG_SCHED_CLASS_EXT=y      # depends on the three below
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_DEBUG_INFO_BTF=y       # needs pahole at build time

Schedulers built with the in-tree helpers (tools/sched_ext) or the scx repository also need:

CONFIG_FUNCTION_TRACER=y      # fentry programs in the scx common headers
CONFIG_DYNAMIC_FTRACE=y
CONFIG_BPF_EVENTS=y
CONFIG_CGROUP_SCHED=y         # struct_ops has cgroup callbacks the loader expects
CONFIG_EXT_GROUP_SCHED=y

tools/sched_ext/Kconfig in the kernel tree is the full recommended fragment.

# Is sched_ext available and is a scheduler loaded?
cat /sys/kernel/sched_ext/state          # disabled | enabled
cat /sys/kernel/sched_ext/root/ops       # name of the running scheduler (only when enabled)

3. Running existing schedulers

The sched-ext/scx repository (v1.1.4) ships production schedulers in Rust and C:

Scheduler Aimed at
scx_lavd Latency-criticality aware virtual deadline; interactive and gaming workloads
scx_bpfland EEVDF-like, per-CPU deadline queues; keeps interactive tasks responsive (Linux 6.16+)
scx_rusty Multi-domain: BPF round robin per domain, load balancing in user space
scx_p2dq Pick-two load balancing with multi-layer queueing, general purpose
scx_cosmos Keeps tasks on their previous CPU (locality) when not saturated
scx_flash Fairness and predictable performance
# Fedora, Arch, CachyOS, openSUSE Tumbleweed package them (scx-scheds)
sudo scx_lavd                 # runs until Ctrl-C, then the kernel falls back to the fair class

# Managed by systemd: v1.1.4 ships services/scx.service, which runs the scheduler named in
# /etc/default/scx (SCX_SCHEDULER=scx_cosmos, optional SCX_FLAGS=...)
sudo systemctl enable --now scx.service
systemctl status scx.service

# scxcli (front end for scx.service) is only on the main branch, not in v1.1.4:
#   cargo build --release -p scxcli
scxcli list                   # recommended schedulers and current state
sudo scxcli start scx_cosmos

# From source
git clone https://github.com/sched-ext/scx && cd scx
cargo build --release -p scx_lavd

The BPF interface has no stability guarantee: kfuncs and sched_ext_ops fields change between kernel releases. Run a scheduler version built for your kernel, and test before deploying.

4. Writing a minimal scheduler

A scheduler fills in struct sched_ext_ops. Tasks flow through dispatch queues (DSQs): each CPU has a local DSQ it runs from, and the scheduler can create shared DSQs.

/* scx_mini.bpf.c — global FIFO scheduler with an idle-CPU fast path */
#include <scx/common.bpf.h>

char _license[] SEC("license") = "GPL";

UEI_DEFINE(uei);                 /* exit info shared with userspace */

#define SHARED_DSQ 0             /* our own dispatch queue id */

/* Pick a CPU on wakeup; if it is idle, queue straight to its local DSQ */
s32 BPF_STRUCT_OPS(mini_select_cpu, struct task_struct *p, s32 prev_cpu, u64 wake_flags)
{
        bool is_idle = false;
        s32 cpu = scx_bpf_select_cpu_dfl(p, prev_cpu, wake_flags, &is_idle);

        if (is_idle)
                scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL, 0);
        return cpu;
}

/* Everything else goes to one shared FIFO */
void BPF_STRUCT_OPS(mini_enqueue, struct task_struct *p, u64 enq_flags)
{
        scx_bpf_dsq_insert(p, SHARED_DSQ, SCX_SLICE_DFL, enq_flags);
}

/* A CPU ran out of work: pull the next task from the shared FIFO */
void BPF_STRUCT_OPS(mini_dispatch, s32 cpu, struct task_struct *prev)
{
        scx_bpf_dsq_move_to_local(SHARED_DSQ, 0);
}

s32 BPF_STRUCT_OPS_SLEEPABLE(mini_init)
{
        return scx_bpf_create_dsq(SHARED_DSQ, -1);   /*
Полный SKILL.md на GitHub

Установить sched-ext в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл sched-ext?

sched_ext skill for Linux CPU schedulers written in BPF. Use when enabling CONFIG_SCHED_CLASS_EXT, running scx schedulers such as scx_lavd or scx_bpfland, writing a custom BPF scheduler with dispatch queues, debugging a scheduler that stalls or gets ejected, or measuring scheduling latency. Activates on queries about sched_ext, SCX, scx_simple, scx_lavd, scx_bpfland, scx_rusty, scxcli, sched_ext_ops, dispatch queues, scx_bpf_dsq_insert, or BPF CPU schedulers.

Как установить скилл sched-ext?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл sched-ext запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить sched-ext с