Re: [PATCH 3/6] sched: Report the different kinds of imbalances in /proc/schedstat
From: Peter Zijlstra
Date: Wed Dec 18 2024 - 06:40:32 EST
On Wed, Dec 18, 2024 at 04:36:26AM +0000, Swapnil Sapkal wrote:
> +static void update_lb_imbalance_stat(struct lb_env *env, struct sched_domain *sd,
> + enum cpu_idle_type idle)
> +{
> + switch (env->migration_type) {
> + case migrate_load:
> + schedstat_add(sd->lb_imbalance_load[idle], env->imbalance);
> + break;
> + case migrate_util:
> + schedstat_add(sd->lb_imbalance_util[idle], env->imbalance);
> + break;
> + case migrate_task:
> + schedstat_add(sd->lb_imbalance_task[idle], env->imbalance);
> + break;
> + case migrate_misfit:
> + schedstat_add(sd->lb_imbalance_misfit[idle], env->imbalance);
> + break;
> + }
> +}
Can you please write that like:
if (!schedstat_enabled())
return;
switch () {
case ...
__schedstat_add();
}
It makes no sense to have 4 copies of schedstat_enabled() inside the
switch statement -- esp. since afaik the compilers aren't able to CSE
static keys :/