lkml.org 
[lkml]   [2012]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 05/16] sched: SCHED_DEADLINE policy implementation.
From
Date
On Fri, 2012-04-06 at 09:14 +0200, Juri Lelli wrote:
> +static int start_dl_timer(struct sched_dl_entity *dl_se)
> +{
> + struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
> + struct rq *rq = rq_of_dl_rq(dl_rq);
> + ktime_t now, act;
> + ktime_t soft, hard;
> + unsigned long range;
> + s64 delta;
> +
> + /*
> + * We want the timer to fire at the deadline, but considering
> + * that it is actually coming from rq->clock and not from
> + * hrtimer's time base reading.
> + */
> + act = ns_to_ktime(dl_se->deadline);
> + now = hrtimer_cb_get_time(&dl_se->dl_timer);
> + delta = ktime_to_ns(now) - rq->clock;
> + act = ktime_add_ns(act, delta);


Right, this all is very sad.. but I guess we'll have to like live with
it. The only other option is adding another timer base that tries to
keep itself in sync with rq->clock but that all sounds very painful
indeed.

Keeping up with rq->clock_task would be even more painful since it slows
the clock down in random fashion making the timer fire early.
Compensating that is going to be both fun and expensive.

> + /*
> + * If the expiry time already passed, e.g., because the value
> + * chosen as the deadline is too small, don't even try to
> + * start the timer in the past!
> + */
> + if (ktime_us_delta(act, now) < 0)
> + return 0;
> +
> + hrtimer_set_expires(&dl_se->dl_timer, act);
> +
> + soft = hrtimer_get_softexpires(&dl_se->dl_timer);
> + hard = hrtimer_get_expires(&dl_se->dl_timer);
> + range = ktime_to_ns(ktime_sub(hard, soft));
> + __hrtimer_start_range_ns(&dl_se->dl_timer, soft,
> + range, HRTIMER_MODE_ABS, 0);
> +
> + return hrtimer_active(&dl_se->dl_timer);
> +}

/me reminds himself to make __hrtimer_start_range_ns() return -ETIME.


\
 
 \ /
  Last update: 2012-04-23 16:15    [W:0.471 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site