public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance
@ 2015-03-27  7:25 Wanpeng Li
  2015-03-27  7:58 ` Jason Low
  2015-03-27 16:57 ` Preeti U Murthy
  0 siblings, 2 replies; 4+ messages in thread
From: Wanpeng Li @ 2015-03-27  7:25 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra
  Cc: Srikar Dronamraju, Jason Low, Preeti U Murthy, linux-kernel,
	Wanpeng Li

As Srikar pointed out (https://lkml.org/lkml/2015/3/27/26):

| With the current code when the ilb cpus are not free: 
| - We would be updating the nohz.next_balance even through we havent done
|   any load balance.
| - We might iterate thro the nohz.idle_cpus_mask()s to find balance_cpus.

This patch fix it by adding need_resched check with the idle check, and 
keep the need_resched check in for loop to catch ilb get busy. 

Suggested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
---
 kernel/sched/fair.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0576ce0..1d3e17f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7639,7 +7639,8 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
 	int balance_cpu;
 
 	if (idle != CPU_IDLE ||
-	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
+	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)) ||
+		need_resched())
 		goto end;
 
 	for_each_cpu(balance_cpu, nohz.idle_cpus_mask) {
-- 
1.9.1


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

* Re: [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance
  2015-03-27  7:58 ` Jason Low
@ 2015-03-27  7:45   ` Wanpeng Li
  0 siblings, 0 replies; 4+ messages in thread
From: Wanpeng Li @ 2015-03-27  7:45 UTC (permalink / raw)
  To: Jason Low
  Cc: Ingo Molnar, Peter Zijlstra, Srikar Dronamraju, Preeti U Murthy,
	linux-kernel, jason.low2

On Fri, Mar 27, 2015 at 12:58:22AM -0700, Jason Low wrote:
>On Fri, 2015-03-27 at 15:25 +0800, Wanpeng Li wrote:
>> As Srikar pointed out (https://lkml.org/lkml/2015/3/27/26):
>> 
>> | With the current code when the ilb cpus are not free: 
>> | - We would be updating the nohz.next_balance even through we havent done
>> |   any load balance.
>> | - We might iterate thro the nohz.idle_cpus_mask()s to find balance_cpus.
>> 
>> This patch fix it by adding need_resched check with the idle check, and 
>> keep the need_resched check in for loop to catch ilb get busy. 
>> 
>> Suggested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
>> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
>> ---
>>  kernel/sched/fair.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 0576ce0..1d3e17f 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -7639,7 +7639,8 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
>>  	int balance_cpu;
>>  
>>  	if (idle != CPU_IDLE ||
>> -	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
>> +	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)) ||
>> +		need_resched())
>>  		goto end;
>
>How about having:
>
>	if (idle != CPU_IDLE || need_resched() ||
>	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
>
>which wouldn't require adding a new line.

Will do.

>
>Besides that:
>
>Reviewed-by: Jason Low <jason.low2@hp.com>

Thanks, ;)

Regards,
Wanpeng Li

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

* Re: [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance
  2015-03-27  7:25 [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance Wanpeng Li
@ 2015-03-27  7:58 ` Jason Low
  2015-03-27  7:45   ` Wanpeng Li
  2015-03-27 16:57 ` Preeti U Murthy
  1 sibling, 1 reply; 4+ messages in thread
From: Jason Low @ 2015-03-27  7:58 UTC (permalink / raw)
  To: Wanpeng Li
  Cc: Ingo Molnar, Peter Zijlstra, Srikar Dronamraju, Preeti U Murthy,
	linux-kernel, jason.low2

On Fri, 2015-03-27 at 15:25 +0800, Wanpeng Li wrote:
> As Srikar pointed out (https://lkml.org/lkml/2015/3/27/26):
> 
> | With the current code when the ilb cpus are not free: 
> | - We would be updating the nohz.next_balance even through we havent done
> |   any load balance.
> | - We might iterate thro the nohz.idle_cpus_mask()s to find balance_cpus.
> 
> This patch fix it by adding need_resched check with the idle check, and 
> keep the need_resched check in for loop to catch ilb get busy. 
> 
> Suggested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
>  kernel/sched/fair.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0576ce0..1d3e17f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7639,7 +7639,8 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
>  	int balance_cpu;
>  
>  	if (idle != CPU_IDLE ||
> -	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
> +	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)) ||
> +		need_resched())
>  		goto end;

How about having:

	if (idle != CPU_IDLE || need_resched() ||
	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))

which wouldn't require adding a new line.

Besides that:

Reviewed-by: Jason Low <jason.low2@hp.com>


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

* Re: [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance
  2015-03-27  7:25 [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance Wanpeng Li
  2015-03-27  7:58 ` Jason Low
@ 2015-03-27 16:57 ` Preeti U Murthy
  1 sibling, 0 replies; 4+ messages in thread
From: Preeti U Murthy @ 2015-03-27 16:57 UTC (permalink / raw)
  To: Wanpeng Li, Ingo Molnar, Peter Zijlstra
  Cc: Srikar Dronamraju, Jason Low, linux-kernel

Hi Wanpeng,

On 03/27/2015 12:55 PM, Wanpeng Li wrote:
> As Srikar pointed out (https://lkml.org/lkml/2015/3/27/26):
> 
> | With the current code when the ilb cpus are not free: 
> | - We would be updating the nohz.next_balance even through we havent done
> |   any load balance.
> | - We might iterate thro the nohz.idle_cpus_mask()s to find balance_cpus.
> 
> This patch fix it by adding need_resched check with the idle check, and 
> keep the need_resched check in for loop to catch ilb get busy. 
> 
> Suggested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@linux.intel.com>
> ---
>  kernel/sched/fair.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0576ce0..1d3e17f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -7639,7 +7639,8 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
>  	int balance_cpu;
> 
>  	if (idle != CPU_IDLE ||
> -	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)))
> +	    !test_bit(NOHZ_BALANCE_KICK, nohz_flags(this_cpu)) ||
> +		need_resched())
>  		goto end;
> 
>  	for_each_cpu(balance_cpu, nohz.idle_cpus_mask) {

If need_resched() becomes true between this point and the test within
the 'for' loop, you will end up with the original problem again. So the
patch does not completely solve the said problem. Besides, are we really
going to gain measurable performance with this patch?

Regards
Preeti U Murthy
> 


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

end of thread, other threads:[~2015-03-27 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-27  7:25 [PATCH] sched/fair: fix update the nohz.next_balance even if we haven't done any load balance Wanpeng Li
2015-03-27  7:58 ` Jason Low
2015-03-27  7:45   ` Wanpeng Li
2015-03-27 16:57 ` Preeti U Murthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox