diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-31 12:00:44 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-31 12:00:44 -0500 |
| commit | 595bf999e3a864f40e049c67c42ecee50fb7a78a (patch) | |
| tree | ef6ccc5e84c7152eff59d6db55733de42c32329b | |
| parent | ab5318788c6725b6d5c95aff28e63af4c35a0e2c (diff) | |
| parent | a57beec5d427086cdc8d75fd51164577193fa7f4 (diff) | |
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fixes from Ingo Molnar:
"A crash fix and documentation updates"
* 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
sched: Make sched_class::get_rr_interval() optional
sched/deadline: Add sched_dl documentation
sched: Fix docbook parameter annotation error in wait.h
| -rw-r--r-- | Documentation/scheduler/00-INDEX | 2 | ||||
| -rw-r--r-- | Documentation/scheduler/sched-deadline.txt | 281 | ||||
| -rw-r--r-- | kernel/sched/core.c | 4 | ||||
| -rw-r--r-- | kernel/sched/deadline.c | 3 |
4 files changed, 288 insertions, 2 deletions
diff --git a/Documentation/scheduler/00-INDEX b/Documentation/scheduler/00-INDEX index d2651c47ae27..46702e4f89c9 100644 --- a/Documentation/scheduler/00-INDEX +++ b/Documentation/scheduler/00-INDEX | |||
| @@ -10,5 +10,7 @@ sched-nice-design.txt | |||
| 10 | - How and why the scheduler's nice levels are implemented. | 10 | - How and why the scheduler's nice levels are implemented. |
| 11 | sched-rt-group.txt | 11 | sched-rt-group.txt |
| 12 | - real-time group scheduling. | 12 | - real-time group scheduling. |
| 13 | sched-deadline.txt | ||
| 14 | - deadline scheduling. | ||
| 13 | sched-stats.txt | 15 | sched-stats.txt |
| 14 | - information on schedstats (Linux Scheduler Statistics). | 16 | - information on schedstats (Linux Scheduler Statistics). |
diff --git a/Documentation/scheduler/sched-deadline.txt b/Documentation/scheduler/sched-deadline.txt new file mode 100644 index 000000000000..18adc92a6b3b --- /dev/null +++ b/Documentation/scheduler/sched-deadline.txt | |||
| @@ -0,0 +1,281 @@ | |||
| 1 | Deadline Task Scheduling | ||
| 2 | ------------------------ | ||
| 3 | |||
| 4 | CONTENTS | ||
| 5 | ======== | ||
| 6 | |||
| 7 | 0. WARNING | ||
| 8 | 1. Overview | ||
| 9 | 2. Scheduling algorithm | ||
| 10 | 3. Scheduling Real-Time Tasks | ||
| 11 | 4. Bandwidth management | ||
| 12 | 4.1 System-wide settings | ||
| 13 | 4.2 Task interface | ||
| 14 | 4.3 Default behavior | ||
| 15 | 5. Tasks CPU affinity | ||
| 16 | 5.1 SCHED_DEADLINE and cpusets HOWTO | ||
| 17 | 6. Future plans | ||
| 18 | |||
| 19 | |||
| 20 | 0. WARNING | ||
| 21 | ========== | ||
| 22 | |||
| 23 | Fiddling with these settings can result in an unpredictable or even unstable | ||
| 24 | system behavior. As for -rt (group) scheduling, it is assumed that root users | ||
| 25 | know what they're doing. | ||
| 26 | |||
| 27 | |||
| 28 | 1. Overview | ||
| 29 | =========== | ||
| 30 | |||
| 31 | The SCHED_DEADLINE policy contained inside the sched_dl scheduling class is | ||
| 32 | basically an implementation of the Earliest Deadline First (EDF) scheduling | ||
| 33 | algorithm, augmented with a mechanism (called Constant Bandwidth Server, CBS) | ||
| 34 | that makes it possible to isolate the behavior of tasks between each other. | ||
| 35 | |||
| 36 | |||
| 37 | 2. Scheduling algorithm | ||
| 38 | ================== | ||
| 39 | |||
| 40 | SCHED_DEADLINE uses three parameters, named "runtime", "period", and | ||
| 41 | "deadline" to schedule tasks. A SCHED_DEADLINE task is guaranteed to receive | ||
| 42 | "runtime" microseconds of execution time every "period" microseconds, and | ||
| 43 | these "runtime" microseconds are available within "deadline" microseconds | ||
| 44 | from the beginning of the period. In order to implement this behaviour, | ||
| 45 | every time the task wakes up, the scheduler computes a "scheduling deadline" | ||
| 46 | consistent with the guarantee (using the CBS[2,3] algorithm). Tasks are then | ||
| 47 | scheduled using EDF[1] on these scheduling deadlines (the task with the | ||
| 48 | smallest scheduling deadline is selected for execution). Notice that this | ||
| 49 | guaranteed is respected if a proper "admission control" strategy (see Section | ||
| 50 | "4. Bandwidth management") is used. | ||
| 51 | |||
| 52 | Summing up, the CBS[2,3] algorithms assigns scheduling deadlines to tasks so | ||
| 53 | that each task runs for at most its runtime every period, avoiding any | ||
| 54 | interference between different tasks (bandwidth isolation), while the EDF[1] | ||
| 55 | algorithm selects the task with the smallest scheduling deadline as the one | ||
| 56 | to be executed first. Thanks to this feature, also tasks that do not | ||
| 57 | strictly comply with the "traditional" real-time task model (see Section 3) | ||
| 58 | can effectively use the new policy. | ||
| 59 | |||
| 60 | In more details, the CBS algorithm assigns scheduling deadlines to | ||
| 61 | tasks in the following way: | ||
| 62 | |||
| 63 | - Each SCHED_DEADLINE task is characterised by the "runtime", | ||
| 64 | "deadline", and "period" parameters; | ||
| 65 | |||
| 66 | - The state of the task is described by a "scheduling deadline", and | ||
| 67 | a "current runtime". These two parameters are initially set to 0; | ||
| 68 | |||
| 69 | - When a SCHED_DEADLINE task wakes up (becomes ready for execution), | ||
| 70 | the scheduler checks if | ||
| 71 | |||
| 72 | current runtime runtime | ||
| 73 | ---------------------------------- > ---------------- | ||
| 74 | scheduling deadline - current time period | ||
| 75 | |||
| 76 | then, if the scheduling deadline is smaller than the current time, or | ||
| 77 | this condition is verified, the scheduling deadline and the | ||
| 78 | current budget are re-initialised as | ||
| 79 | |||
| 80 | scheduling deadline = current time + deadline | ||
| 81 | current runtime = runtime | ||
| 82 | |||
| 83 | otherwise, the scheduling deadline and the current runtime are | ||
| 84 | left unchanged; | ||
| 85 | |||
| 86 | - When a SCHED_DEADLINE task executes for an amount of time t, its | ||
| 87 | current runtime is decreased as | ||
| 88 | |||
| 89 | current runtime = current runtime - t | ||
| 90 | |||
| 91 | (technically, the runtime is decreased at every tick, or when the | ||
| 92 | task is descheduled / preempted); | ||
| 93 | |||
| 94 | - When the current runtime becomes less or equal than 0, the task is | ||
| 95 | said to be "throttled" (also known as "depleted" in real-time literature) | ||
| 96 | and cannot be scheduled until its scheduling deadline. The "replenishment | ||
| 97 | time" for this task (see next item) is set to be equal to the current | ||
| 98 | value of the scheduling deadline; | ||
| 99 | |||
| 100 | - When the current time is equal to the replenishment time of a | ||
| 101 | throttled task, the scheduling deadline and the current runtime are | ||
| 102 | updated as | ||
| 103 | |||
| 104 | scheduling deadline = scheduling deadline + period | ||
| 105 | current runtime = current runtime + runtime | ||
| 106 | |||
| 107 | |||
| 108 | 3. Scheduling Real-Time Tasks | ||
| 109 | ============================= | ||
| 110 | |||
| 111 | * BIG FAT WARNING ****************************************************** | ||
| 112 | * | ||
| 113 | * This section contains a (not-thorough) summary on classical deadline | ||
| 114 | * scheduling theory, and how it applies to SCHED_DEADLINE. | ||
| 115 | * The reader can "safely" skip to Section 4 if only interested in seeing | ||
| 116 | * how the scheduling policy can be used. Anyway, we strongly recommend | ||
| 117 | * to come back here and continue reading (once the urge for testing is | ||
| 118 | * satisfied :P) to be sure of fully understanding all technical details. | ||
| 119 | ************************************************************************ | ||
| 120 | |||
| 121 | There are no limitations on what kind of task can exploit this new | ||
| 122 | scheduling discipline, even if it must be said that it is particularly | ||
| 123 | suited for periodic or sporadic real-time tasks that need guarantees on their | ||
| 124 | timing behavior, e.g., multimedia, streaming, control applications, etc. | ||
| 125 | |||
| 126 | A typical real-time task is composed of a repetition of computation phases | ||
| 127 | (task instances, or jobs) which are activated on a periodic or sporadic | ||
| 128 | fashion. | ||
| 129 | Each job J_j (where J_j is the j^th job of the task) is characterised by an | ||
| 130 | arrival time r_j (the time when the job starts), an amount of computation | ||
| 131 | time c_j needed to finish the job, and a job absolute deadline d_j, which | ||
| 132 | is the time within which the job should be finished. The maximum execution | ||
| 133 | time max_j{c_j} is called "Worst Case Execution Time" (WCET) for the task. | ||
| 134 | A real-time task can be periodic with period P if r_{j+1} = r_j + P, or | ||
| 135 | sporadic with minimum inter-arrival time P is r_{j+1} >= r_j + P. Finally, | ||
| 136 | d_j = r_j + D, where D is the task's relative deadline. | ||
| 137 | |||
| 138 | SCHED_DEADLINE can be used to schedule real-time tasks guaranteeing that | ||
| 139 | the jobs' deadlines of a task are respected. In order to do this, a task | ||
| 140 | must be scheduled by setting: | ||
| 141 | |||
| 142 | - runtime >= WCET | ||
| 143 | - deadline = D | ||
| 144 | - period <= P | ||
| 145 | |||
| 146 | IOW, if runtime >= WCET and if period is >= P, then the scheduling deadlines | ||
| 147 | and the absolute deadlines (d_j) coincide, so a proper admission control | ||
| 148 | allows to respect the jobs' absolute deadlines for this task (this is what is | ||
| 149 | called "hard schedulability property" and is an extension of Lemma 1 of [2]). | ||
| 150 | |||
| 151 | References: | ||
| 152 | 1 - C. L. Liu and J. W. Layland. Scheduling algorithms for multiprogram- | ||
| 153 | ming in a hard-real-time environment. Journal of the Association for | ||
| 154 | Computing Machinery, 20(1), 1973. | ||
| 155 | 2 - L. Abeni , G. Buttazzo. Integrating Multimedia Applications in Hard | ||
| 156 | Real-Time Systems. Proceedings of the 19th IEEE Real-time Systems | ||
| 157 | Symposium, 1998. http://retis.sssup.it/~giorgio/paps/1998/rtss98-cbs.pdf | ||
| 158 | 3 - L. Abeni. Server Mechanisms for Multimedia Applications. ReTiS Lab | ||
| 159 | Technical Report. http://xoomer.virgilio.it/lucabe72/pubs/tr-98-01.ps | ||
| 160 | |||
| 161 | 4. Bandwidth management | ||
| 162 | ======================= | ||
| 163 | |||
