All of lore.kernel.org
 help / color / mirror / Atom feed
* [tip:sched/core] sched, nohz: Isolated cores do not load balance
@ 2014-02-21 21:34 tip-bot for Mike Galbraith
  2014-02-24  2:11 ` [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing Lei Wen
  0 siblings, 1 reply; 5+ messages in thread
From: tip-bot for Mike Galbraith @ 2014-02-21 21:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mgalbraith, hpa, mingo, peterz, leiwen, tglx

Commit-ID:  6833dbedc680daac32418f919e675d208eb45fa9
Gitweb:     http://git.kernel.org/tip/6833dbedc680daac32418f919e675d208eb45fa9
Author:     Mike Galbraith <mgalbraith@suse.de>
AuthorDate: Mon, 5 Dec 2011 10:01:47 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:21 +0100

sched, nohz: Isolated cores do not load balance

The user explicitly disabled load balancing, else this core would not be
disconnected.  Don't add these to nohz.idle_cpus_mask.

Cc: Lei Wen <leiwen@marvell.com>
Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-vmme4f49psirp966pklm5l9j@git.kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sched/fair.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 37ee473..9ca5d57 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6802,6 +6802,11 @@ out_unlock:
 	return 0;
 }
 
+static inline int on_null_domain(struct rq *rq)
+{
+	return unlikely(!rcu_dereference_sched(rq->sd));
+}
+
 #ifdef CONFIG_NO_HZ_COMMON
 /*
  * idle load balancing details
@@ -6856,8 +6861,13 @@ static void nohz_balancer_kick(void)
 static inline void nohz_balance_exit_idle(int cpu)
 {
 	if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))) {
-		cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
-		atomic_dec(&nohz.nr_cpus);
+		/*
+		 * Completely isolated CPUs don't ever set, so we must test.
+		 */
+		if (likely(cpumask_test_cpu(cpu, nohz.idle_cpus_mask))) {
+			cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
+			atomic_dec(&nohz.nr_cpus);
+		}
 		clear_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
 	}
 }
@@ -6911,6 +6921,12 @@ void nohz_balance_enter_idle(int cpu)
 	if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
 		return;
 
+	/*
+	 * If we're a completely isolated CPU, we don't play.
+	 */
+	if (on_null_domain(cpu_rq(cpu)))
+		return;
+
 	cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
 	atomic_inc(&nohz.nr_cpus);
 	set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
@@ -7173,11 +7189,6 @@ static void run_rebalance_domains(struct softirq_action *h)
 	nohz_idle_balance(this_rq, idle);
 }
 
-static inline int on_null_domain(struct rq *rq)
-{
-	return !rcu_dereference_sched(rq->sd);
-}
-
 /*
  * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing.
  */

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

* Re: [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing
  2014-02-21 21:34 [tip:sched/core] sched, nohz: Isolated cores do not load balance tip-bot for Mike Galbraith
@ 2014-02-24  2:11 ` Lei Wen
  2014-02-24  3:18   ` Mike Galbraith
  2014-02-24  7:07   ` Peter Zijlstra
  0 siblings, 2 replies; 5+ messages in thread
From: Lei Wen @ 2014-02-24  2:11 UTC (permalink / raw)
  To: mingo, hpa, mgalbraith, linux-kernel, peterz, leiwen, tglx
  Cc: linux-tip-commits

On Sun, Feb 23, 2014 at 2:04 AM, tip-bot for Mike Galbraith
<tipbot@zytor.com> wrote:
> Commit-ID:  d987fc7f3228bf94cb6b21313ebab1d64ee637ad
> Gitweb:     http://git.kernel.org/tip/d987fc7f3228bf94cb6b21313ebab1d64ee637ad
> Author:     Mike Galbraith <mgalbraith@suse.de>
> AuthorDate: Mon, 5 Dec 2011 10:01:47 +0100
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Sat, 22 Feb 2014 18:17:22 +0100
>
> sched, nohz: Exclude isolated cores from load balancing
>
> The user explicitly disabled load balancing, else this core would not be
> disconnected.  Don't add these to nohz.idle_cpus_mask.
>
> Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
> Signed-off-by: Peter Zijlstra <peterz@infradead.org>
> Cc: Lei Wen <leiwen@marvell.com>
> Link: http://lkml.kernel.org/n/tip-vmme4f49psirp966pklm5l9j@git.kernel.org
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  kernel/sched/fair.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 7982faf..a3a41c61 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6788,6 +6788,11 @@ out_unlock:
>         return 0;
>  }
>
> +static inline int on_null_domain(struct rq *rq)
> +{
> +       return unlikely(!rcu_dereference_sched(rq->sd));
> +}
> +
>  #ifdef CONFIG_NO_HZ_COMMON
>  /*
>   * idle load balancing details
> @@ -6842,8 +6847,13 @@ static void nohz_balancer_kick(void)
>  static inline void nohz_balance_exit_idle(int cpu)
>  {
>         if (unlikely(test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))) {
> -               cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
> -               atomic_dec(&nohz.nr_cpus);
> +               /*
> +                * Completely isolated CPUs don't ever set, so we must test.
> +                */
> +               if (likely(cpumask_test_cpu(cpu, nohz.idle_cpus_mask))) {
> +                       cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);

