Re: [PATCH v3 5/6] KVM-GST: adjust scheduler cpu power

Peter Zijlstra
2011-02-11T19:05:45Z

On Fri, 2011-02-11 at 13:19 -0500, Glauber Costa wrote:

> static void update_rq_clock_task(struct rq *rq, s64 delta)
> {
> + s64 irq_delta = 0, steal = 0;
>
> +#ifdef CONFIG_IRQ_TIME_ACCOUNTING
> irq_delta = irq_time_read(cpu_of(rq)) - rq->prev_irq_time;
>
> /*
> @@ -1926,20 +1932,24 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
>
> rq->prev_irq_time += irq_delta;
> delta -= irq_delta;
> +#endif
> +#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
>
> + steal = steal_time_clock(cpu_of(rq)) - rq->prev_steal_time;
>
> + if (steal > delta)
> + steal = delta;
> +
> + rq->prev_steal_time += steal;
> +
> + delta -= steal;
> +#endif
>
> rq->clock_task += delta;
>
> + if ((irq_delta + steal) && sched_feat(NONTASK_POWER))
> + sched_rt_avg_update(rq, irq_delta + steal);
> +}

I think we should make both these conditional, like:

#ifdef CONFIG_IRQ_TIME_ACCOUNTING
if (sched_clock_irqtime) {
/* ... magic ... */
}
#endif

#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
if (sched_paravirt_time) {
/* ... magic ... */
}
#endif

Once the jump-label stuff gets a bit better we could use the if
(static_branch()) magic to avoid pretty much all cost.