sched/fair: Fix the logic about active_balance in load_balance()
PATCH 1/1 sched/fair: Fix the logic about active_balance in load_balance()
I think the unbalance scenario here should be that we need to do active balance but it is not actually done. So fix it.
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -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 {
Signature · 1 line
2.25.1
Dietmar Eggemann
reviewerQuoted 14 lines · 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 <[email protected]>--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +0
-0
kernel/sched/fair.c static int load_balance(int this_cpu, struct rq *this_rq, · line 9716
Quoted 8 lines
kernel/sched/fair.c +1
-1@@ -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").
Hi Dietmar,
I understand, thank you for your review and very detailed explanation.
Yours,
Qi Zheng
Quoted 40 lines · Dietmar Eggemann
Quoted 14 lines · 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 <[email protected]>--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/fair.c +0
-0kernel/sched/fair.c static int load_balance(int this_cpu, struct rq *this_rq, · line 9716
Quoted 8 lines
kernel/sched/fair.c +1
-1@@ -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_intervalin 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 ofsrc_cpuis reduced compared to the one ofdst_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").