How about use the API as cpumask_test_and_clear_cpu?
Then below one line is enough.

 +               if (likely(cpumask_test_and_clear_cpu(cpu,
nohz.idle_cpus_mask))) {

And I am not pretty sure whether we need such test here.
Since if one cpu is set to NULL domain, it would not set NOHZ_TICK_STOPPED.
And it would not enter into this logic.
Unless that cpu is set to NULL domain when it already run after
nohz_balance_enter_idle.
Not sure what status would it be, and whether it could be set NULL
domain then...

> +                       atomic_dec(&nohz.nr_cpus);

> +               }
>                 clear_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
>         }
>  }
> @@ -6897,6 +6907,12 @@ void nohz_balance_enter_idle(int cpu)
>         if (test_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu)))
>                 return;
>
> +       /*
> +        * If we're a completely isolated CPU, we don't play.
> +        */
> +       if (on_null_domain(cpu_rq(cpu)))
> +               return;
> +

Great! it is much better than my previous patch.

>         cpumask_set_cpu(cpu, nohz.idle_cpus_mask);
>         atomic_inc(&nohz.nr_cpus);
>         set_bit(NOHZ_TICK_STOPPED, nohz_flags(cpu));
> @@ -7159,11 +7175,6 @@ static void run_rebalance_domains(struct softirq_action *h)
>         nohz_idle_balance(this_rq, idle);
>  }
>
> -static inline int on_null_domain(struct rq *rq)
> -{
> -       return !rcu_dereference_sched(rq->sd);
> -}
> -
>  /*
>   * Trigger the SCHED_SOFTIRQ if it is time to do periodic load balancing.
>   */
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing
  2014-02-24  2:11 ` [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing Lei Wen
@ 2014-02-24  3:18   ` Mike Galbraith
  2014-02-24  7:07   ` Peter Zijlstra
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Galbraith @ 2014-02-24  3:18 UTC (permalink / raw)
  To: Lei Wen; +Cc: mingo, hpa, linux-kernel, peterz, leiwen, tglx, linux-tip-commits

On Mon, 2014-02-24 at 10:11 +0800, Lei Wen wrote:

> How about use the API as cpumask_test_and_clear_cpu?
> Then below one line is enough.

Yeah.

> +               if (likely(cpumask_test_and_clear_cpu(cpu,
> nohz.idle_cpus_mask))) {
> 
> And I am not pretty sure whether we need such test here.

It was born because I watched me wreck nohz.nr_cpus :)

-Mike


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

* Re: [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing
  2014-02-24  2:11 ` [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing Lei Wen
  2014-02-24  3:18   ` Mike Galbraith
@ 2014-02-24  7:07   ` Peter Zijlstra
  2014-02-24  7:13     ` Lei Wen
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2014-02-24  7:07 UTC (permalink / raw)
  To: Lei Wen
  Cc: mingo, hpa, mgalbraith, linux-kernel, leiwen, tglx, linux-tip-commits

On Mon, Feb 24, 2014 at 10:11:05AM +0800, Lei Wen wrote:
> How about use the API as cpumask_test_and_clear_cpu?
> Then below one line is enough.

Its more expensive.


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

* Re: [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing
  2014-02-24  7:07   ` Peter Zijlstra
@ 2014-02-24  7:13     ` Lei Wen
  0 siblings, 0 replies; 5+ messages in thread
From: Lei Wen @ 2014-02-24  7:13 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: mingo, hpa, mgalbraith, linux-kernel, leiwen, tglx, linux-tip-commits

On Mon, Feb 24, 2014 at 3:07 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> On Mon, Feb 24, 2014 at 10:11:05AM +0800, Lei Wen wrote:
>> How about use the API as cpumask_test_and_clear_cpu?
>> Then below one line is enough.
>
> Its more expensive.
>

I see...
No problem for me then.

Acked-by: Lei Wen <leiwen@marvell.com>

Thanks,
Lei

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

end of thread, other threads:[~2014-02-24  7:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 21:34 [tip:sched/core] sched, nohz: Isolated cores do not load balance tip-bot for Mike Galbraith
2014-02-24  2:11 ` [tip:sched/core] sched, nohz: Exclude isolated cores from load balancing Lei Wen
2014-02-24  3:18   ` Mike Galbraith
2014-02-24  7:07   ` Peter Zijlstra
2014-02-24  7:13     ` Lei Wen

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.