[PATCH] sched/core: fix SCHED_DEADLINE admission control

From: Juri Lelli
Date: Fri Sep 04 2015 - 10:41:42 EST


As Documentation/sched/sched-deadline.txt says, a new task can pass
through admission control if sum(WCET_i / min{D_i, P_i}) <= 1.
However, if the user specifies both sched_period and sched_deadline,
we actually check that sum(WCET_i / P_i) <= 1; and this is a less
restrictive check w.r.t. the former.

Fix this by always using sched_deadline parameter to compute new_bw,
as we also impose that runtime <= deadline <= period (if period != 0)
and deadline != 0.

Fixes: 4df1638cfaf9 ("sched/deadline: Fix overflow to handle period==0 and deadline!=0")
Signed-off-by: Juri Lelli <juri.lelli@xxxxxxx>
---
kernel/sched/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 096b73b..56bc449 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2302,9 +2302,9 @@ static int dl_overflow(struct task_struct *p, int policy,
{

struct dl_bw *dl_b = dl_bw_of(task_cpu(p));
- u64 period = attr->sched_period ?: attr->sched_deadline;
+ u64 deadline = attr->sched_deadline;
u64 runtime = attr->sched_runtime;
- u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0;
+ u64 new_bw = dl_policy(policy) ? to_ratio(deadline, runtime) : 0;
int cpus, err = -1;

if (new_bw == p->dl.dl_bw)
--->8---

that we then dediced not to propose since (note that these are just my
memories of the dicussion, so everything it's up for further discussion,
also in light of the problem highlighted by Daniel)

- SCHED_DEADLINE, as the documentation says, does AC using utilization
- it is however true that a sufficient (but not necessary) test on UP for
D_i != P_i cases is the one of my patch above
- we have agreed in the past that the kernel should only check that we
don't cause "overload" in the system (which is still the case if we
consider utilizations), not "hard schedulability"
- also because on SMP systems "sum(WCET_i / min{D_i, P_i}) <= M"
doesn't guarantee much more than the test base on P_i only (there not
seem to be many/any papers around considering the D_i != P_i case on
SMP actually)
- basically the patch above would only matter for the UP/partitioned
cases

Thoughts?

Thanks,

- Juri