Re: [PATCH v2 06/22] sched/fair: Collect load-balancing stats for IPC classes

From: Dietmar Eggemann
Date: Wed Dec 07 2022 - 12:01:00 EST


On 28/11/2022 14:20, Ricardo Neri wrote:

[...]

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 224107278471..3a1d6c50a19b 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9100,6 +9100,57 @@ group_type group_classify(unsigned int imbalance_pct,
> return group_has_spare;
> }
>
> +struct sg_lb_ipcc_stats {
> + int min_score; /* Min(score(rq->curr->ipcc)) */
> + int min_ipcc; /* Min(rq->curr->ipcc) */
> + long sum_score; /* Sum(score(rq->curr->ipcc)) */
> +};

Wouldn't it be cleaner to put `min_score`, `min_ipcc` and `sum_score`
into `struct sg_lb_stats` next to `ipcc_score_{after, before}` under the
same #ifdef CONFIG_IPC_CLASSES?

Looks like those IPCC stats would only be needed in the specific
condition under which update_sg_lb_stats_scores() is called?

> +#ifdef CONFIG_IPC_CLASSES
> +static void init_rq_ipcc_stats(struct sg_lb_ipcc_stats *sgcs)
> +{
> + *sgcs = (struct sg_lb_ipcc_stats) {
> + .min_score = INT_MAX,
> + };
> +}
> +
> +/** Called only if cpu_of(@rq) is not idle and has tasks running. */
> +static void update_sg_lb_ipcc_stats(struct sg_lb_ipcc_stats *sgcs,
> + struct rq *rq)
> +{
> + struct task_struct *curr;
> + unsigned short ipcc;
> + int score;
> +
> + if (!sched_ipcc_enabled())
> + return;
> +
> + curr = rcu_dereference(rq->curr);
> + if (!curr || (curr->flags & PF_EXITING) || is_idle_task(curr))

So the Idle task is excluded but RT, DL, (Stopper) tasks are not. Looks
weird if non-CFS tasks could influence CFS load-balancing.
AFAICS, RT and DL tasks could have p->ipcc != IPC_CLASS_UNCLASSIFIED?

[...]