Re: [RFC PATCH v4 1/2] sched/fair: Introduce short duration task check

From: Dietmar Eggemann
Date: Thu Jan 05 2023 - 06:33:55 EST


On 16/12/2022 07:11, Chen Yu wrote:

[...]

> @@ -5995,6 +6005,18 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
>
> static void set_next_buddy(struct sched_entity *se);
>
> +static inline void dur_avg_update(struct task_struct *p, bool task_sleep)
> +{
> + u64 dur;
> +
> + if (!task_sleep)
> + return;
> +
> + dur = p->se.sum_exec_runtime - p->se.prev_sum_exec_runtime_vol;
> + p->se.prev_sum_exec_runtime_vol = p->se.sum_exec_runtime;

Shouldn't se->prev_sum_exec_runtime_vol be set in enqueue_task_fair()
and not in dequeue_task_fair()->dur_avg_update()? Otherwise `dur` will
contain sleep time.

Like we do for se->prev_sum_exec_runtime in set_next_entity() but for
one `set_next_entity()-put_prev_entity()` run section.

AFAICS, you want to measure the exec_runtime sum over all run sections
between enqueue and dequeue.

> + update_avg(&p->se.dur_avg, dur);
> +}
> +

[...]