LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] sched/fair: Fix the logic about active_balance in load_balance()
@ 2020-08-02  4:51 Qi Zheng
  2020-08-03  7:36 ` Dietmar Eggemann
  0 siblings, 1 reply; 3+ messages in thread
From: Qi Zheng @ 2020-08-02  4:51 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman
  Cc: linux-kernel, Qi Zheng

I think the unbalance scenario here should be that we need to
do active balance but it is not actually done. So fix it.

Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2ba8f230feb9..6d8c53718b67 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9710,7 +9710,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
 	} else
 		sd->nr_balance_failed = 0;
 
-	if (likely(!active_balance) || voluntary_active_balance(&env)) {
+	if (likely(!active_balance) && voluntary_active_balance(&env)) {
 		/* We were unbalanced, so reset the balancing interval */
 		sd->balance_interval = sd->min_interval;
 	} else {
-- 
2.25.1


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

* Re: [PATCH] sched/fair: Fix the logic about active_balance in load_balance()
  2020-08-02  4:51 [PATCH] sched/fair: Fix the logic about active_balance in load_balance() Qi Zheng
@ 2020-08-03  7:36 ` Dietmar Eggemann
  2020-08-03 12:33   ` Qi Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Dietmar Eggemann @ 2020-08-03  7:36 UTC (permalink / raw)
  To: Qi Zheng, mingo, peterz, juri.lelli, vincent.guittot, rostedt,
	bsegall, mgorman
  Cc: linux-kernel

On 02/08/2020 06:51, Qi Zheng wrote:
> I think the unbalance scenario here should be that we need to
> do active balance but it is not actually done. So fix it.
> 
> Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
> ---
>  kernel/sched/fair.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 2ba8f230feb9..6d8c53718b67 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9710,7 +9710,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
>  	} else
>  		sd->nr_balance_failed = 0;
>  
> -	if (likely(!active_balance) || voluntary_active_balance(&env)) {
> +	if (likely(!active_balance) && voluntary_active_balance(&env)) {
>  		/* We were unbalanced, so reset the balancing interval */
>  		sd->balance_interval = sd->min_interval;
>  	} else {
> 

Active balance is potentially already been done when we reach this code.

See 'if (need_active_balance(&env))' and 'if (!busiest->active_balance)'
further up.

Here we only reset sd->balance_interval in case:
(A) the last load balance wasn't an active one
(B) the reason for the active load balance was:
    (1) asym packing
    (2) capacity of src_cpu is reduced compared to the one of dst_cpu
    (3) misfit handling

(B) is done to not unnecessarily increase of balance interval, see
commit 46a745d90585 ("sched/fair: Fix unnecessary increase of balance
interval").

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

* Re: [PATCH] sched/fair: Fix the logic about active_balance in load_balance()
  2020-08-03  7:36 ` Dietmar Eggemann
@ 2020-08-03 12:33   ` Qi Zheng
  0 siblings, 0 replies; 3+ messages in thread
From: Qi Zheng @ 2020-08-03 12:33 UTC (permalink / raw)
  To: Dietmar Eggemann, mingo, peterz, juri.lelli, vincent.guittot,
	rostedt, bsegall, mgorman
  Cc: linux-kernel

Hi Dietmar,

I understand, thank you for your review and very detailed explanation.

Yours,
Qi Zheng

On 2020/8/3 下午3:36, Dietmar Eggemann wrote:
> On 02/08/2020 06:51, Qi Zheng wrote:
>> I think the unbalance scenario here should be that we need to
>> do active balance but it is not actually done. So fix it.
>>
>> Signed-off-by: Qi Zheng <arch0.zheng@gmail.com>
>> ---
>>   kernel/sched/fair.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 2ba8f230feb9..6d8c53718b67 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -9710,7 +9710,7 @@ static int load_balance(int this_cpu, struct rq *this_rq,
>>   	} else
>>   		sd->nr_balance_failed = 0;
>>   
>> -	if (likely(!active_balance) || voluntary_active_balance(&env)) {
>> +	if (likely(!active_balance) && voluntary_active_balance(&env)) {
>>   		/* We were unbalanced, so reset the balancing interval */
>>   		sd->balance_interval = sd->min_interval;
>>   	} else {
>>
> 
> Active balance is potentially already been done when we reach this code.
> 
> See 'if (need_active_balance(&env))' and 'if (!busiest->active_balance)'
> further up.
> 
> Here we only reset sd->balance_interval in case:
> (A) the last load balance wasn't an active one
> (B) the reason for the active load balance was:
>      (1) asym packing
>      (2) capacity of src_cpu is reduced compared to the one of dst_cpu
>      (3) misfit handling
> 
> (B) is done to not unnecessarily increase of balance interval, see
> commit 46a745d90585 ("sched/fair: Fix unnecessary increase of balance
> interval").
> 

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-02  4:51 [PATCH] sched/fair: Fix the logic about active_balance in load_balance() Qi Zheng
2020-08-03  7:36 ` Dietmar Eggemann
2020-08-03 12:33   ` Qi Zheng

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git