Skip to content

Commit 3ea2f09

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Fix NOHZ next idle balance
With commit: 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")' rebalance_domains of the local cfs_rq happens before others idle cpus have updated nohz.next_balance and its value is overwritten. Move the update of nohz.next_balance for other idles cpus before balancing and updating the next_balance of local cfs_rq. Also, the nohz.next_balance is now updated only if all idle cpus got a chance to rebalance their domains and the idle balance has not been aborted because of new activities on the CPU. In case of need_resched, the idle load balance will be kick the next jiffie in order to address remaining ilb. Fixes: b7031a0 ("sched/fair: Add NOHZ_STATS_KICK") Reported-by: Peng Liu <[email protected]> Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Acked-by: Mel Gorman <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent b4098bf commit 3ea2f09

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

kernel/sched/fair.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10022,7 +10022,12 @@ static void kick_ilb(unsigned int flags)
1002210022
{
1002310023
int ilb_cpu;
1002410024

10025-
nohz.next_balance++;
10025+
/*
10026+
* Increase nohz.next_balance only when if full ilb is triggered but
10027+
* not if we only update stats.
10028+
*/
10029+
if (flags & NOHZ_BALANCE_KICK)
10030+
nohz.next_balance = jiffies+1;
1002610031

1002710032
ilb_cpu = find_new_ilb();
1002810033

@@ -10343,6 +10348,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
1034310348
}
1034410349
}
1034510350

10351+
/*
10352+
* next_balance will be updated only when there is a need.
10353+
* When the CPU is attached to null domain for ex, it will not be
10354+
* updated.
10355+
*/
10356+
if (likely(update_next_balance))
10357+
nohz.next_balance = next_balance;
10358+
1034610359
/* Newly idle CPU doesn't need an update */
1034710360
if (idle != CPU_NEWLY_IDLE) {
1034810361
update_blocked_averages(this_cpu);
@@ -10363,14 +10376,6 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
1036310376
if (has_blocked_load)
1036410377
WRITE_ONCE(nohz.has_blocked, 1);
1036510378

10366-
/*
10367-
* next_balance will be updated only when there is a need.
10368-
* When the CPU is attached to null domain for ex, it will not be
10369-
* updated.
10370-
*/
10371-
if (likely(update_next_balance))
10372-
nohz.next_balance = next_balance;
10373-
1037410379
return ret;
1037510380
}
1037610381

0 commit comments

Comments
 (0)