Re: [PATCH v3] sched/fair: static cpumasks for load balance

From: Dietmar Eggemann
Date: Tue Jun 07 2022 - 04:27:57 EST


On 02/06/2022 05:01, Bing Huang wrote:
> The both cpu mask load_balance_mask and select_idle_mask just only used
> in fair.c, but allocation in core.c in CONFIG_CPUMASK_OFFSTACK=y case,
> and global via declare per cpu variations. More or less, it looks wired.

Maybe you can change this into:

sched/fair: Make per-cpu cpumasks static

load_balance_mask and select_idle_mask are only used in fair.c. Make
them static and move their allocation into init_sched_fair_class().

Replace kzalloc_node() with zalloc_cpumask_var_node() to get rid of the
CONFIG_CPUMASK_OFFSTACK #ifdef and to align with per-cpu cpumask
allocation for RT (local_cpu_mask in init_sched_rt_class()) and DL
class (local_cpu_mask_dl in init_sched_dl_class()).

> Co-developed-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>

You can remove the `Co-developed-by`. I was just reviewing the patch and
gave suggestions.

[...]

> @@ -11841,6 +11841,15 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m)
> __init void init_sched_fair_class(void)
> {
> #ifdef CONFIG_SMP
> + int i;
> +
> + for_each_possible_cpu(i) {
> + zalloc_cpumask_var_node(&per_cpu(load_balance_mask, i),
> + GFP_KERNEL, cpu_to_node(i));
> + zalloc_cpumask_var_node(&per_cpu(select_idle_mask, i),
> + GFP_KERNEL, cpu_to_node(i));

@@ -11815,9 +11815,9 @@ __init void init_sched_fair_class(void)

for_each_possible_cpu(i) {
zalloc_cpumask_var_node(&per_cpu(load_balance_mask, i),
- GFP_KERNEL, cpu_to_node(i));
+ GFP_KERNEL, cpu_to_node(i));
zalloc_cpumask_var_node(&per_cpu(select_idle_mask, i),
- GFP_KERNEL, cpu_to_node(i));
+ GFP_KERNEL, cpu_to_node(i));
}

[...]

Reviewed-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>