Re: [RFC PATCH 2/3] sched: Introduce Window-Assisted CPU utilization Tracking

From: Peter Zijlstra
Date: Fri Oct 28 2016 - 03:52:42 EST


On Fri, Oct 28, 2016 at 12:10:41AM -0700, Vikram Mulukutla wrote:
> +static int account_cpu_busy_time(struct rq *rq, struct task_struct *p,
> + u64 irqtime, int event)
> +{
> + if (is_idle_task(p)) {
> + /* TASK_WAKE && TASK_MIGRATE is not possible on idle task! */
> + if (event == PICK_NEXT_TASK)
> + return 0;
> +
> + /* PUT_PREV_TASK, TASK_UPDATE && IRQ_UPDATE are left */
> + return irqtime || cpu_is_waiting_on_io(rq);
> + }
> +
> + if (event == TASK_WAKE)
> + return 0;
> +
> + if (event == PUT_PREV_TASK || event == IRQ_UPDATE ||
> + event == TASK_UPDATE)
> + return 1;
> +
> + /* Only TASK_MIGRATE && PICK_NEXT_TASK left */
> + return walt_freq_account_wait_time;
> +}

switch() wasn't an option?