>From 7a0e6747c40cf9186f3645eb94408090ab11936a Mon Sep 17 00:00:00 2001 From: Luca Abeni Date: Sat, 27 Dec 2014 18:20:57 +0100 Subject: [PATCH 03/11] Do not initialize the deadline timer if it is already initialized After commit 67dfa1b756f250972bde31d65e3f8fde6aeddc5b changing the parameters of a SCHED_DEADLINE tasks might crash the system. This happens because 67dfa1b756f250972bde31d65e3f8fde6aeddc5b removed the following lines from init_dl_task_timer(): - if (hrtimer_active(timer)) { - hrtimer_try_to_cancel(timer); - return; - } As a result, if sched_setattr() is invoked to change the parameters (runtime or period) of a SCHED_DEADLINE task, init_dl_task_timer() might end up initializing a pending timer. Fix this problem by modifying __setparam_dl() to call init_dl_task_timer() only if the task is not already a SCHED_DEADLINE one. --- kernel/sched/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b5797b7..470111c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3251,7 +3251,9 @@ __setparam_dl(struct task_struct *p, const struct sched_attr *attr) { struct sched_dl_entity *dl_se = &p->dl; - init_dl_task_timer(dl_se); + if (p->sched_class != &dl_sched_class) { + init_dl_task_timer(dl_se); + } dl_se->dl_runtime = attr->sched_runtime; dl_se->dl_deadline = attr->sched_deadline; dl_se->dl_period = attr->sched_period ?: dl_se->dl_deadline; -- 2.1.0