linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs
@ 2019-04-12  4:26 Nicholas Piggin
  2019-04-25 11:56 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nicholas Piggin @ 2019-04-12  4:26 UTC (permalink / raw)
  To: Thomas Gleixner, Frederic Weisbecker
  Cc: Nicholas Piggin, Ingo Molnar, Peter Zijlstra, linux-kernel

The nohz idle balancer runs on the lowest idle CPU. This can
interfere with isolated CPUs, so confine it to HK_FLAG_MISC
housekeeping CPUs.

HK_FLAG_SCHED is not used for this because it is not set anywhere
at the moment. This could be folded into HK_FLAG_SCHED once that
option is fixed.

The problem was observed with increased jitter on an application
running on CPU0, caused by nohz idle load balancing being run on
CPU1 (an SMT sibling).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 kernel/sched/fair.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fdab7eb6f351..d29ca323214d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9522,22 +9522,26 @@ static inline int on_null_domain(struct rq *rq)
  * - When one of the busy CPUs notice that there may be an idle rebalancing
  *   needed, they will kick the idle load balancer, which then does idle
  *   load balancing for all the idle CPUs.
+ * - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
+ *   anywhere yet.
  */
 
 static inline int find_new_ilb(void)
 {
-	int ilb = cpumask_first(nohz.idle_cpus_mask);
+	int ilb;
 
-	if (ilb < nr_cpu_ids && idle_cpu(ilb))
-		return ilb;
+	for_each_cpu_and(ilb, nohz.idle_cpus_mask,
+			      housekeeping_cpumask(HK_FLAG_MISC)) {
+		if (idle_cpu(ilb))
+			return ilb;
+	}
 
 	return nr_cpu_ids;
 }
 
 /*
- * Kick a CPU to do the nohz balancing, if it is time for it. We pick the
- * nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
- * CPU (if there is one).
+ * Kick a CPU to do the nohz balancing, if it is time for it. We pick any
+ * idle CPU in the HK_FLAG_MISC housekeeping set (if there is one).
  */
 static void kick_ilb(unsigned int flags)
 {
-- 
2.20.1


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

* Re: [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs
  2019-04-12  4:26 [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs Nicholas Piggin
@ 2019-04-25 11:56 ` Peter Zijlstra
  2019-04-26  4:40   ` Nicholas Piggin
  2019-04-28  7:01 ` Wanpeng Li
  2019-04-29  6:38 ` [tip:sched/core] sched/nohz: Run NOHZ " tip-bot for Nicholas Piggin
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2019-04-25 11:56 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Thomas Gleixner, Frederic Weisbecker, Ingo Molnar, linux-kernel

On Fri, Apr 12, 2019 at 02:26:13PM +1000, Nicholas Piggin wrote:
> The nohz idle balancer runs on the lowest idle CPU. This can
> interfere with isolated CPUs, so confine it to HK_FLAG_MISC
> housekeeping CPUs.
> 
> HK_FLAG_SCHED is not used for this because it is not set anywhere
> at the moment. This could be folded into HK_FLAG_SCHED once that
> option is fixed.

Frederic? Anyway, I thnk I'll take this patch as is.

Thanks!

> The problem was observed with increased jitter on an application
> running on CPU0, caused by nohz idle load balancing being run on
> CPU1 (an SMT sibling).
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  kernel/sched/fair.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fdab7eb6f351..d29ca323214d 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9522,22 +9522,26 @@ static inline int on_null_domain(struct rq *rq)
>   * - When one of the busy CPUs notice that there may be an idle rebalancing
>   *   needed, they will kick the idle load balancer, which then does idle
>   *   load balancing for all the idle CPUs.
> + * - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
> + *   anywhere yet.
>   */
>  
>  static inline int find_new_ilb(void)
>  {
> -	int ilb = cpumask_first(nohz.idle_cpus_mask);
> +	int ilb;
>  
> -	if (ilb < nr_cpu_ids && idle_cpu(ilb))
> -		return ilb;
> +	for_each_cpu_and(ilb, nohz.idle_cpus_mask,
> +			      housekeeping_cpumask(HK_FLAG_MISC)) {
> +		if (idle_cpu(ilb))
> +			return ilb;
> +	}
>  
>  	return nr_cpu_ids;
>  }
>  
>  /*
> - * Kick a CPU to do the nohz balancing, if it is time for it. We pick the
> - * nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
> - * CPU (if there is one).
> + * Kick a CPU to do the nohz balancing, if it is time for it. We pick any
> + * idle CPU in the HK_FLAG_MISC housekeeping set (if there is one).
>   */
>  static void kick_ilb(unsigned int flags)
>  {
> -- 
> 2.20.1
> 

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

* Re: [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs
  2019-04-25 11:56 ` Peter Zijlstra
@ 2019-04-26  4:40   ` Nicholas Piggin
  0 siblings, 0 replies; 6+ messages in thread
From: Nicholas Piggin @ 2019-04-26  4:40 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Frederic Weisbecker, linux-kernel, Ingo Molnar, Thomas Gleixner

Peter Zijlstra's on April 25, 2019 9:56 pm:
> On Fri, Apr 12, 2019 at 02:26:13PM +1000, Nicholas Piggin wrote:
>> The nohz idle balancer runs on the lowest idle CPU. This can
>> interfere with isolated CPUs, so confine it to HK_FLAG_MISC
>> housekeeping CPUs.
>> 
>> HK_FLAG_SCHED is not used for this because it is not set anywhere
>> at the moment. This could be folded into HK_FLAG_SCHED once that
>> option is fixed.
> 
> Frederic? Anyway, I thnk I'll take this patch as is.

That would be great, thanks. We've been testing it in a staging
environment (this is where they noticed the noise in the first
place), and results have been as expected:

  I've been able to test Nick's idle-loop load balancer (ILB) patch, 
  with and without the TEO cpuidle governor. With the ILB patch (and 
  nohz_full) I get a very quiet noise profile with either cpuidle 
  governor (menu or teo). For my tests, I don't see a meaningful 
  difference between the two governors.

  [...]

  Bottom line: Nick's patch that constrains the ILB to run on non-nohz 
  cores has a noticeable noise-reduction effect. For this type of 
  workload, the choice of cpuidle governor, menu or teo, is immaterial.

This is against a slightly backported RHEL kernel they are using, but
no significant differences from upstream in these areas.

Thanks,
Nick


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

* Re: [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs
  2019-04-12  4:26 [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs Nicholas Piggin
  2019-04-25 11:56 ` Peter Zijlstra
@ 2019-04-28  7:01 ` Wanpeng Li
  2019-04-28 11:58   ` Nicholas Piggin
  2019-04-29  6:38 ` [tip:sched/core] sched/nohz: Run NOHZ " tip-bot for Nicholas Piggin
  2 siblings, 1 reply; 6+ messages in thread
From: Wanpeng Li @ 2019-04-28  7:01 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Thomas Gleixner, Frederic Weisbecker, Ingo Molnar, Peter Zijlstra, LKML

On Fri, 12 Apr 2019 at 12:27, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> The nohz idle balancer runs on the lowest idle CPU. This can
> interfere with isolated CPUs, so confine it to HK_FLAG_MISC
> housekeeping CPUs.
>
> HK_FLAG_SCHED is not used for this because it is not set anywhere
> at the moment. This could be folded into HK_FLAG_SCHED once that
> option is fixed.
>
> The problem was observed with increased jitter on an application
> running on CPU0, caused by nohz idle load balancing being run on
> CPU1 (an SMT sibling).
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  kernel/sched/fair.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index fdab7eb6f351..d29ca323214d 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9522,22 +9522,26 @@ static inline int on_null_domain(struct rq *rq)
>   * - When one of the busy CPUs notice that there may be an idle rebalancing
>   *   needed, they will kick the idle load balancer, which then does idle
>   *   load balancing for all the idle CPUs.
> + * - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
> + *   anywhere yet.
>   */
>
>  static inline int find_new_ilb(void)
>  {
> -       int ilb = cpumask_first(nohz.idle_cpus_mask);
> +       int ilb;
>
> -       if (ilb < nr_cpu_ids && idle_cpu(ilb))
> -               return ilb;
> +       for_each_cpu_and(ilb, nohz.idle_cpus_mask,
> +                             housekeeping_cpumask(HK_FLAG_MISC)) {
> +               if (idle_cpu(ilb))
> +                       return ilb;
> +       }

What will happen if cpu1 is still idle currently && housekeeping?

Regards,
Wanpeng Li

>
>         return nr_cpu_ids;
>  }
>
>  /*
> - * Kick a CPU to do the nohz balancing, if it is time for it. We pick the
> - * nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
> - * CPU (if there is one).
> + * Kick a CPU to do the nohz balancing, if it is time for it. We pick any
> + * idle CPU in the HK_FLAG_MISC housekeeping set (if there is one).
>   */
>  static void kick_ilb(unsigned int flags)
>  {
> --
> 2.20.1
>

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

* Re: [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs
  2019-04-28  7:01 ` Wanpeng Li
@ 2019-04-28 11:58   ` Nicholas Piggin
  0 siblings, 0 replies; 6+ messages in thread
From: Nicholas Piggin @ 2019-04-28 11:58 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Frederic Weisbecker, LKML, Ingo Molnar, Peter Zijlstra, Thomas Gleixner

Wanpeng Li's on April 28, 2019 5:01 pm:
> On Fri, 12 Apr 2019 at 12:27, Nicholas Piggin <npiggin@gmail.com> wrote:
>>
>> The nohz idle balancer runs on the lowest idle CPU. This can
>> interfere with isolated CPUs, so confine it to HK_FLAG_MISC
>> housekeeping CPUs.
>>
>> HK_FLAG_SCHED is not used for this because it is not set anywhere
>> at the moment. This could be folded into HK_FLAG_SCHED once that
>> option is fixed.
>>
>> The problem was observed with increased jitter on an application
>> running on CPU0, caused by nohz idle load balancing being run on
>> CPU1 (an SMT sibling).
>>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>  kernel/sched/fair.c | 16 ++++++++++------
>>  1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index fdab7eb6f351..d29ca323214d 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -9522,22 +9522,26 @@ static inline int on_null_domain(struct rq *rq)
>>   * - When one of the busy CPUs notice that there may be an idle rebalancing
>>   *   needed, they will kick the idle load balancer, which then does idle
>>   *   load balancing for all the idle CPUs.
>> + * - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
>> + *   anywhere yet.
>>   */
>>
>>  static inline int find_new_ilb(void)
>>  {
>> -       int ilb = cpumask_first(nohz.idle_cpus_mask);
>> +       int ilb;
>>
>> -       if (ilb < nr_cpu_ids && idle_cpu(ilb))
>> -               return ilb;
>> +       for_each_cpu_and(ilb, nohz.idle_cpus_mask,
>> +                             housekeeping_cpumask(HK_FLAG_MISC)) {
>> +               if (idle_cpu(ilb))
>> +                       return ilb;
>> +       }
> 
> What will happen if cpu1 is still idle currently && housekeeping?

Then it will run the ilb.

In the customer scenario, cpu1 will not be in the housekeeping mask.

Thanks,
Nick


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

* [tip:sched/core] sched/nohz: Run NOHZ idle load balancer on HK_FLAG_MISC CPUs
  2019-04-12  4:26 [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs Nicholas Piggin
  2019-04-25 11:56 ` Peter Zijlstra
  2019-04-28  7:01 ` Wanpeng Li
@ 2019-04-29  6:38 ` tip-bot for Nicholas Piggin
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Nicholas Piggin @ 2019-04-29  6:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, npiggin, tglx, mingo, hpa, torvalds, fweisbec, peterz

Commit-ID:  9b019acb72e4b5741d88e8936d6f200ed44b66b2
Gitweb:     https://git.kernel.org/tip/9b019acb72e4b5741d88e8936d6f200ed44b66b2
Author:     Nicholas Piggin <npiggin@gmail.com>
AuthorDate: Fri, 12 Apr 2019 14:26:13 +1000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 29 Apr 2019 08:27:03 +0200

sched/nohz: Run NOHZ idle load balancer on HK_FLAG_MISC CPUs

The NOHZ idle balancer runs on the lowest idle CPU. This can
interfere with isolated CPUs, so confine it to HK_FLAG_MISC
housekeeping CPUs.

HK_FLAG_SCHED is not used for this because it is not set anywhere
at the moment. This could be folded into HK_FLAG_SCHED once that
option is fixed.

The problem was observed with increased jitter on an application
running on CPU0, caused by NOHZ idle load balancing being run on
CPU1 (an SMT sibling).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190412042613.28930-1-npiggin@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/fair.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 13bafe350abf..7b0da7007da3 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9519,22 +9519,26 @@ static inline int on_null_domain(struct rq *rq)
  * - When one of the busy CPUs notice that there may be an idle rebalancing
  *   needed, they will kick the idle load balancer, which then does idle
  *   load balancing for all the idle CPUs.
+ * - HK_FLAG_MISC CPUs are used for this task, because HK_FLAG_SCHED not set
+ *   anywhere yet.
  */
 
 static inline int find_new_ilb(void)
 {
-	int ilb = cpumask_first(nohz.idle_cpus_mask);
+	int ilb;
 
-	if (ilb < nr_cpu_ids && idle_cpu(ilb))
-		return ilb;
+	for_each_cpu_and(ilb, nohz.idle_cpus_mask,
+			      housekeeping_cpumask(HK_FLAG_MISC)) {
+		if (idle_cpu(ilb))
+			return ilb;
+	}
 
 	return nr_cpu_ids;
 }
 
 /*
- * Kick a CPU to do the nohz balancing, if it is time for it. We pick the
- * nohz_load_balancer CPU (if there is one) otherwise fallback to any idle
- * CPU (if there is one).
+ * Kick a CPU to do the nohz balancing, if it is time for it. We pick any
+ * idle CPU in the HK_FLAG_MISC housekeeping set (if there is one).
  */
 static void kick_ilb(unsigned int flags)
 {

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

end of thread, other threads:[~2019-04-29  6:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12  4:26 [PATCH] kernel/sched: run nohz idle load balancer on HK_FLAG_MISC CPUs Nicholas Piggin
2019-04-25 11:56 ` Peter Zijlstra
2019-04-26  4:40   ` Nicholas Piggin
2019-04-28  7:01 ` Wanpeng Li
2019-04-28 11:58   ` Nicholas Piggin
2019-04-29  6:38 ` [tip:sched/core] sched/nohz: Run NOHZ " tip-bot for Nicholas Piggin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).