Skip to content

Commit 519252e

Browse files
vingu-linarogregkh
authored andcommitted
sched/fair: Fix NOHZ next idle balance
[ Upstream commit 3ea2f09 ] 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 <iwtbavbm@gmail.com> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Valentin Schneider <valentin.schneider@arm.com> Acked-by: Mel Gorman <mgorman@suse.de> Link: https://lkml.kernel.org/r/20200609123748.18636-1-vincent.guittot@linaro.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 40f9816 commit 519252e

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

kernel/sched/fair.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9208,7 +9208,12 @@ static void kick_ilb(unsigned int flags)
92089208
{
92099209
int ilb_cpu;
92109210

9211-
nohz.next_balance++;
9211+
/*
9212+
* Increase nohz.next_balance only when if full ilb is triggered but
9213+
* not if we only update stats.
9214+
*/
9215+
if (flags & NOHZ_BALANCE_KICK)
9216+
nohz.next_balance = jiffies+1;
92129217

92139218
ilb_cpu = find_new_ilb();
92149219

@@ -9503,6 +9508,14 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
95039508
}
95049509
}
95059510

9511+
/*
9512+
* next_balance will be updated only when there is a need.
9513+
* When the CPU is attached to null domain for ex, it will not be
9514+
* updated.
9515+
*/
9516+
if (likely(update_next_balance))
9517+
nohz.next_balance = next_balance;
9518+
95069519
/* Newly idle CPU doesn't need an update */
95079520
if (idle != CPU_NEWLY_IDLE) {
95089521
update_blocked_averages(this_cpu);
@@ -9523,14 +9536,6 @@ static bool _nohz_idle_balance(struct rq *this_rq, unsigned int flags,
95239536
if (has_blocked_load)
95249537
WRITE_ONCE(nohz.has_blocked, 1);
95259538

9526-
/*
9527-
* next_balance will be updated only when there is a need.
9528-
* When the CPU is attached to null domain for ex, it will not be
9529-
* updated.
9530-
*/
9531-
if (likely(update_next_balance))
9532-
nohz.next_balance = next_balance;
9533-
95349539
return ret;
95359540
}
95369541

0 commit comments

Comments
 (0)