[PATCH 3/3] sched: Rate limit load balance in newidle_balance()

From: Tim Chen
Date: Fri May 07 2021 - 17:54:54 EST


Currently newidle_balance() could do load balancng even if the cpu is not
due for a load balance. Make newidle_balance() check the next_balance
time on the cpu's runqueue so it defers load balancing if it is not
due for its load balance.

Signed-off-by: Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>
---
kernel/sched/fair.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f828b75488a0..8e00e1fdd6e0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10617,6 +10617,7 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf)

if (this_rq->avg_idle < sysctl_sched_migration_cost ||
!READ_ONCE(this_rq->rd->overload) ||
+ time_before(jiffies, this_rq->next_balance) ||
(sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {

if (sd)
--
2.20.1