Overview of the Linux Scheduler Framework



Similar documents
Linux Process Scheduling. sched.c. schedule() scheduler_tick() hooks. try_to_wake_up() ... CFS CPU 0 CPU 1 CPU 2 CPU 3

Improvement of Scheduling Granularity for Deadline Scheduler

Process Scheduling in Linux

Linux scheduler history. We will be talking about the O(1) scheduler

Linux process scheduling

Process Scheduling II

Linux Scheduler Analysis and Tuning for Parallel Processing on the Raspberry PI Platform. Ed Spetka Mike Kohler

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Linux Plumbers API for Real-Time Scheduling with Temporal Isolation on Linux

Hard Real-Time Linux

CPU Scheduling Outline

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Threads Scheduling on Linux Operating Systems

CPU Scheduling. Basic Concepts. Basic Concepts (2) Basic Concepts Scheduling Criteria Scheduling Algorithms Batch systems Interactive systems

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

W4118 Operating Systems. Instructor: Junfeng Yang

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

Linux O(1) CPU Scheduler. Amit Gud amit (dot) gud (at) veritas (dot) com

A complete guide to Linux process scheduling. Nikita Ishkov

Linux Scheduler. Linux Scheduler

Operating Systems Concepts: Chapter 7: Scheduling Strategies

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Process Scheduling in Linux

Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm

Modular Real-Time Linux

Completely Fair Scheduler and its tuning 1

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Chapter 5 Process Scheduling

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

Operating Systems. III. Scheduling.

Real-Time Scheduling 1 / 39

ò Scheduling overview, key trade-offs, etc. ò O(1) scheduler older Linux scheduler ò Today: Completely Fair Scheduler (CFS) new hotness

EECS 750: Advanced Operating Systems. 01/28 /2015 Heechul Yun

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Predictable response times in event-driven real-time systems

ChronOS Linux: A Best-Effort Real-Time Multiprocessor Linux Kernel

Task Scheduling for Multicore Embedded Devices

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

CPU Scheduling. Core Definitions

CPU Scheduling. CPU Scheduling

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

CPU Scheduling. Multitasking operating systems come in two flavours: cooperative multitasking and preemptive multitasking.

Multilevel Load Balancing in NUMA Computers

Processor Scheduling. Queues Recall OS maintains various queues

Using EDF in Linux: SCHED DEADLINE. Luca Abeni

A Survey of Parallel Processing in Linux

Tasks Schedule Analysis in RTAI/Linux-GPL

Asymmetric Scheduling and Load Balancing for Real-Time on Linux SMP

Chapter 1: Introduction. What is an Operating System?

Linux Process Scheduling Policy

ICS Principles of Operating Systems

Effective Computing with SMP Linux

Linux Load Balancing

Understanding the Linux CPU Scheduler

Scheduling. Scheduling. Scheduling levels. Decision to switch the running process can take place under the following circumstances:

Understanding the Linux CPU Scheduler

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Real- Time Mul,- Core Virtual Machine Scheduling in Xen

Operating System: Scheduling

Process Scheduling in Linux

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Real-Time Multi-Core Virtual Machine Scheduling in Xen

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

RT-Xen: Towards Real-time Hypervisor Scheduling in Xen

Quality of Service su Linux: Passato Presente e Futuro

Capacity Estimation for Linux Workloads

Load-Balancing for Improving User Responsiveness on Multicore Embedded Systems

Real-Time Multi-Core Virtual Machine Scheduling in Xen

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Scheduling Aperiodic and Sporadic Jobs in Priority- Driven Systems

Multi-core and Linux* Kernel

Understanding the Linux CPU Scheduler

Lecture 3 Theoretical Foundations of RTOS

Chapter 5 Linux Load Balancing Mechanisms

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

Android Operating System

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

Testing task schedulers on Linux system

Real-Time Operating Systems.

Introduction. Application Performance in the QLinux Multimedia Operating System. Solution: QLinux. Introduction. Outline. QLinux Design Principles

OPERATING SYSTEMS SCHEDULING

Why Relative Share Does Not Work

KairosVM: Deterministic Introspection for Real-time Virtual Machine Hierarchical Scheduling

Transcription:

Overview of the Linux Scheduler Framework WORKSHOP ON REAL-TIME SCHEDULING IN THE LINUX KERNEL Pisa, June 27th, 2014 Marco Cesati University of Rome Tor Vergata Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 1 / 23

Goals of the Linux scheduler Select the right task to run on each available CPU when a task terminates, blocks, or becomes runnable and when requested by the time-sharing policy Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 2 / 23

Goals of the Linux scheduler (2) Select the right task to run in such a way to be fair to tasks and users respect relative priorities among tasks minimize task response times maximize system throughput (tasks completed per unit time) balance load among CPUs minimize power consumption have small overhead degrade gracefully on highest loads Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 3 / 23

Why scheduling is so difficult, anyway? We cannot optimize for any given goal fairness vs priority throughput vs response time load balancing vs power consumption Many scheduling algorithms rely on heuristic rules Practical definition of heuristic rule This is black magic, please don t ask, it s not your business anyway! Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 4 / 23

One Sched to rule them all! The Linux scheduler must achieve good results in High-performance clusters, mainframes High-end servers Desktop computers Laptops, tablets, smartphones Embedded devices Any change of the scheduler must not impair performance for each class of machines with any realistic usage pattern Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 5 / 23

