]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.3/sched-deadline-fix-migration-of-sched_deadline-tasks.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 3.18.3 / sched-deadline-fix-migration-of-sched_deadline-tasks.patch
1 From 6a503c3be937d275113b702e0421e5b0720abe8a Mon Sep 17 00:00:00 2001
2 From: Luca Abeni <luca.abeni@unitn.it>
3 Date: Wed, 17 Dec 2014 11:50:31 +0100
4 Subject: sched/deadline: Fix migration of SCHED_DEADLINE tasks
5
6 From: Luca Abeni <luca.abeni@unitn.it>
7
8 commit 6a503c3be937d275113b702e0421e5b0720abe8a upstream.
9
10 According to global EDF, tasks should be migrated between runqueues
11 without checking if their scheduling deadlines and runtimes are valid.
12 However, SCHED_DEADLINE currently performs such a check:
13 a migration happens doing:
14
15 deactivate_task(rq, next_task, 0);
16 set_task_cpu(next_task, later_rq->cpu);
17 activate_task(later_rq, next_task, 0);
18
19 which ends up calling dequeue_task_dl(), setting the new CPU, and then
20 calling enqueue_task_dl().
21
22 enqueue_task_dl() then calls enqueue_dl_entity(), which calls
23 update_dl_entity(), which can modify scheduling deadline and runtime,
24 breaking global EDF scheduling.
25
26 As a result, some of the properties of global EDF are not respected:
27 for example, a taskset {(30, 80), (40, 80), (120, 170)} scheduled on
28 two cores can have unbounded response times for the third task even
29 if 30/80+40/80+120/170 = 1.5809 < 2
30
31 This can be fixed by invoking update_dl_entity() only in case of
32 wakeup, or if this is a new SCHED_DEADLINE task.
33
34 Signed-off-by: Luca Abeni <luca.abeni@unitn.it>
35 Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
36 Acked-by: Juri Lelli <juri.lelli@gmail.com>
37 Cc: Dario Faggioli <raistlin@linux.it>
38 Cc: Linus Torvalds <torvalds@linux-foundation.org>
39 Link: http://lkml.kernel.org/r/1418813432-20797-2-git-send-email-luca.abeni@unitn.it
40 Signed-off-by: Ingo Molnar <mingo@kernel.org>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42
43 ---
44 kernel/sched/deadline.c | 6 +++---
45 1 file changed, 3 insertions(+), 3 deletions(-)
46
47 --- a/kernel/sched/deadline.c
48 +++ b/kernel/sched/deadline.c
49 @@ -831,10 +831,10 @@ enqueue_dl_entity(struct sched_dl_entity
50 * parameters of the task might need updating. Otherwise,
51 * we want a replenishment of its runtime.
52 */
53 - if (!dl_se->dl_new && flags & ENQUEUE_REPLENISH)
54 - replenish_dl_entity(dl_se, pi_se);
55 - else
56 + if (dl_se->dl_new || flags & ENQUEUE_WAKEUP)
57 update_dl_entity(dl_se, pi_se);
58 + else if (flags & ENQUEUE_REPLENISH)
59 + replenish_dl_entity(dl_se, pi_se);
60
61 __enqueue_dl_entity(dl_se);
62 }