Using the SCHED_DEADLINE scheduler

This page collects the material used for presenting SCHED_DEADLINE at TuToR 2017, and describes some experiments and exercises with this scheduler.

SCHED_DEADLINE: a real-time CPU scheduler for Linux

SCHED_DEADLINE is a scheduling policy for the Linux kernel, implementing a scheduler based on Earliest Deadline First and the Constant Bandwidth Server (CBS). It supports multiple CPUs and uses global EDF by default, but allows to use partitioned EDF with a little bit of configuration trickeries.

Since it is part of the standard Linux kernel, SCHED_DEADLINE can be easily used without having to install additional software.

Here are some slides introducing this scheduling class and its usage.

The Tutorial

This tutorial will explain how to use the SCHED_DEADLINE scheduling class in your programs, and how to use standard tools to schedule unmodified programs with SCHED_DEADLINE.

This will be done through a set of simple exercises and experiments, based on the development and usage of some simple programs exploiting the SCHED_DEADLINE scheduling class.

The SCHED_DEADLINE policy is included in the vanilla Linux kernel, hence it is available without installing any additional software: any recent Linux distribution (Ubuntu is recommended) is ok for the tutorial.

Since in the tutorial the real-time performance of the scheduler will be exercized, running SCHED_DEADLINE in a VM is not recommended (it would require some additional care to execute the host kernel in real-time).

When running the experiments on a laptop, it is important to disable the CPU frequency scaling mechanism (support for frequency scaling in SCHED_DEADLINE is being worked on, but it is still work in progress...). If you use an Intel CPU, you can be do this by disabling the turbo mechanism and fixing the CPU power state:

cd /sys/devices/system/cpu/intel_pstate
echo  1 > no_turbo
echo 40 > min_perf_pct
echo 40 > max_perf_pct
       

In order to attend the tutorial it is useful to install some additional programs to be used for testing / exercizing the scheduler.

Some of the experiments will be performed by using the rt-app application. The participants are hence encouraged to install it in advance: just clone the sources from github and compile it as described in the README. Remember to configure with the "--with-deadline" switch (note that you need to install autoconf, automake, libtool and libjson-c on your system). Regarding libjson-c, the rt-app README file is slightly misleading: it mentions "libjson-c", but to compile rt-app you actually need to install the development files for the library. On debian or ubuntu, this is the "libjson-c-dev" package (the package name might be different on other distributions, but generally contains the "-dev" or "-devel" suffix). As an alternative, you can install the libjson-c library from source. The rt-app program accepts taskset descriptions in json format; here are two simple examples: test1.json and test2.json.

Some simpler source code will also be used to show how to programmatically use SCHED_DEADLINE in your programs (just download the tarball).

Finally, in the tutorial it will be shown how to use SCHED_DEADLINE to schedule the vcpu threads of a KVM-based virtual machine to implement hierarchical real-time scheduling (SCHED_DEADLINE will be used on the host, and some real-time tasks will be executed in the guest). Hence, the attenders are encouraged to install Qemu/KVM (it is packaged by all the major Linux distributions) in their laptop and to download the guest kernel and filesystem that will be used.

Quick Links