Tasks A task is an execution flow that can be scheduled on a CPU In Linux: Task is equivalent to Process A multi-threaded program runs as a group of related light-weight processes Basic data structure for a task: struct task_struct Its address is the main task identifier inside the kernel Includes hundreds of fields and pointers to other task-related data structures current identifies the task in execution Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 6 / 23

Unix tasks Unix normal tasks Arbitrary execution times Relative priorities Starvation-free time-sharing scheduling algorithms POSIX real-time tasks Arbitrary execution times Absolute priorities Round-robin or FIFO scheduling algorithms for tasks of equal priority Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 7 / 23

Real-time tasks Real-time tasks Deadlines on completion times Absolute priorities based on temporal parameters Usually periodic or sporadic tasks Dedicated priority-based scheduling algorithms (EDF, RM,... ) Since version 3.14, Linux supports native real-time tasks There is an on-going global effort to make Linux usable in real-time systems (see also RTAI, CONFIG_PREEMPT_RT patch,... ) Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 8 / 23

Current scheduler framework Introduced by Ingo Molnar in kernel 2.6.23 (2007) Based on different scheduling policies included in scheduling classes Original design assumptions: Partitioned scheduler (decisions are local to each CPU) If necessary, tasks can be migrated among the CPUs Each scheduling class has a unique priority On some CPU, no task of a given class can be run if tasks of classes with higher priorities are runnable Real-time policies break some of these assumptions Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 9 / 23

Scheduling classes and policies Class Policy stop_sched_class dl_sched_class rt_sched_class fair_sched_class SCHED_DEADLINE SCHED_FIFO SCHED_RR SCHED_NORMAL SCHED_BATCH SCHED_IDLE idle_sched_class Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 10 / 23

Class stop_sched_class Highest priority scheduling class Mechanism to force running a function on some CPU(s) by preempting and freezing any other task Not associated with a scheduling policy just one kernel thread per CPU (migration/n) Used by task migration, RCU, CPU unplugging,... Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 11 / 23

Class dl_sched_class By Dario Faggioli & Juri Lelli, kernel version 3.14 (Nov. 2013) Scheduling policy SCHED_DEADLINE Highest priority tasks in the system Further details in another talk! Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 12 / 23

Class rt_sched_class POSIX real-time tasks 99 absolute priorities Scheduling policies for tasks of equal priority: SCHED_FIFO: cooperative scheduling, First Come First Served SCHED_RR: round-robin scheduling, 100 ms timeslice by default Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 13 / 23

Class fair_sched_class By Ingo Molnar, kernel version 2.6.23 (July 2007) Completely Fair Scheduler (CFS) Three scheduling policies: SCHED_NORMAL: normal Unix tasks SCHED_BATCH: batch (non-interactive) tasks SCHED_IDLE: low-priority tasks Further details in another talk! Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 14 / 23

Class idle_sched_class Lowest priority scheduling class Not associated with a scheduling policy just one task per CPU ( idle thread swapper/n) Executed only when no other task is runnable Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 15 / 23

The scheduling class Implemented by struct sched_class Basically a collection of function pointers (methods) Each structure is linked to the next lower class in the hierarchy by a next pointer the for_each_class macro iterates over all classes stop dl rt fair idle Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 16 / 23

Main methods of the scheduling class enqueue_task: invoked when a task becomes runnable dequeue_task: invoked when a task is no longer runnable pick_next_task: select the best task to be run next (scheduling decision) return NULL if no runnable task was found return RETRY_TASK if a runnable task appeared in a higher-priority class check_preempt_curr: check if the new runnable task should preempt the current one task_tick: periodically invoked to update task parameters (for time sharing) Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 17 / 23

The schedule() function Executed on a CPU to select the best task to be run next schedule() picks the best runnable task starting from the highest-priority scheduler class again: for_each_class(class) { p = class->pick_next_task(rq, prev); if (p) { if (p == RETRY_TASK) goto again; return p; } } Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 18 / 23

Runqueues Runnable tasks are included in a runqueue: struct rq There is a runqueue for each CPU in the system Lots of information available here: number of runnable tasks in queue current and past CPU load information specific to each scheduling class also lists or trees collecting tasks various statistics and accounting information Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 19 / 23

Example: two runqueues RQ (CPU0) stop dl rt fair idle stop dl rt fair idle RQ (CPU1) Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 20 / 23

Reserved CPU bandwidth SCHED_DEADLINE, SCHED_FIFO, and SCHED_RR tasks may easily starve normal tasks To make life easier for RT developers, some CPU bandwidth can be reserved to normal tasks: In an interval of time of length P µs, at least N µs are reserved for normal tasks P /proc/sys/kernel/sched_rt_period_us P N /proc/sys/kernel/sched_rt_runtime_us The reserved CPU bandwidth mechanism can also be applied to real-time scheduling groups Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 21 / 23

Important scheduler topics deserving further discussions CFS and deadline schedulers (stay tuned!) Load balancing and scheduling domains Per-entity load tracking Group scheduling Power-aware CPU scheduling Linsched and other scheduler testing frameworks Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 22 / 23

Thank you! Marco Cesati (Univ. of Rome Tor Vergata) Overview of the Linux scheduler framework RTS-LIKE June 27th, 2014 23 / 23