[PATCH 2/3] fix a bug in the -deadline utilization tracking mechanism

From: Juri Lelli
Date: Thu Feb 25 2016 - 09:50:42 EST


Currently, a task doing
while(1) {
switch to SCHED_DEADLINE
switch to SCHED_OTHER
}
brings dl_b->total_bw below 0.
This happens because when the task switches back from SCHED_DEADLINE
to SCHED_OTHER, switched_from_dl() does not clear its deadline
parameters (they will be cleared by the deadline timer when it fires).
But dl_overflow() removes its utilization from dl_b->total_bw.
When the task switches back to SCHED_DEADLINE, the
if (new_bw == p->dl.dl_bw)
check in dl_overflow() prevents __dl_add() from being called, and
so when the task switches back to SCHED_OTHER dl_b->total_bw becomes
negative.
This patch changes the check so that if the task is switching from
SCHED_OTHER to SCHED_DEADLINE __dl_add() is correctly invoked.
---
kernel/sched/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9503d59..d59fa20 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2432,7 +2432,7 @@ static int dl_overflow(struct task_struct *p, int policy,
u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0;
int cpus, err = -1;

- if (new_bw == p->dl.dl_bw)
+ if (task_has_dl_policy(p) && new_bw == p->dl.dl_bw)
return 0;

/*
--
2.5.0