Deadline Miss Detection with
SCHED_DEADLINE
Copyright 2013, Toshiba Corporation.
Yoshitake Kobayashi
Advanced Software Technology Group
Corporate Software Engineering Center
TOSHIBA CORPORATION
Resources
The latest version slide is available on elinux wiki
http://elinux.org/ELC_2013_Presentations
Related source code is able to download from GitHub
https://github.com/ystk/sched-deadline/tree/dlmiss-detection-dev
2Embedded Linux Conference 2013
Outline
Motivation
Deadline scheduler
SCHED_DEADLINE and its evaluation
Budget management
Deadline miss detection
Conclusion
3Embedded Linux Conference 2013
Conclusion
Motivation
We would like to use Linux on control systems
Real-time is one of the most critical topic
Problem statement
Need to evaluate deeply to meet the deadline
CPU resource used too much by higher priority tasks
4Embedded Linux Conference 2013
CPU resource used too much by higher priority tasks
EDF scheduler
Definition of deadline
Wakeup time: The time of an event occurred (Ex. Timer interrupt)
and target task’s state changed to runnable.
Event response time: Interrupt latency
Deadline: The time for a target task must finish
Process time
Event response time
5Embedded Linux Conference 2013
Wakeup time
Deadline
Period
Event response time
Wakeup time
Earliest Deadline Fisrt scheduling (EDF)
The earliest deadline task has the highest priority
Task’s priority is dynamically changed and
managed
SCHED_FIFO is static priority management
Theoretically the total CPU usage by all tasks is
up to 100%
Includes the kernel overhead
6Embedded Linux Conference 2013
Includes the kernel overhead
If usage of CPU by all tasks is less than 100%, all
tasks meet the deadline
Reference
http://en.wikipedia.org/wiki/Earliest_deadline_first_schedu
ling
An example of EDF Scheduling
Task1: budget 1ms period 8ms
Task2: budget 2ms period 5ms
Task3: budget 4ms period 10ms
T1
20ms0ms
CPU usage====0.925%
<<<< 100%
7Embedded Linux Conference 2013
T1
T2
T3
Rate-Monotonic Scheduling (RMS)
One of the popular scheduling algorithm for RTOS
Assumptions for task behavior
NO resource sharing such as hardware, a queue, or any kind of semaphore
Deterministic deadlines are exactly equal to periods
Static priorities (the task with the highest static priority that is runnable
immediately preempts all other tasks)
Static priorities assigned according to the rate monotonic conventions (tasks with
shorter periods/deadlines are given higher priorities)
Context switch times and other thread operations are free and have no impact on
the model
CPU utilization
8Embedded Linux Conference 2013
CPU utilization
n: number of periodic tasks,Ti: Release period, Ci: Computation time
CPU utilization depends on the combination of periodic tasks and it is possible to
meet the deadline even the CPU utilization is around 80%
Reference
http://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling
69.02ln)12(/
0
≈→−≤= ∞=
=
∑ n
n
i
n
ii nTCU
Compared with the RMS scheduling
Task1: budget 1ms period 4ms
Task2: budget 2ms period 6ms
Task3: budget 3ms period 8ms
T1
T2
20ms0ms
RMS
CPU usage====0.958%
9Embedded Linux Conference 2013
T3
deadline miss
T1
T2
T3
20ms0ms
EDF
Comparison of deadline algorithms
Advantage Disadvantage
RMS Easier to implement
Evaluation for
scheduling possibility is
required to meet the
deadline
10Embedded Linux Conference 2013
deadline
EDF
No evaluation for
scheduling possibility is
required to meet the
deadline
Difficult to implement
What SCHED_DEADLINE is?
http://www.evidence.eu.com/sched_deadline.html
Implements the EDF scheduling algorithm
Posted to LKML by Dario Faggioli and Juri Lelli
Latest version is V7 (2013/2/12)
Our work based on V2 and V4.
Key features of SCHED_DEADLINE
11Embedded Linux Conference 2013
Key features of SCHED_DEADLINE
Temporal isolation
The temporal behavior of each task (i.e., its ability to meet its
deadlines) is not affected by the behavior of any other task in the
system
Each task is characterized by the following aspects:
Budget: sched_runtime
Period: sched_period, equal to its deadline
Build SCHED_DEADLINE enabled kernel
Get the source code from the following places
git clone git://github.com/jlelli/sched-deadline.git
(for V4 to V7)
git clone git://gitorious.org/rt-deadline
(for V2)
Kernel configuration
CONFIG_EXPERIMENTAL = y
12Embedded Linux Conference 2013
CONFIG_EXPERIMENTAL = y
CONFIG_CGROUPS = y
CONFIG_CGROUP_SCHED = n
CONFIG_HIGH_RES_TIMERS = y
CONFIG_PREEMPT = y
CONFIG_PREEMPT_RT = y
CONFIG_HZ_1000 = y
Overview of SCHED_DEADLINE
EDF task User
sysctl_sched_dl_runtime
sysctl_sched_dl_period
procfs
Set parameters for
SCHED_DEADLINE
sched_pram2
Set deadline
and budget
System call
13Embedded Linux Conference 2013
Kernel
task_struct
sched_calss
dl_sched_class
enqueue_task_dl
dequeue_task_dl
sched_dl_entity
task_tick_dl
set_curr_task_dl
・・・
・・・
・・・
・・・
rb_node
dl_runtime
dl_deadline
dl_timer
・・・・・・
・・
Overview of SCHED_DEADLINE
EDF task User
sysctl_sched_dl_runtime
sysctl_sched_dl_period
procfs
Set parameters for
SCHED_DEADLINE
sched_pram2
Set deadline
and budget
System call
14Embedded Linux Conference 2013
Kernel
task_struct
sched_calss
dl_sched_class
enqueue_task_dl
dequeue_task_dl
sched_dl_entity
task_tick_dl
set_curr_task_dl
・・・
・・・
・・・
・・・
rb_node
dl_runtime
dl_deadline
dl_timer
・・・・・・
・・
Setting CPU utilization for EDF tasks
Parameters can be setted via procfs
CPU utilization for rt(SCHED_FIFO and SCHED_RR) and
dl(SCHED_DEADLINE) should be under 100%
Parameters for EDF scheduler
/proc/sys/kernel/sched_dl_period_us
/proc/sys/kernel/sched_dl_runtime_us
When a task requires more than above limit, the task
15Embedded Linux Conference 2013
When a task requires more than above limit, the task
cannot submit to run
An example setting (rt: 50%, dl:50%))))
# echo 500000 > /proc/sys/kernel/sched_rt_runtime_us (500ms)
# echo 100000 > /proc/sys/kernel/sched_dl_period_us (100ms)
# echo 50000 > /proc/sys/kernel/sched_dl_runtime_us (50ms)
Overview of SCHED_DEADLINE
EDF task User
sysctl_sched_dl_runtime
sysctl_sched_dl_period
procfs
Set parameters for
SCHED_DEADLINE
sched_pram2
Set deadline
and runtime
System call
16Embedded Linux Conference 2013
Kernel
task_struct
sched_calss
dl_sched_class
enqueue_task_dl
dequeue_task_dl
sched_dl_entity
task_tick_dl
set_curr_task_dl
・・・
・・・
・・・
・・・
rb_node
dl_runtime
dl_deadline
dl_timer
・・・・・・
・・
Structure of sched_param2
struct sched_param2 {
int sched_priority;
unsigned int sched_flags;
u64 sched_runtime;
u64 sched_deadline;
u64 sched_period;
17Embedded Linux Conference 2013
u64 sched_period;
u64 __unused[12];
};
Run a EDF task
Schedtool
# schedtool -E -t 10000:100000 -a 0 -e ./yes
Options
-E: a task runs on SCHED_DEADLINE
-t: <execution time> and <period> in micro seconds
-a: Affinity mask
-e: command
18Embedded Linux Conference 2013
System call
sched_setscheduler2()
Budget management for EDF tasks
EDF task User
sysctl_sched_dl_runtime
sysctl_sched_dl_period
procfs
Set parameters for
SCHED_DEADLINE
sched_prama2
Set deadline
and runtime
System call
19Embedded Linux Conference 2013
Kernel
task_struct
sched_calss
dl_sched_class
enqueue_task_dl
dequeue_task_dl
sched_dl_entity
task_tick_dl
set_curr_task_dl
・・・
・・・
・・・
・・・
rb_node
dl_runtime
dl_deadline
dl_timer
・・・・・・
・・
Budget management for EDF tasks
Each task on SCHED_DEADLINE has budget which
allows it to use CPU
Budget management
Refill budget : dl_timer ( high resolution timer )
Use budget : task_tick_dl ( tick based )
task_tick_dl
20Embedded Linux Conference 2013
Wakeup time Period Wakeup time
dl_timer
Task
task_tick_dl
dl_timer
Evaluation (Period:100ms, Budget: 50ms)
21Embedded Linux Conference 2013
Evaluation
Task T1: budget 1ms period 4ms
Task T2: budget 2ms period 6ms
Task T3: budget 3ms period 8ms
22Embedded Linux Conference 2013
T1
T2
T3
20ms0ms
Compare with page 6
Evaluation (Period: 1ms, Budget: 0.5ms)
23Embedded Linux Conference 2013
Budget management for EDF tasks
Each task on SCHED_DEADLINE has budget which allows it to
use CPU
Budget management
Refill budget : dl_timer ( high resolution timer )
Use budget : task_tick_dl ( tick based )
An Issue
Difficult to keep task’s budget if the budget has micro seconds granularity
1.5ms 1.5ms
24Embedded Linux Conference 2013
Wakeup
Period
Task execution
Time
dl_timer
1.5ms
task_tick_dl
1ms
Wakeup
dl_timer
1.5ms
1ms
Step1: Refill budget
Step2: Use budget
Period
2ms
Overview
When a task’s budget is less than 1ms, set HRTICK for the rest of
budget
Step1: Refill budget
3.2ms
1ms 2ms 3ms
Support for micro seconds granularity
25Embedded Linux Conference 2013
Wakeup
Period
Task execution
Set HRTICK here
Step2: Use budget
Time
1ms 2ms 3ms
Wakeup
Evaluation (Cycle: 1ms, Budget: 0.5ms)
26Embedded Linux Conference 2013
Advantage and Disadvantage
Advantage
Easy to support high resolution budget
Disadvantage
Increase overhead
27Embedded Linux Conference 2013
Summary of scheduling granularity improvement
An Enhancement for budget management
Support fine grained budget such as 100 micro seconds
HRTICK is needed to support fine grained budget
28Embedded Linux Conference 2013
DEMO
“Big Buck Bunny”
http://www.bigbuckbunny.org/
(c) copyright 2008, Blender Foundation
License: Creative Commons Attribution 3.0
Play the movie about 3 times faster than normal speed
Requirement for a frame decoding
29Embedded Linux Conference 2013
Requirement for a frame decoding
Period: 10ms
CPU budget: 3.6ms
When a frame decode is not finished in a period, the player shows
“DEADLINE MISS” on screen and add 3ms penalty
Let’s play the movie
ModifiedOriginal
30Embedded Linux Conference 2013
Note: Both movies are running on same spec x86 based PC
Requirement for deadline miss detection
Current behavior
Have a counter to count the number of deadline misses
Not able to control tasks that missed the deadline
Wakeup time Period (((( Deadline )
Task
Period (((( Deadline )
DetectDetect
31Embedded Linux Conference 2013
Requirement
Detect the deadline miss at the begging of period
Detect
Here
Wakeup time Period (((( Deadline )
Task
Period (((( Deadline )
Need to detect
Here
Detect
Here
Current limitation of SCHED_DEADLINE
SCHED_DEADLINE is able to count the number of
deadline misses
SCHED_DEADLINE is not able to control tasks that
missed the deadline
32Embedded Linux Conference 2013
Possible approaches to detect deadline misses
Userland
Monitor process or thread
Run at the end or begging of each period
A pair of periodic timer and signal handler
Have to cancel if the process meet the deadline
or
Have to catch the signal to check the deadline miss status
33Embedded Linux Conference 2013
Have to catch the signal to check the deadline miss status
…
Kernel
This presentation takes this approach
Overview of SCHED_DEADLINE
EDF task User
sysctl_sched_dl_runtime
sysctl_sched_dl_period
procfs
Set parameters for
SCHED_DEADLINE
sched_pram2
Set deadline
and runtime
System call
sched_flags
34Embedded Linux Conference 2013
Kernel
task_struct
sched_calss
dl_sched_class
enqueue_task_dl
dequeue_task_dl
sched_dl_entity
task_tick_dl
set_curr_task_dl
・・・
・・・
・・・
・・・
rb_node
dl_runtime
dl_deadline
dl_timer
・・・・・・
・・ flags
Overview of deadline miss detection
Set parameters to sched_param2.sched_flags
Parameters for sched_flags
Enable or disable the deadline miss detection
SCHED_DL_DMISS_DETECT_DISABLE
SCHED_DL_DMISS_DETECT_ENABLE
Behaviors
35Embedded Linux Conference 2013
Behaviors
next slide..
Behaviors ( sched_param2.sched_flags )
Nothing to do
SCHED_DL_DMISS_ACT_NONE
When the SCHED_DL_DMISS_DETECT_ENABLE flag is set, the kernel will count the
number of deadline misses on /proc/sys/kernel/sched_dl_dmiss_count
Send a signal
To the process itself
SCHED_DL_DMISS_ACT_SEND_SIG_OWN
Send a SIGXCPU signal
SCHED_DL_DMISS_ACT_PROCESS_END
Send a SIGKILL signal
SCHED_DL_DMISS_ACT_PROCESS_STOP
36Embedded Linux Conference 2013
SCHED_DL_DMISS_ACT_PROCESS_STOP
Send a SIGSTOP signal
To the other task
Set the PID to /proc/sys/kernel/sched_dl_dmiss_sig_pid
SCHED_DL_DMISS_ACT_SEND_SIG_OTHER_WITH_RUN
Send a signal to the specified process
Deadline missed process continues to run
SCHED_DL_DMISS_ACT_SEND_SIG_OTHER_WITH_STOP
Send a signal to the specified process
Deadline missed process is stoped
Evaluation
Behavior of process
Period: 10ms
Budget: 5ms
Most of case the process is able to call sched_yield() between
4.5ms to 4.8ms
The process missed the deadline at the last period in the log
37Embedded Linux Conference 2013
OK DL miss here
Conclusion
SCHED_DEADLINE is useful for real time systems
This presentation enhanced SCHED_DEADLINE
For budget management
Support fine grained budget such as 100 micro seconds
HRTICK is needed to support fine grained budget
For deadline miss detection
38Embedded Linux Conference 2013
For deadline miss detection
Add a function to control deadline missed tasks
All source code are available at the following URL
https://github.com/ystk/sched-deadline/tree/dlmiss-detection-dev
Thank you
39Embedded Linux Conference 2013
Thank you

More Related Content

PDF
Improvement of Scheduling Granularity for Deadline Scheduler
PPTX
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
PDF
4838281 operating-system-scheduling-on-multicore-architectures
PDF
22). smlevel energy eff-dynamictaskschedng
PDF
Scheduling of Heterogeneous Tasks in Cloud Computing using Multi Queue (MQ) A...
PDF
Ijariie1161
PPT
Unit vi
PDF
LCU13: Power-efficient scheduling, and the latest news from the kernel summit
Improvement of Scheduling Granularity for Deadline Scheduler
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
4838281 operating-system-scheduling-on-multicore-architectures
22). smlevel energy eff-dynamictaskschedng
Scheduling of Heterogeneous Tasks in Cloud Computing using Multi Queue (MQ) A...
Ijariie1161
Unit vi
LCU13: Power-efficient scheduling, and the latest news from the kernel summit

What's hot (20)

PPTX
Real time systems 1 and 2
PPTX
Task Scheduling Algorithm for Multicore Processor Systems with Turbo Boost an...
PPTX
Real time-system
PPTX
Real Time System
PDF
Real Time Systems
PDF
Scheduling Task-parallel Applications in Dynamically Asymmetric Environments
PPTX
Components in real time systems
PPT
PDF
Realtime systems chapter 1
PPT
Real time system
PDF
Detecting Lateral Movement with a Compute-Intense Graph Kernel
PPTX
Real time Scheduling in Operating System for Msc CS
PPTX
Hard versus Soft real time system
PDF
10. resource management
PDF
Resource management
PPT
CPU Scheduling
PDF
capacityshifting1
PDF
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
PDF
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
PDF
Power aware compilation
Real time systems 1 and 2
Task Scheduling Algorithm for Multicore Processor Systems with Turbo Boost an...
Real time-system
Real Time System
Real Time Systems
Scheduling Task-parallel Applications in Dynamically Asymmetric Environments
Components in real time systems
Realtime systems chapter 1
Real time system
Detecting Lateral Movement with a Compute-Intense Graph Kernel
Real time Scheduling in Operating System for Msc CS
Hard versus Soft real time system
10. resource management
Resource management
CPU Scheduling
capacityshifting1
Sara Afshar: Scheduling and Resource Sharing in Multiprocessor Real-Time Systems
VTU 5TH SEM CSE OPERATING SYSTEMS SOLVED PAPERS
Power aware compilation
Ad

Viewers also liked (15)

PPTX
Webinar - "Transformar Oportunidades em Vendas através do Marketing Digital"
PPTX
FUNDAMENTOS DE LAS HERRAMIENTAS WEB 2.0
PDF
Funciones de busqueda y referencia
PDF
Moving Forward: Overcoming Compatibility Issues BoFs
PDF
Poky meets Debian: Understanding how to make an embedded Linux by using an ex...
PPTX
Port.min
DOCX
3rd March 2017 - Becoming a true Christian
PPTX
Bioquímica celular
PPTX
Cours4.5 opérateurs recherche
PPTX
Grand Format "Jardins Ouverts, Jardins Clos" du 28/02/2017 - Présentation Fre...
PDF
Actividades de Mantenimiento de Recipientes Sujetos a Presion
PPT
Retaining wall
PPTX
SonarQube - The leading platform for Continuous Code Quality
PDF
GoodPack_Marketing Deck_AMP for customer visit- USA -W. Wong
PDF
LLamado a arrendamiento de campo ganadero
Webinar - "Transformar Oportunidades em Vendas através do Marketing Digital"
FUNDAMENTOS DE LAS HERRAMIENTAS WEB 2.0
Funciones de busqueda y referencia
Moving Forward: Overcoming Compatibility Issues BoFs
Poky meets Debian: Understanding how to make an embedded Linux by using an ex...
Port.min
3rd March 2017 - Becoming a true Christian
Bioquímica celular
Cours4.5 opérateurs recherche
Grand Format "Jardins Ouverts, Jardins Clos" du 28/02/2017 - Présentation Fre...
Actividades de Mantenimiento de Recipientes Sujetos a Presion
Retaining wall
SonarQube - The leading platform for Continuous Code Quality
GoodPack_Marketing Deck_AMP for customer visit- USA -W. Wong
LLamado a arrendamiento de campo ganadero
Ad

Similar to Deadline Miss Detection with SCHED_DEADLINE (20)

PDF
Embedded Recipes 2017 - Understanding SCHED_DEADLINE - Steven Rostedt
PPTX
RTOS for Embedded systems and scheduling mechanisms
PPTX
Embedded system scheduling Algorithm .pptx
PPTX
Polling server
PPTX
Process scheduling
PDF
Luca Abeni - Real-Time Virtual Machines with Linux and kvm
PDF
RTAI - Earliest Deadline First
DOCX
Rate.docx
PPT
Os5 2
PDF
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
PPTX
Scheduling algorithm in real time system
PDF
Linux Scheduler Latest_ viresh Kumar.pdf
PDF
Linux Internals - Interview essentials 4.0
PDF
Building a Custom Linux CPU Scheduler with sched_ext.pdf
PDF
Real Time most famous algorithms
PDF
Linux scheduler
PDF
Implementation and evaluation of novel scheduler of UC/OS (RTOS)
PDF
Real Time Operating System Concepts
PDF
Process Scheduler and Balancer in Linux Kernel
Embedded Recipes 2017 - Understanding SCHED_DEADLINE - Steven Rostedt
RTOS for Embedded systems and scheduling mechanisms
Embedded system scheduling Algorithm .pptx
Polling server
Process scheduling
Luca Abeni - Real-Time Virtual Machines with Linux and kvm
RTAI - Earliest Deadline First
Rate.docx
Os5 2
2025年 Linux 核心專題: 探討 sched_ext 及機器學習.pdf
Scheduling algorithm in real time system
Linux Scheduler Latest_ viresh Kumar.pdf
Linux Internals - Interview essentials 4.0
Building a Custom Linux CPU Scheduler with sched_ext.pdf
Real Time most famous algorithms
Linux scheduler
Implementation and evaluation of novel scheduler of UC/OS (RTOS)
Real Time Operating System Concepts
Process Scheduler and Balancer in Linux Kernel

More from Yoshitake Kobayashi (13)

PDF
InnerSource Learning Path (Japanese)
PDF
Civil Infrastructure Platform: Industrial Grade SLTS Kernel and Base-layer De...
PDF
SLTS kernel and base-layer development in the Civil Infrastructure Platform
PDF
Time is ready for the Civil Infrastructure Platform
PDF
Introducing the Civil Infrastructure Platform Project
PDF
Introducing the Civil Infrastructure Platform
PDF
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
PDF
Applying Linux to the Civil Infrastructure
PDF
Using Embedded Linux for Infrastructure Systems
PDF
Using Real-Time Patch with LTSI Kernel
PDF
An Essential Relationship between Real-time and Resource Partitioning
PDF
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
PDF
Evaluation of Data Reliability on Linux File Systems
InnerSource Learning Path (Japanese)
Civil Infrastructure Platform: Industrial Grade SLTS Kernel and Base-layer De...
SLTS kernel and base-layer development in the Civil Infrastructure Platform
Time is ready for the Civil Infrastructure Platform
Introducing the Civil Infrastructure Platform Project
Introducing the Civil Infrastructure Platform
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
Applying Linux to the Civil Infrastructure
Using Embedded Linux for Infrastructure Systems
Using Real-Time Patch with LTSI Kernel
An Essential Relationship between Real-time and Resource Partitioning
Ineffective and Effective Ways To Find Out Latency Bottlenecks With Ftrace
Evaluation of Data Reliability on Linux File Systems

Recently uploaded (20)

PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Architecture types and enterprise applications.pdf
DOCX
search engine optimization ppt fir known well about this
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Hybrid model detection and classification of lung cancer
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
STKI Israel Market Study 2025 version august
PPTX
Tartificialntelligence_presentation.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Modernising the Digital Integration Hub
WOOl fibre morphology and structure.pdf for textiles
A novel scalable deep ensemble learning framework for big data classification...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Zenith AI: Advanced Artificial Intelligence
O2C Customer Invoices to Receipt V15A.pptx
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Getting started with AI Agents and Multi-Agent Systems
Architecture types and enterprise applications.pdf
search engine optimization ppt fir known well about this
DP Operators-handbook-extract for the Mautical Institute
sustainability-14-14877-v2.pddhzftheheeeee
Hybrid model detection and classification of lung cancer
NewMind AI Weekly Chronicles – August ’25 Week III
Hindi spoken digit analysis for native and non-native speakers
A review of recent deep learning applications in wood surface defect identifi...
STKI Israel Market Study 2025 version august
Tartificialntelligence_presentation.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Modernising the Digital Integration Hub

Deadline Miss Detection with SCHED_DEADLINE

  • 1. Deadline Miss Detection with SCHED_DEADLINE Copyright 2013, Toshiba Corporation. Yoshitake Kobayashi Advanced Software Technology Group Corporate Software Engineering Center TOSHIBA CORPORATION
  • 2. Resources The latest version slide is available on elinux wiki http://elinux.org/ELC_2013_Presentations Related source code is able to download from GitHub https://github.com/ystk/sched-deadline/tree/dlmiss-detection-dev 2Embedded Linux Conference 2013
  • 3. Outline Motivation Deadline scheduler SCHED_DEADLINE and its evaluation Budget management Deadline miss detection Conclusion 3Embedded Linux Conference 2013 Conclusion
  • 4. Motivation We would like to use Linux on control systems Real-time is one of the most critical topic Problem statement Need to evaluate deeply to meet the deadline CPU resource used too much by higher priority tasks 4Embedded Linux Conference 2013 CPU resource used too much by higher priority tasks EDF scheduler
  • 5. Definition of deadline Wakeup time: The time of an event occurred (Ex. Timer interrupt) and target task’s state changed to runnable. Event response time: Interrupt latency Deadline: The time for a target task must finish Process time Event response time 5Embedded Linux Conference 2013 Wakeup time Deadline Period Event response time Wakeup time
  • 6. Earliest Deadline Fisrt scheduling (EDF) The earliest deadline task has the highest priority Task’s priority is dynamically changed and managed SCHED_FIFO is static priority management Theoretically the total CPU usage by all tasks is up to 100% Includes the kernel overhead 6Embedded Linux Conference 2013 Includes the kernel overhead If usage of CPU by all tasks is less than 100%, all tasks meet the deadline Reference http://en.wikipedia.org/wiki/Earliest_deadline_first_schedu ling
  • 7. An example of EDF Scheduling Task1: budget 1ms period 8ms Task2: budget 2ms period 5ms Task3: budget 4ms period 10ms T1 20ms0ms CPU usage====0.925% <<<< 100% 7Embedded Linux Conference 2013 T1 T2 T3
  • 8. Rate-Monotonic Scheduling (RMS) One of the popular scheduling algorithm for RTOS Assumptions for task behavior NO resource sharing such as hardware, a queue, or any kind of semaphore Deterministic deadlines are exactly equal to periods Static priorities (the task with the highest static priority that is runnable immediately preempts all other tasks) Static priorities assigned according to the rate monotonic conventions (tasks with shorter periods/deadlines are given higher priorities) Context switch times and other thread operations are free and have no impact on the model CPU utilization 8Embedded Linux Conference 2013 CPU utilization n: number of periodic tasks,Ti: Release period, Ci: Computation time CPU utilization depends on the combination of periodic tasks and it is possible to meet the deadline even the CPU utilization is around 80% Reference http://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling 69.02ln)12(/ 0 ≈→−≤= ∞= = ∑ n n i n ii nTCU
  • 9. Compared with the RMS scheduling Task1: budget 1ms period 4ms Task2: budget 2ms period 6ms Task3: budget 3ms period 8ms T1 T2 20ms0ms RMS CPU usage====0.958% 9Embedded Linux Conference 2013 T3 deadline miss T1 T2 T3 20ms0ms EDF
  • 10. Comparison of deadline algorithms Advantage Disadvantage RMS Easier to implement Evaluation for scheduling possibility is required to meet the deadline 10Embedded Linux Conference 2013 deadline EDF No evaluation for scheduling possibility is required to meet the deadline Difficult to implement
  • 11. What SCHED_DEADLINE is? http://www.evidence.eu.com/sched_deadline.html Implements the EDF scheduling algorithm Posted to LKML by Dario Faggioli and Juri Lelli Latest version is V7 (2013/2/12) Our work based on V2 and V4. Key features of SCHED_DEADLINE 11Embedded Linux Conference 2013 Key features of SCHED_DEADLINE Temporal isolation The temporal behavior of each task (i.e., its ability to meet its deadlines) is not affected by the behavior of any other task in the system Each task is characterized by the following aspects: Budget: sched_runtime Period: sched_period, equal to its deadline
  • 12. Build SCHED_DEADLINE enabled kernel Get the source code from the following places git clone git://github.com/jlelli/sched-deadline.git (for V4 to V7) git clone git://gitorious.org/rt-deadline (for V2) Kernel configuration CONFIG_EXPERIMENTAL = y 12Embedded Linux Conference 2013 CONFIG_EXPERIMENTAL = y CONFIG_CGROUPS = y CONFIG_CGROUP_SCHED = n CONFIG_HIGH_RES_TIMERS = y CONFIG_PREEMPT = y CONFIG_PREEMPT_RT = y CONFIG_HZ_1000 = y
  • 13. Overview of SCHED_DEADLINE EDF task User sysctl_sched_dl_runtime sysctl_sched_dl_period procfs Set parameters for SCHED_DEADLINE sched_pram2 Set deadline and budget System call 13Embedded Linux Conference 2013 Kernel task_struct sched_calss dl_sched_class enqueue_task_dl dequeue_task_dl sched_dl_entity task_tick_dl set_curr_task_dl ・・・ ・・・ ・・・ ・・・ rb_node dl_runtime dl_deadline dl_timer ・・・・・・ ・・
  • 14. Overview of SCHED_DEADLINE EDF task User sysctl_sched_dl_runtime sysctl_sched_dl_period procfs Set parameters for SCHED_DEADLINE sched_pram2 Set deadline and budget System call 14Embedded Linux Conference 2013 Kernel task_struct sched_calss dl_sched_class enqueue_task_dl dequeue_task_dl sched_dl_entity task_tick_dl set_curr_task_dl ・・・ ・・・ ・・・ ・・・ rb_node dl_runtime dl_deadline dl_timer ・・・・・・ ・・
  • 15. Setting CPU utilization for EDF tasks Parameters can be setted via procfs CPU utilization for rt(SCHED_FIFO and SCHED_RR) and dl(SCHED_DEADLINE) should be under 100% Parameters for EDF scheduler /proc/sys/kernel/sched_dl_period_us /proc/sys/kernel/sched_dl_runtime_us When a task requires more than above limit, the task 15Embedded Linux Conference 2013 When a task requires more than above limit, the task cannot submit to run An example setting (rt: 50%, dl:50%)))) # echo 500000 > /proc/sys/kernel/sched_rt_runtime_us (500ms) # echo 100000 > /proc/sys/kernel/sched_dl_period_us (100ms) # echo 50000 > /proc/sys/kernel/sched_dl_runtime_us (50ms)
  • 16. Overview of SCHED_DEADLINE EDF task User sysctl_sched_dl_runtime sysctl_sched_dl_period procfs Set parameters for SCHED_DEADLINE sched_pram2 Set deadline and runtime System call 16Embedded Linux Conference 2013 Kernel task_struct sched_calss dl_sched_class enqueue_task_dl dequeue_task_dl sched_dl_entity task_tick_dl set_curr_task_dl ・・・ ・・・ ・・・ ・・・ rb_node dl_runtime dl_deadline dl_timer ・・・・・・ ・・
  • 17. Structure of sched_param2 struct sched_param2 { int sched_priority; unsigned int sched_flags; u64 sched_runtime; u64 sched_deadline; u64 sched_period; 17Embedded Linux Conference 2013 u64 sched_period; u64 __unused[12]; };
  • 18. Run a EDF task Schedtool # schedtool -E -t 10000:100000 -a 0 -e ./yes Options -E: a task runs on SCHED_DEADLINE -t: <execution time> and <period> in micro seconds -a: Affinity mask -e: command 18Embedded Linux Conference 2013 System call sched_setscheduler2()
  • 19. Budget management for EDF tasks EDF task User sysctl_sched_dl_runtime sysctl_sched_dl_period procfs Set parameters for SCHED_DEADLINE sched_prama2 Set deadline and runtime System call 19Embedded Linux Conference 2013 Kernel task_struct sched_calss dl_sched_class enqueue_task_dl dequeue_task_dl sched_dl_entity task_tick_dl set_curr_task_dl ・・・ ・・・ ・・・ ・・・ rb_node dl_runtime dl_deadline dl_timer ・・・・・・ ・・
  • 20. Budget management for EDF tasks Each task on SCHED_DEADLINE has budget which allows it to use CPU Budget management Refill budget : dl_timer ( high resolution timer ) Use budget : task_tick_dl ( tick based ) task_tick_dl 20Embedded Linux Conference 2013 Wakeup time Period Wakeup time dl_timer Task task_tick_dl dl_timer
  • 21. Evaluation (Period:100ms, Budget: 50ms) 21Embedded Linux Conference 2013
  • 22. Evaluation Task T1: budget 1ms period 4ms Task T2: budget 2ms period 6ms Task T3: budget 3ms period 8ms 22Embedded Linux Conference 2013 T1 T2 T3 20ms0ms Compare with page 6
  • 23. Evaluation (Period: 1ms, Budget: 0.5ms) 23Embedded Linux Conference 2013
  • 24. Budget management for EDF tasks Each task on SCHED_DEADLINE has budget which allows it to use CPU Budget management Refill budget : dl_timer ( high resolution timer ) Use budget : task_tick_dl ( tick based ) An Issue Difficult to keep task’s budget if the budget has micro seconds granularity 1.5ms 1.5ms 24Embedded Linux Conference 2013 Wakeup Period Task execution Time dl_timer 1.5ms task_tick_dl 1ms Wakeup dl_timer 1.5ms 1ms Step1: Refill budget Step2: Use budget Period 2ms
  • 25. Overview When a task’s budget is less than 1ms, set HRTICK for the rest of budget Step1: Refill budget 3.2ms 1ms 2ms 3ms Support for micro seconds granularity 25Embedded Linux Conference 2013 Wakeup Period Task execution Set HRTICK here Step2: Use budget Time 1ms 2ms 3ms Wakeup
  • 26. Evaluation (Cycle: 1ms, Budget: 0.5ms) 26Embedded Linux Conference 2013
  • 27. Advantage and Disadvantage Advantage Easy to support high resolution budget Disadvantage Increase overhead 27Embedded Linux Conference 2013
  • 28. Summary of scheduling granularity improvement An Enhancement for budget management Support fine grained budget such as 100 micro seconds HRTICK is needed to support fine grained budget 28Embedded Linux Conference 2013
  • 29. DEMO “Big Buck Bunny” http://www.bigbuckbunny.org/ (c) copyright 2008, Blender Foundation License: Creative Commons Attribution 3.0 Play the movie about 3 times faster than normal speed Requirement for a frame decoding 29Embedded Linux Conference 2013 Requirement for a frame decoding Period: 10ms CPU budget: 3.6ms When a frame decode is not finished in a period, the player shows “DEADLINE MISS” on screen and add 3ms penalty
  • 30. Let’s play the movie ModifiedOriginal 30Embedded Linux Conference 2013 Note: Both movies are running on same spec x86 based PC
  • 31. Requirement for deadline miss detection Current behavior Have a counter to count the number of deadline misses Not able to control tasks that missed the deadline Wakeup time Period (((( Deadline ) Task Period (((( Deadline ) DetectDetect 31Embedded Linux Conference 2013 Requirement Detect the deadline miss at the begging of period Detect Here Wakeup time Period (((( Deadline ) Task Period (((( Deadline ) Need to detect Here Detect Here
  • 32. Current limitation of SCHED_DEADLINE SCHED_DEADLINE is able to count the number of deadline misses SCHED_DEADLINE is not able to control tasks that missed the deadline 32Embedded Linux Conference 2013
  • 33. Possible approaches to detect deadline misses Userland Monitor process or thread Run at the end or begging of each period A pair of periodic timer and signal handler Have to cancel if the process meet the deadline or Have to catch the signal to check the deadline miss status 33Embedded Linux Conference 2013 Have to catch the signal to check the deadline miss status … Kernel This presentation takes this approach
  • 34. Overview of SCHED_DEADLINE EDF task User sysctl_sched_dl_runtime sysctl_sched_dl_period procfs Set parameters for SCHED_DEADLINE sched_pram2 Set deadline and runtime System call sched_flags 34Embedded Linux Conference 2013 Kernel task_struct sched_calss dl_sched_class enqueue_task_dl dequeue_task_dl sched_dl_entity task_tick_dl set_curr_task_dl ・・・ ・・・ ・・・ ・・・ rb_node dl_runtime dl_deadline dl_timer ・・・・・・ ・・ flags
  • 35. Overview of deadline miss detection Set parameters to sched_param2.sched_flags Parameters for sched_flags Enable or disable the deadline miss detection SCHED_DL_DMISS_DETECT_DISABLE SCHED_DL_DMISS_DETECT_ENABLE Behaviors 35Embedded Linux Conference 2013 Behaviors next slide..
  • 36. Behaviors ( sched_param2.sched_flags ) Nothing to do SCHED_DL_DMISS_ACT_NONE When the SCHED_DL_DMISS_DETECT_ENABLE flag is set, the kernel will count the number of deadline misses on /proc/sys/kernel/sched_dl_dmiss_count Send a signal To the process itself SCHED_DL_DMISS_ACT_SEND_SIG_OWN Send a SIGXCPU signal SCHED_DL_DMISS_ACT_PROCESS_END Send a SIGKILL signal SCHED_DL_DMISS_ACT_PROCESS_STOP 36Embedded Linux Conference 2013 SCHED_DL_DMISS_ACT_PROCESS_STOP Send a SIGSTOP signal To the other task Set the PID to /proc/sys/kernel/sched_dl_dmiss_sig_pid SCHED_DL_DMISS_ACT_SEND_SIG_OTHER_WITH_RUN Send a signal to the specified process Deadline missed process continues to run SCHED_DL_DMISS_ACT_SEND_SIG_OTHER_WITH_STOP Send a signal to the specified process Deadline missed process is stoped
  • 37. Evaluation Behavior of process Period: 10ms Budget: 5ms Most of case the process is able to call sched_yield() between 4.5ms to 4.8ms The process missed the deadline at the last period in the log 37Embedded Linux Conference 2013 OK DL miss here
  • 38. Conclusion SCHED_DEADLINE is useful for real time systems This presentation enhanced SCHED_DEADLINE For budget management Support fine grained budget such as 100 micro seconds HRTICK is needed to support fine grained budget For deadline miss detection 38Embedded Linux Conference 2013 For deadline miss detection Add a function to control deadline missed tasks All source code are available at the following URL https://github.com/ystk/sched-deadline/tree/dlmiss-detection-dev
  • 39. Thank you 39Embedded Linux Conference 2013 Thank you