All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sched/fair: static cpumasks for load balance
@ 2022-05-31  3:12 Bing Huang
  2022-06-01  8:45 ` Dietmar Eggemann
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Huang @ 2022-05-31  3:12 UTC (permalink / raw)
  To: peterz
  Cc: brauner, bristot, bsegall, dietmar.eggemann, juri.lelli,
	linux-kernel, mgorman, mingo, rostedt, vincent.guittot

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@kylinos.cn>
---

 v2: move load_balance_mask and select_idle_mask allocation from
sched_init() to init_sched_fair_class()   

 kernel/sched/core.c | 11 -----------
 kernel/sched/fair.c | 14 ++++++++++++--
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 696c6490bd5b..707df2aeebf8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9503,9 +9503,6 @@ LIST_HEAD(task_groups);
 static struct kmem_cache *task_group_cache __read_mostly;
 #endif
 
-DECLARE_PER_CPU(cpumask_var_t, load_balance_mask);
-DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
-
 void __init sched_init(void)
 {
 	unsigned long ptr = 0;
@@ -9549,14 +9546,6 @@ void __init sched_init(void)
 
 #endif /* CONFIG_RT_GROUP_SCHED */
 	}
-#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
 
 	init_rt_bandwidth(&def_rt_bandwidth, global_rt_period(), global_rt_runtime());
 
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8c5b74f66bd3..377d908866ab 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5843,8 +5843,8 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
 #ifdef CONFIG_SMP
 
 /* Working cpumask for: load_balance, load_balance_newidle. */
-DEFINE_PER_CPU(cpumask_var_t, load_balance_mask);
-DEFINE_PER_CPU(cpumask_var_t, select_idle_mask);
+static DEFINE_PER_CPU(cpumask_var_t, load_balance_mask);
+static DEFINE_PER_CPU(cpumask_var_t, select_idle_mask);
 
 #ifdef CONFIG_NO_HZ_COMMON
 
@@ -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
+
+#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
+
 	open_softirq(SCHED_SOFTIRQ, run_rebalance_domains);
 
 #ifdef CONFIG_NO_HZ_COMMON
-- 
2.25.1


No virus found
		Checked by Hillstone Network AntiVirus

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] sched/fair: static cpumasks for load balance
  2022-05-31  3:12 [PATCH v2] sched/fair: static cpumasks for load balance Bing Huang
@ 2022-06-01  8:45 ` Dietmar Eggemann
  2022-06-02  2:56   ` huangbing@kylinos
  0 siblings, 1 reply; 3+ messages in thread
From: Dietmar Eggemann @ 2022-06-01  8:45 UTC (permalink / raw)
  To: Bing Huang, peterz
  Cc: brauner, bristot, bsegall, juri.lelli, linux-kernel, mgorman,
	mingo, rostedt, vincent.guittot

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@kylinos.cn>
> ---
> 
>  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.

> +
> +#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).

[...]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] sched/fair: static cpumasks for load balance
  2022-06-01  8:45 ` Dietmar Eggemann
@ 2022-06-02  2:56   ` huangbing@kylinos
  0 siblings, 0 replies; 3+ messages in thread
From: huangbing@kylinos @ 2022-06-02  2:56 UTC (permalink / raw)
  To: Dietmar Eggemann, peterz
  Cc: brauner, bristot, bsegall, juri.lelli, linux-kernel, mgorman,
	mingo, rostedt, vincent.guittot


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@kylinos.cn>
>> ---
>>
>>   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.
>
> [...]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-02  4:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31  3:12 [PATCH v2] sched/fair: static cpumasks for load balance Bing Huang
2022-06-01  8:45 ` Dietmar Eggemann
2022-06-02  2:56   ` huangbing@kylinos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.