[PATCH 1/4] sched/fair: Move checking for nohz cpus after time check

Shrikanth Hegde posted 4 patches 2 hours ago
[PATCH 1/4] sched/fair: Move checking for nohz cpus after time check
Posted by Shrikanth Hegde 2 hours ago
Idle load balancer is kicked off only after time check. So move
the atomic read after the time check.

If there are no nohz CPUs there likely has_blocked should be reset
too. So stats load balancing shouldn't much difference. 

Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com> 
---
 kernel/sched/fair.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 769d7b7990df..61cc3fdfa45b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -12440,19 +12440,18 @@ static void nohz_balancer_kick(struct rq *rq)
 	 */
 	nohz_balance_exit_idle(rq);
 
-	/*
-	 * None are in tickless mode and hence no need for NOHZ idle load
-	 * balancing:
-	 */
-	if (likely(!atomic_read(&nohz.nr_cpus)))
-		return;
-
 	if (READ_ONCE(nohz.has_blocked) &&
 	    time_after(now, READ_ONCE(nohz.next_blocked)))
 		flags = NOHZ_STATS_KICK;
 
 	if (time_before(now, nohz.next_balance))
 		goto out;
+	/*
+	 * None are in tickless mode and hence no need for NOHZ idle load
+	 * balancing:
+	 */
+	if (likely(!atomic_read(&nohz.nr_cpus)))
+		return;
 
 	if (rq->nr_running >= 2) {
 		flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK;
-- 
2.43.0