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

From: huangbing@kylinos
Date: Thu Jun 02 2022 - 00:52:57 EST



On 6/1/22 16:45, Dietmar Eggemann wrote:
On 31/05/2022 05:12, 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.

Signed-off-by: Bing Huang <huangbing@xxxxxxxxxx>
---

v2: move load_balance_mask and select_idle_mask allocation from
sched_init() to init_sched_fair_class()
This would align CFS with RT (local_cpu_mask) and DL
(local_cpu_mask_dl).

[...]

@@ -11841,6 +11841,16 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m)
__init void init_sched_fair_class(void)
{
#ifdef CONFIG_SMP
`int i` missing for DEBUG_PER_CPU_MAPS/CONFIG_CPUMASK_OFFSTACK case.
sorry,my fault.

+
+#ifdef CONFIG_CPUMASK_OFFSTACK
+ for_each_possible_cpu(i) {
+ per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
+ cpumask_size(), GFP_KERNEL, cpu_to_node(i));
+ per_cpu(select_idle_mask, i) = (cpumask_var_t)kzalloc_node(
+ cpumask_size(), GFP_KERNEL, cpu_to_node(i));
+ }
+#endif
+
What about:

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 98319b654788..9ef5133c72d6 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11811,15 +11811,14 @@ void show_numa_stats(struct task_struct *p, struct seq_file *m)
__init void init_sched_fair_class(void)
{
#ifdef CONFIG_SMP
+ int i;
-#ifdef CONFIG_CPUMASK_OFFSTACK
for_each_possible_cpu(i) {
- per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
- cpumask_size(), GFP_KERNEL, cpu_to_node(i));
- per_cpu(select_idle_mask, i) = (cpumask_var_t)kzalloc_node(
- cpumask_size(), GFP_KERNEL, cpu_to_node(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));
}
-#endif

to get rid of the #ifdef ? We do the same for RT (local_cpu_mask) and DL
(local_cpu_mask_dl).
good suggestion, thanks very much. happy to do that.

[...]