Skip to content

Commit

Permalink
sched: rt-group: fixup schedulability constraints calculation
Browse files Browse the repository at this point in the history
it was only possible to configure the rt-group scheduling parameters
beyond the default value in a very small range.

that's because div64_64() has a different calling convention than
do_div() :/

fix a few untidies while we are here; sysctl_sched_rt_period may overflow
due to that multiplication, so cast to u64 first. Also that RUNTIME_INF
juggling makes little sense although its an effective NOP.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Mar 7, 2008
1 parent 1868f95 commit 2692a24
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -7726,9 +7726,7 @@ static unsigned long to_ratio(u64 period, u64 runtime)
if (runtime == RUNTIME_INF)
return 1ULL << 16;

runtime *= (1ULL << 16);
div64_64(runtime, period);
return runtime;
return div64_64(runtime << 16, period);
}

static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime)
Expand Down Expand Up @@ -7757,18 +7755,16 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
u64 rt_runtime, rt_period;
int err = 0;

rt_period = sysctl_sched_rt_period * NSEC_PER_USEC;
rt_period = (u64)sysctl_sched_rt_period * NSEC_PER_USEC;
rt_runtime = (u64)rt_runtime_us * NSEC_PER_USEC;
if (rt_runtime_us == -1)
rt_runtime = rt_period;
rt_runtime = RUNTIME_INF;

mutex_lock(&rt_constraints_mutex);
if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
err = -EINVAL;
goto unlock;
}
if (rt_runtime_us == -1)
rt_runtime = RUNTIME_INF;
tg->rt_runtime = rt_runtime;
unlock:
mutex_unlock(&rt_constraints_mutex);
Expand Down

0 comments on commit 2692a24

Please sign in to comment.