CachyOS sched ext Tutorial - ryzendew/Linux-Tips-and-Tricks GitHub Wiki

CachyOS sched-ext Tutorial

Complete beginner-friendly guide to sched-ext (extensible scheduler framework) on CachyOS, including installation, configuration, and custom scheduler usage.


Table of Contents

  1. Understanding sched-ext
  2. Installing sched-ext Kernel
  3. Using sched-ext
  4. Custom Schedulers
  5. Troubleshooting

Understanding sched-ext

What is sched-ext?

sched-ext (scheduler extensibility) is a framework for custom CPU schedulers.

What it does:

  • Custom schedulers: Allows custom CPU schedulers
  • User-space: Schedulers run in user-space
  • Flexible: Highly customizable
  • Experimental: Advanced feature

Why use sched-ext:

  • Custom scheduling: Create custom schedulers
  • Research: Test scheduler algorithms
  • Optimization: Optimize for specific workloads
  • Learning: Learn about CPU scheduling

sched-ext vs Standard Schedulers

Standard schedulers:

  • BORE: Burst-Oriented Response Enhancer
  • EEVDF: Earliest Eligible Virtual Deadline First
  • Built-in: Part of kernel

sched-ext:

  • Extensible: Framework for custom schedulers
  • User-space: Schedulers outside kernel
  • Flexible: More customization

Installing sched-ext Kernel

Install Kernel

Install sched-ext kernel:

sudo pacman -S linux-cachyos-sched-ext linux-cachyos-sched-ext-headers

What this does:

  • Installs sched-ext kernel
  • Installs kernel headers
  • Makes sched-ext available

Reboot:

sudo reboot

What this does:

  • Reboots into sched-ext kernel
  • Activates sched-ext framework
  • Ready to use

Verify Installation

Check kernel:

uname -r

What this does:

  • Shows kernel version
  • Should show sched-ext kernel
  • Verifies installation

Check sched-ext:

ls /sys/fs/sched_ext/

What this does:

  • Lists sched-ext filesystem
  • Verifies sched-ext is available
  • Shows sched-ext is working

Using sched-ext

Basic Usage

sched-ext requires custom schedulers to be loaded.

Load scheduler:

echo scheduler-name > /sys/fs/sched_ext/current

What this does:

  • Loads custom scheduler
  • Activates scheduler
  • Applies to system

Check current scheduler:

cat /sys/fs/sched_ext/current

What this does:

  • Shows current scheduler
  • Verifies scheduler is loaded
  • Confirms activation

Example Schedulers

sched-ext comes with example schedulers.

List available schedulers:

  • Check sched-ext documentation
  • Look for scheduler examples
  • Custom schedulers available

Custom Schedulers

Creating Custom Schedulers

sched-ext allows creating custom schedulers.

Requirements:

  • Kernel headers: For compilation
  • Development tools: Compiler, build tools
  • sched-ext knowledge: Understanding of scheduling

Basic scheduler:

  • Written in C or Rust
  • Implements scheduler interface
  • Loaded via sched-ext

Loading Custom Scheduler

Load scheduler:

./custom-scheduler

What this does:

  • Runs custom scheduler
  • Loads into sched-ext
  • Activates scheduler

Or via sysfs:

echo custom-scheduler > /sys/fs/sched_ext/current

Troubleshooting

Scheduler Not Loading

Check sched-ext:

ls /sys/fs/sched_ext/

What this does:

  • Verifies sched-ext is available
  • Checks filesystem exists
  • Helps troubleshoot

Check kernel:

uname -r | grep sched-ext

What this does:

  • Verifies sched-ext kernel
  • Confirms correct kernel
  • Helps identify issues

Performance Issues

Monitor performance:

htop

What this does:

  • Shows system performance
  • Monitors CPU usage
  • Helps identify issues

Switch back to standard scheduler:

echo "" > /sys/fs/sched_ext/current

What this does:

  • Unloads custom scheduler
  • Returns to default scheduler
  • Restores normal operation

Additional Resources


Summary

This guide covered:

  1. Understanding sched-ext - What sched-ext is
  2. Installing kernel - Installing sched-ext kernel
  3. Using sched-ext - Basic usage
  4. Custom schedulers - Creating and loading schedulers
  5. Troubleshooting - Common issues

Key Takeaways:

  • sched-ext allows custom CPU schedulers
  • Requires sched-ext kernel
  • Advanced feature for power users
  • Allows custom scheduling algorithms
  • Use for research and optimization
  • Can switch back to standard scheduler

This guide is based on the CachyOS Wiki and expanded with detailed explanations for beginners. For the most up-to-date sched-ext information, always refer to the official CachyOS documentation.