SchedX-Agent is a Linux adaptive resource-control Agent for mixed workloads. It probes /proc, classifies user-space workloads, detects sched_ext/scx availability, and applies safe cgroup v2 CPU controls with rollback and reproducible benchmark reporting.
Current verified platform: openEuler 24.03 LTS SP4 with cgroup v2 and the
config-rebuilt kernel 6.6.0-159.4.3.154.oe2403sp4.schedx1. The stock SP4
kernel remains installed and is supported through the cgroup-only fallback
mode because its binary config does not enable CONFIG_SCHED_CLASS_EXT.
Competition Submission
The master branch root contains the official preliminary-round deliverables:
README.md
SchedX-Agent_项目说明书.docx
SchedX-Agent_项目介绍.pptx
操作系统开源创新大赛 作品原创承诺书.docx
项目展示.mp4
THIRD_PARTY_NOTICES.md
code_origin_stats.md
Canonical source code lives in schedx/, scx/, ebpf/, and scripts/.
Reproducibility material lives in kernel/, tests/, results/, reports/,
and docs/. Root-level source copies, editing prompts, template copies, and
submission ZIP archives are intentionally excluded to avoid stale duplicates.
Current Status
Verified on openEuler:
schedx status detects cgroup v2 and reports native sched_ext availability.
schedx classify identifies:
nginx / redis-server as latency_sensitive
stress-ng / stress-ng-cpu as background_noise
schedx optimize --target stress-ng --mode isolate_background moves stress-ng PIDs into /sys/fs/cgroup/schedx/pid-<pid>/ and sets cpu.weight=50.
schedx rollback restores previous CPU weights and removes empty pid-* cgroups. The base /sys/fs/cgroup/schedx cgroup is removed when no workload remains.
schedx benchmark nginx runs a three-phase nginx + stress-ng experiment and generates summary.csv, summary.json, raw wrk output, cgroup snapshots, and report.md.
The SP4 VM passes 141 tests and the fairness-gated native sched_ext run
reports 62.18% higher RPS, 33.74% lower P99, 32.22% background CPU
retention and nr_rejected=0.
A real wrk canary accepted a policy with 13.32% higher RPS, 92.82% lower
P99 and 81.86% background progress retention. A stricter valid gate also
exercised automatic rollback and left no cgroup or scx task-policy residue.
The formal four-way ablation reports 86.66% higher RPS and 72.33% lower
P99 for the combined Agent while retaining 43.92% of background progress.
In the formal sysbench scenario, CPU interference reduces throughput by
46.71%; SchedX recovers 64.54% versus the interference phase, reduces
P95 latency from 2.97 ms to 0.37 ms, and retains 27.19% of background
progress. The result passes the configured 25% fairness floor.
flowchart LR
P[Probe Skills] --> A[Analyze Skills]
A --> C[Workload Classifier]
C --> RT[Time-weighted Policy Router]
PR[Expert Policy Repository] <--> RT
RT --> PL[Policy Planner]
PL --> EX[Safe Action Executor]
PL --> CB[Baseline SLO Canary]
CB --> EX
EX --> CG[cgroup v2 Controller]
EX --> SCX[scx Controller Detection]
EX --> CC[Candidate SLO Canary]
CC --> V[Canary Verifier]
V -->|accepted outcome| PR
V -->|regression| RB
CG --> RB[Rollback Store]
EX --> B[Benchmark Runner]
B --> R[Report Generator]
Commands
schedx status: print platform, cgroup v2, and sched_ext status.
schedx policies: list the allowlisted expert policy catalog and canary outcomes.
schedx probe: collect process, pressure, sched, and cgroup signals.
schedx classify: classify workloads and include rule reasons.
schedx optimize: apply structured cgroup actions or show them with --dry-run.
schedx control: manually move a PID into a managed cgroup and set CPU controls.
schedx rollback: restore recorded CPU settings and clean empty SchedX cgroups.
schedx benchmark: run benchmark tools and the nginx mixed workload experiment.
schedx report: generate a Markdown report from result JSON files.
schedx tool-run: execute one AI Agent tool call with an ephemeral cgroup,
native sched_ext policy, resource-intent profile, metrics, and feedback.
Adaptive Mixture Of Policies
Automatic rule and LLM proposals pass through a bounded, time-weighted router
before execution. The router uses exponential decay, a confidence threshold,
and a six-second switch cooldown to avoid policy thrashing. After cooldown, a
new expert must remain the winner for two consecutive observations before the
router switches. Explicit CLI modes always bypass automatic routing.
The built-in allowlisted experts are:
Expert
SchedX mode
Purpose
latency_guard
latency_first
Protect nginx, Redis, and other latency-sensitive services.
Inspect the catalog and historical canary outcomes without root privileges:
schedx policies
The router selects an internal policy mode implemented by the existing
scx_agent; it never executes a repository entry as a command. When benchmark
or the CLI enables a real wrk baseline/candidate canary, verification
rejects sched_ext task rejections, background starvation, P99 regressions, and
throughput regressions. A rejected canary enters the existing rollback path;
missing objective metrics are recorded separately as inconclusive rather than
as a successful policy outcome.
Enable the real service-SLO closed loop explicitly:
SchedX runs wrk before and after the candidate policy, measures RPS and P99,
tracks classified background-process CPU progress, checks nr_rejected, and
rolls back both cgroup and persistent scx task policies when a safety gate
fails. Canary execution is skipped during --dry-run.
Agent Tool-Call Resource Control
SchedX treats each test, compile, package installation, interactive command, or
background job as an independent resource-control unit:
The experiment runs the same tool call under full CPU contention and reports
tool-call latency, success rate, native sched_ext activation, and background
CPU retention.
Persistent sched_ext Daemon
For concurrent Agents, one systemd-managed daemon owns the sched_ext struct_ops
link and exposes serialized policy updates over /run/schedx/scx-daemon.sock.
Each tool-run registers and removes only its own PID policy.
When the daemon is unavailable, tool-run retains its standalone sched_ext and
cgroup-only fallback paths.
The daemon also applies PSI-driven cross-class fairness. Tool calls register
their ephemeral cgroup rather than a single PID, so all descendants inherit the
sched_ext class and weighted-vtime policy:
The adaptive scheduler preserves a configurable background service floor while
keeping latency work preferred. Runtime and formal benchmarks now share the
same initial background service interval of 64; the daemon adjusts it from
observed runtime share instead of starting from the old unvalidated 2048.
Each managed cgroup exposes scheduler-level enqueues, runs, runtime_ns,
and wait_ns. The daemon uses runtime-share deltas for closed-loop tuning, and
the metrics are included in each tool-run JSON result:
The latest fairness-gated SP4 comparison uses 10-second samples and 3 repeats.
It reports 62.18% higher mean RPS, 33.74% lower mean P99 and 32.22%
background CPU retention against a required minimum of 25%.
DeepSeek V4 Policy Agent
SchedX can use deepseek-v4-pro as a real policy-planning Agent. The model
receives workload classification, PSI, CPU topology, native sched_ext status,
and a safe rule-based baseline. It returns a strict JSON policy proposal.
The proposal cannot execute commands directly. SchedX validates the mode,
target process, parameter names, quotas, weights, and nice ranges before the
existing Policy/Act/Verify/Rollback pipeline can use it. API failures or unsafe
proposals automatically fall back to the deterministic rule engine.
The one-click demo runs environment preflight, four-way nginx ablation, batch
throughput, accepted and rejected SLO canaries, cleanup verification, and report
generation. The default remains an offline-compatible rule-policy path:
sudo bash scripts/run_competition_demo.sh
For the judge-facing Agent-first demonstration, load the protected LLM
configuration and enable the compact decision trace:
set -a
source /etc/schedx/llm.env
set +a
sudo --preserve-env=SCHEDX_LLM_API_KEY,SCHEDX_LLM_MODEL,SCHEDX_LLM_BASE_URL \
bash scripts/run_competition_demo.sh --llm-policy --compact
This path records the LLM proposal, learned expert route, Skill phases, Canary
verdict, and rollback summary in agent-trace.json. The first Canary exercises
an accepted policy. The second applies the policy and then requires a 99.9% P99
latency improvement, intentionally demonstrating a post-action SLO rejection and
automatic rollback without fabricating benchmark results.
The default is a short presentation run. Use the formal profile for repeated
20-second measurements:
native sched_ext fairness-gated result: 62.18% RPS gain, 33.74% P99
reduction and 32.22% background CPU retention;
DeepSeek-guided policy result: 84.96% RPS gain and 55.16% P99 reduction;
multi-Agent LLM experiment: 6/6 tools used native sched_ext through daemon mode;
final daemon state after validation: sched_ext=enabled, scheduler schedx_agent, nr_rejected=0.
The ablation compares default, cgroup_only, scx_only, and
agent_combined. It records background CPU retention and marks a row invalid
for performance claims when the configured fairness floor is not met.
test ! -d /sys/fs/cgroup/schedx && echo cleanup-ok
Example Result
One openEuler smoke-test run with duration=5, connections=8, threads=2, repeats=1, stress_cpu=4 produced:
Phase
Requests/sec
Avg Latency ms
P99 ms
Baseline
94626.15
0.0935
0.58
Interference
35430.07
0.735
4.20
SchedX
36266.89
0.626
4.07
The run showed 62.56% RPS drop under interference, 2.36% RPS recovery with SchedX, 14.83% average-latency reduction versus interference, and successful cgroup cleanup. Results are not fabricated; benchmark output is saved under the timestamped result directory.
Safety Model
SchedX-Agent executes structured actions only. It does not execute model-generated shell commands. The isolate policy protects control-plane processes such as schedx, python -m schedx, bash, sshd, systemd, NetworkManager, firewalld, and tuned.
cgroup writes are recorded in .schedx/rollback.json before mutation, and
persistent scx task policies are recorded in .schedx/scx_rollback.json.
schedx rollback removes both policy types, restores recorded values and
removes empty /sys/fs/cgroup/schedx/pid-* groups. If a process is still alive,
cleanup is skipped with a reason such as process_still_alive.
sched_ext/scx
SchedX-Agent detects /sys/kernel/sched_ext and reports whether sched_ext is
available. scx/scx_agent.bpf.c is a native sched_ext_ops scheduler with
class-specific dispatch queues for latency, default/batch, and background
tasks. The stock openEuler SP4 kernel automatically uses the cgroup-only
fallback.
The SP4 source RPM already contains sched_ext source code. The reproducible
config-only kernel rebuild, source checksum, installation dry-run and stock
kernel rollback procedure are under
kernel/openEuler-24.03-LTS-SP4/README.md.
SchedX-Agent
SchedX-Agent is a Linux adaptive resource-control Agent for mixed workloads. It probes
/proc, classifies user-space workloads, detects sched_ext/scx availability, and applies safe cgroup v2 CPU controls with rollback and reproducible benchmark reporting.Current verified platform: openEuler 24.03 LTS SP4 with cgroup v2 and the config-rebuilt kernel
6.6.0-159.4.3.154.oe2403sp4.schedx1. The stock SP4 kernel remains installed and is supported through the cgroup-only fallback mode because its binary config does not enableCONFIG_SCHED_CLASS_EXT.Competition Submission
The
masterbranch root contains the official preliminary-round deliverables:README.mdSchedX-Agent_项目说明书.docxSchedX-Agent_项目介绍.pptx操作系统开源创新大赛 作品原创承诺书.docx项目展示.mp4THIRD_PARTY_NOTICES.mdcode_origin_stats.mdCanonical source code lives in
schedx/,scx/,ebpf/, andscripts/. Reproducibility material lives inkernel/,tests/,results/,reports/, anddocs/. Root-level source copies, editing prompts, template copies, and submission ZIP archives are intentionally excluded to avoid stale duplicates.Current Status
Verified on openEuler:
schedx statusdetects cgroup v2 and reports native sched_ext availability.schedx classifyidentifies:nginx/redis-serveraslatency_sensitivestress-ng/stress-ng-cpuasbackground_noiseschedx optimize --target stress-ng --mode isolate_backgroundmoves stress-ng PIDs into/sys/fs/cgroup/schedx/pid-<pid>/and setscpu.weight=50.schedx rollbackrestores previous CPU weights and removes emptypid-*cgroups. The base/sys/fs/cgroup/schedxcgroup is removed when no workload remains.schedx benchmark nginxruns a three-phase nginx + stress-ng experiment and generatessummary.csv,summary.json, raw wrk output, cgroup snapshots, andreport.md.141tests and the fairness-gated native sched_ext run reports62.18%higher RPS,33.74%lower P99,32.22%background CPU retention andnr_rejected=0.13.32%higher RPS,92.82%lower P99 and81.86%background progress retention. A stricter valid gate also exercised automatic rollback and left no cgroup or scx task-policy residue.86.66%higher RPS and72.33%lower P99 for the combined Agent while retaining43.92%of background progress.46.71%; SchedX recovers64.54%versus the interference phase, reduces P95 latency from2.97 msto0.37 ms, and retains27.19%of background progress. The result passes the configured25%fairness floor.Quick Start
Dry-run is explicit. Commands that change cgroups execute for real unless
--dry-runis passed:Documentation
Architecture
Commands
schedx status: print platform, cgroup v2, and sched_ext status.schedx policies: list the allowlisted expert policy catalog and canary outcomes.schedx probe: collect process, pressure, sched, and cgroup signals.schedx classify: classify workloads and include rule reasons.schedx optimize: apply structured cgroup actions or show them with--dry-run.schedx control: manually move a PID into a managed cgroup and set CPU controls.schedx rollback: restore recorded CPU settings and clean empty SchedX cgroups.schedx benchmark: run benchmark tools and the nginx mixed workload experiment.schedx report: generate a Markdown report from result JSON files.schedx tool-run: execute one AI Agent tool call with an ephemeral cgroup, native sched_ext policy, resource-intent profile, metrics, and feedback.Adaptive Mixture Of Policies
Automatic rule and LLM proposals pass through a bounded, time-weighted router before execution. The router uses exponential decay, a confidence threshold, and a six-second switch cooldown to avoid policy thrashing. After cooldown, a new expert must remain the winner for two consecutive observations before the router switches. Explicit CLI modes always bypass automatic routing.
The built-in allowlisted experts are:
latency_guardlatency_firstthroughput_boostthroughput_firstbackground_isolationisolate_backgroundbalancedbalancedInspect the catalog and historical canary outcomes without root privileges:
The router selects an internal policy mode implemented by the existing
scx_agent; it never executes a repository entry as a command. When benchmark or the CLI enables a real wrk baseline/candidate canary, verification rejects sched_ext task rejections, background starvation, P99 regressions, and throughput regressions. A rejected canary enters the existing rollback path; missing objective metrics are recorded separately as inconclusive rather than as a successful policy outcome.Enable the real service-SLO closed loop explicitly:
SchedX runs wrk before and after the candidate policy, measures RPS and P99, tracks classified background-process CPU progress, checks
nr_rejected, and rolls back both cgroup and persistent scx task policies when a safety gate fails. Canary execution is skipped during--dry-run.Agent Tool-Call Resource Control
SchedX treats each test, compile, package installation, interactive command, or background job as an independent resource-control unit:
Example:
The wrapper automatically:
AGENT_RESOURCE_HINTAgent-to-OS intent protocol;cpu.weight,cpu.max,memory.high,memory.max, andpids.max;memory.peak, memory events, and peak PIDs;next_resource_hintfor the Agent’s next planning round;[schedx-feedback]messages when memory pressure, OOM, CPU throttling, or command failure is detected.Run the reproducible demonstration:
Run the formal unmanaged-versus-managed Agent tool-call experiment:
The experiment runs the same tool call under full CPU contention and reports tool-call latency, success rate, native sched_ext activation, and background CPU retention.
Persistent sched_ext Daemon
For concurrent Agents, one systemd-managed daemon owns the sched_ext struct_ops link and exposes serialized policy updates over
/run/schedx/scx-daemon.sock. Eachtool-runregisters and removes only its own PID policy.When the daemon is unavailable,
tool-runretains its standalone sched_ext and cgroup-only fallback paths.The daemon also applies PSI-driven cross-class fairness. Tool calls register their ephemeral cgroup rather than a single PID, so all descendants inherit the sched_ext class and weighted-vtime policy:
The adaptive scheduler preserves a configurable background service floor while keeping latency work preferred. Runtime and formal benchmarks now share the same initial background service interval of
64; the daemon adjusts it from observed runtime share instead of starting from the old unvalidated2048.Each managed cgroup exposes scheduler-level
enqueues,runs,runtime_ns, andwait_ns. The daemon uses runtime-share deltas for closed-loop tuning, and the metrics are included in eachtool-runJSON result:The latest fairness-gated SP4 comparison uses 10-second samples and 3 repeats. It reports
62.18%higher mean RPS,33.74%lower mean P99 and32.22%background CPU retention against a required minimum of25%.DeepSeek V4 Policy Agent
SchedX can use
deepseek-v4-proas a real policy-planning Agent. The model receives workload classification, PSI, CPU topology, native sched_ext status, and a safe rule-based baseline. It returns a strict JSON policy proposal.The proposal cannot execute commands directly. SchedX validates the mode, target process, parameter names, quotas, weights, and nice ranges before the existing Policy/Act/Verify/Rollback pipeline can use it. API failures or unsafe proposals automatically fall back to the deterministic rule engine.
Store credentials outside the repository:
Run the formal DeepSeek-versus-rule scheduling comparison:
Competition Demo And Final Report
The one-click demo runs environment preflight, four-way nginx ablation, batch throughput, accepted and rejected SLO canaries, cleanup verification, and report generation. The default remains an offline-compatible rule-policy path:
For the judge-facing Agent-first demonstration, load the protected LLM configuration and enable the compact decision trace:
This path records the LLM proposal, learned expert route, Skill phases, Canary verdict, and rollback summary in
agent-trace.json. The first Canary exercises an accepted policy. The second applies the policy and then requires a 99.9% P99 latency improvement, intentionally demonstrating a post-action SLO rejection and automatic rollback without fabricating benchmark results.The default is a short presentation run. Use the formal profile for repeated 20-second measurements:
Run either experiment independently:
Generate the judge-facing summary report:
Current verified highlights:
62.18%RPS gain,33.74%P99 reduction and32.22%background CPU retention;84.96%RPS gain and55.16%P99 reduction;6/6tools used native sched_ext through daemon mode;sched_ext=enabled, schedulerschedx_agent,nr_rejected=0.The ablation compares
default,cgroup_only,scx_only, andagent_combined. It records background CPU retention and marks a row invalid for performance claims when the configured fairness floor is not met.Latest formal artifacts:
Nginx Mixed Workload Benchmark
Install and start nginx:
Install wrk if needed:
Run the reproducible three-phase experiment:
The benchmark creates a timestamped directory:
Check cleanup:
Example Result
One openEuler smoke-test run with
duration=5,connections=8,threads=2,repeats=1,stress_cpu=4produced:The run showed 62.56% RPS drop under interference, 2.36% RPS recovery with SchedX, 14.83% average-latency reduction versus interference, and successful cgroup cleanup. Results are not fabricated; benchmark output is saved under the timestamped result directory.
Safety Model
SchedX-Agent executes structured actions only. It does not execute model-generated shell commands. The isolate policy protects control-plane processes such as
schedx,python -m schedx,bash,sshd,systemd,NetworkManager,firewalld, andtuned.cgroup writes are recorded in
.schedx/rollback.jsonbefore mutation, and persistent scx task policies are recorded in.schedx/scx_rollback.json.schedx rollbackremoves both policy types, restores recorded values and removes empty/sys/fs/cgroup/schedx/pid-*groups. If a process is still alive, cleanup is skipped with a reason such asprocess_still_alive.sched_ext/scx
SchedX-Agent detects
/sys/kernel/sched_extand reports whether sched_ext is available.scx/scx_agent.bpf.cis a nativesched_ext_opsscheduler with class-specific dispatch queues for latency, default/batch, and background tasks. The stock openEuler SP4 kernel automatically uses the cgroup-only fallback.The SP4 source RPM already contains sched_ext source code. The reproducible config-only kernel rebuild, source checksum, installation dry-run and stock kernel rollback procedure are under
kernel/openEuler-24.03-LTS-SP4/README.md.