Repository navigation
Proposal: Decoupled & Independent Scheduler Distribution (pkgscx) #3598
SoongVilda
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Design: Decoupled Scheduler Binary Distribution (
pkgscx)Overview
The current
sched-ext/scxrepository already supports building and releasing schedulers independently at the Cargo package level. Individual schedulers live as separate crates underscheds/rust/*, can be built with commands such ascargo build --release -p scx_rusty, and some may be published tocrates.ioforcargo install.The remaining gap is different: users who want fast scheduler updates still need either a local Rust/BPF build environment,
cargo installfrom source, or downstream distribution packages. That is inconvenient for fast-moving scheduler experimentation, especially when distributions intentionally move more slowly than upstream scheduler development.pkgscxis proposed as a small Rust CLI for discovering, verifying, installing, updating, and rolling back prebuilt scx scheduler binaries independently from the base system package. It should complement existing distro packages and Cargo-based source distribution rather than replace them.The first version should integrate with the current
scxcodebase reality:/etc/default/scxand executesSCX_SCHEDULERdirectly;scx_loaderdaemon,/etc/scx_loader/config.toml,scxctl, or a D-Bus control API;scx_utils::compatand remain the final source of truth.The design goal is to keep package installation as a mechanism and leave runtime policy — which scheduler is active, with what flags, and when services restart — under administrator control.
1. Goals and Non-Goals
Goals
scxrelease, Cargo, CI, and runtime compatibility mechanisms where possible.Non-Goals for v1
pacman,dnf,apt,zypper, or Nix./etc/default/scxautomatically unless the user explicitly requests an integration command.scx.serviceautomatically during install or update.scx_loaderdaemon; none exists in the current repository.2. Current
scxIntegration ModelThe current service model in this repository is simple:
The default configuration file uses variables like:
SCX_SCHEDULER=scx_cosmos SCX_FLAGS=''Therefore, v1 integration should treat installed schedulers as normal executables. An administrator can select a
pkgscx-managed scheduler by either using an absolute path:or by adding
/var/lib/pkgscx/binahead of/usr/binin the servicePATHthrough an explicit systemd drop-in.pkgscx installshould install files only. It should not silently change the running scheduler.3. Architecture
flowchart TD A["channels.list"] --> B["pkgscx"] C["remote signed registry"] --> B B --> D["artifact verification"] D --> E["pkgscx store"] E --> F["bin symlinks"] F --> G["existing scx.service"] H["/etc/default/scx"] --> G G --> I["scheduler binary"] I --> J["scx_utils compatibility checks"] J --> K["libbpf and kernel verifier"] K --> L["sched_ext kernel runtime"]Components
pkgscxCLIResponsible for:
/var/lib/pkgscx/bin;Not responsible for:
/etc/default/scxby default;Existing runtime
The runtime remains the scheduler binary itself, launched directly by an administrator, a shell, or
scx.service.The binary performs its existing runtime checks through
scx_utils::compatand libbpf before attaching the scheduler to the kernel.4. Local Storage Model
A pure “directory of binaries is the database” model is attractive, but it is too weak for signed artifacts, rollback, provenance, and multiple target triples. Instead,
pkgscxshould use a file-tree store without a central SQLite/BerkeleyDB-style package database.Recommended layout:
This keeps the “files are the database” property while preserving enough information for safe operations:
/var/lib/pkgscx/store;/var/lib/pkgscx/bin;Atomic install/update
Installation should be staged and then atomically activated:
/var/lib/pkgscx/store/...;/var/lib/pkgscx/bin/scx_namesymlink.A failed install must leave the previous active symlink untouched.
5. Configuration
Channel list
Registry channels should be configured in a simple text file:
Each non-empty, non-comment line is a registry URL:
This is intentionally easy to inspect and manage with normal Unix tools.
Tool configuration
A small TOML file may hold non-channel settings:
The channel list remains separate because administrators often want to manage repository subscriptions independently from tool behavior.
6. CLI Design
Output behavior
stderrand produce non-zero exit codes.--quietis passed.Example:
$ pkgscx list --json [ { "name": "scx_rusty", "version": "1.1.1", "target": "x86_64-unknown-linux-gnu", "active_path": "/var/lib/pkgscx/bin/scx_rusty", "status": "installed" } ]7. Registry and Artifact Format
The registry should be a signed static index. A static JSON file is easy to host on GitHub Pages, an object store, a CDN, or a distribution mirror.
Example shape:
{ "registry_version": 1, "generated_at": "2026-07-01T00:00:00Z", "channel": "stable", "artifacts": [ { "name": "scx_rusty", "version": "1.1.1", "source_repo": "https://github.com/sched-ext/scx", "source_revision": "<git-sha>", "cargo_package": "scx_rusty", "target": "x86_64-unknown-linux-gnu", "libc": "glibc", "url": "https://example.org/scx/scx_rusty-1.1.1-x86_64-unknown-linux-gnu.tar.zst", "sha256": "<artifact-sha256>", "signature": "<artifact-signature-url-or-inline-reference>", "compat": { "min_kernel_version_hint": "6.12", "required_struct_fields": [ { "type": "sched_ext_ops", "field": "dump" } ], "optional_struct_fields": [ { "type": "sched_ext_ops", "field": "sub_cgroup_id", "fallback": "disable_or_downgrade_feature" } ], "ci_tested_kernels": [ "linux-rolling-stable", "linux-6.16.y", "linux-6.18.y" ] } } ] }Required registry fields
Each artifact entry should include at least:
Artifact contents
A scheduler artifact should contain:
The binary should be executable and should not require post-install scripts.
8. Signing and Trust Model
This is the most security-sensitive part of the design. Scheduler binaries run with high privilege and load BPF programs into the kernel.
pkgscxmust treat unsigned binaries as unsafe by default.Recommended policy:
--allow-untrusted-channelor equivalent explicit opt-in.Possible implementation choices:
minisign/signifystyle detached signatures;For a first implementation, detached signatures plus pinned trusted public keys are simpler. A TUF-like model can be added later if the ecosystem grows.
9. Compatibility Model
Compatibility should be split into two layers.
Layer 1: install-time filtering
pkgscxcan reject obviously incompatible artifacts before installation. It can safely check:/sys/kernel/sched_ext;The kernel version should be treated as advisory. Distro kernels may backport features or carry patches, so exact feature tests are better than version checks when available.
pkgscxshould not require root-only checks for ordinary metadata queries. For system-wide installation under/var/lib/pkgscx, privilege is needed to write files, but compatibility inspection should remain as unprivileged as possible.Layer 2: execution-time validation
The scheduler binary remains the final authority. Existing
scxcode already performs runtime checks throughscx_utils::compatand libbpf, including:sched_ext_opsfields such asdump;sub_cgroup_idand applying fallback behavior where implemented;If registry metadata is wrong or a binary is copied manually, runtime loading must still fail safely and loudly before attaching an incompatible scheduler.
Important wording
Do not claim install-time metadata “ensures absolute kernel safety.” It reduces avoidable mistakes. The real safety boundary is the combination of scheduler runtime checks, libbpf, the BPF verifier, and the kernel implementation.
10. Source Metadata in
Cargo.tomlIt is reasonable to declare scheduler compatibility metadata in each scheduler crate, but the implementation must account for how Cargo actually works.
Cargo does not automatically expose arbitrary
[package.metadata]keys asCARGO_PKG_METADATA_*environment variables tobuild.rs.Instead, one of these approaches is needed.
Preferred v1: generate registry metadata with
xtaskExtend
tools/xtaskwith a command such as:The command can use
cargo metadatato read package names, versions, existing[package.metadata.scx]data, source paths, publish flags, and workspace membership.This fits the existing repository because
tools/xtaskalready exists and already usescargo_metadatafor workspace introspection.Optional later: embed metadata in binaries
If binary self-description is needed, add a shared helper in
scx_cargoor schedulerbuild.rsfiles that explicitly reads metadata and emits compiler environment variables:Then
scx_utilscan expose that data through one of these mechanisms:--metadata-jsonor--version --jsoncommand-line mode;The current codebase does not implement a
.note.scx.compatsection, so that should be described as future work rather than an existing feature.Suggested metadata namespace
Because
[package.metadata.scx]is already used for CI-related settings, compatibility metadata should live in a subtable:Compatibility metadata should distinguish between:
11. Rollback Semantics
Rollback should be precise about what changes.
pkgscx rollback scx_rustyshould switch/var/lib/pkgscx/bin/scx_rustyback to an older retained version. This affects the next scheduler start.It does not affect an already-running scheduler process unless the administrator separately restarts the service or stops and starts the scheduler.
Possible UX:
Cache policy:
Nversions per scheduler and target triple;N = 3;12. Integration Commands
Although ordinary install/update operations should not edit system runtime policy, explicit integration helpers are useful.
Examples:
Generated guidance might look like:
or, if using PATH precedence:
SCX_SCHEDULER=scx_rusty SCX_FLAGS=''Any command that writes to
/etcor changes systemd configuration should be explicit, privileged, and reversible.13. Future Loader Integration
If a separate
scx_loaderdaemon becomes available or is targeted as an external project,pkgscxcan integrate with it later.Potential future features:
/var/lib/pkgscx/bin;These should be treated as future work. The v1 proposal should not depend on them.
14. Roadmap
Phase 1: registry generation and artifact policy
tools/xtaskto generate registry metadata from Cargo workspace data and optional[package.metadata.scx.compat]tables.Phase 2: initial
pkgscxCLIrefresh,search,info,install,list,remove,rollback, andupgrade.--jsonfor query commands./var/lib/pkgscxand optional user-local installation.Phase 3: compatibility improvements
--metadata-jsonconvention.scx_cargo/scx_utilsmechanism.Phase 4: explicit runtime integration helpers
/etc/default/scxsnippet generation.15. Open Questions
Official vs third-party channels
Should there be an official upstream registry, or should this be distribution-maintained first? A distro-maintained registry may be easier to secure and support initially.
Trust root distribution
Should trusted signing keys be shipped by distro packages, embedded in
pkgscx, or configured manually by administrators?Static vs dynamic linking
Should artifacts be fully static where possible, or should they target common distro ABIs such as
x86_64-unknown-linux-gnuwith documented dynamic library requirements?Kernel feature metadata
What is the minimum useful compatibility schema that avoids becoming a second, inaccurate copy of libbpf/kernel feature checks?
Yanking and deprecation
Should the registry support yanked versions, expiration dates, or warnings for scheduler builds known to be unsafe or incompatible with newer kernels?
Running scheduler upgrades
Should
pkgscx upgradewarn if the upgraded scheduler is currently running? Should there be an explicit--restart-serviceflag, or should service management remain completely outsidepkgscx?Summary
pkgscxis a strong idea if framed as a signed binary artifact manager for standalonescxscheduler binaries. The currentscxcodebase already supports per-scheduler crates and runtime compatibility checks, so the proposal should build on those facts instead of assuming a loader daemon that is not present.A practical v1 should:
/var/lib/pkgscx;/var/lib/pkgscx/bin;/etc/default/scxandscx.servicemodel;All reactions