Skip to content

Commit 6392838

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/nohz: Optimize nohz_idle_balance()
Avoid calling update_blocked_averages() when it does not in fact have any by re-using/extending update_nohz_stats(). Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 1936c53 commit 6392838

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

kernel/sched/fair.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7898,7 +7898,7 @@ group_type group_classify(struct sched_group *group,
78987898
return group_other;
78997899
}
79007900

7901-
static bool update_nohz_stats(struct rq *rq)
7901+
static bool update_nohz_stats(struct rq *rq, bool force)
79027902
{
79037903
#ifdef CONFIG_NO_HZ_COMMON
79047904
unsigned int cpu = rq->cpu;
@@ -7909,7 +7909,7 @@ static bool update_nohz_stats(struct rq *rq)
79097909
if (!cpumask_test_cpu(cpu, nohz.idle_cpus_mask))
79107910
return false;
79117911

7912-
if (!time_after(jiffies, rq->last_blocked_load_update_tick))
7912+
if (!force && !time_after(jiffies, rq->last_blocked_load_update_tick))
79137913
return true;
79147914

79157915
update_blocked_averages(cpu);
@@ -7942,7 +7942,7 @@ static inline void update_sg_lb_stats(struct lb_env *env,
79427942
for_each_cpu_and(i, sched_group_span(group), env->cpus) {
79437943
struct rq *rq = cpu_rq(i);
79447944

7945-
if ((env->flags & LBF_NOHZ_STATS) && update_nohz_stats(rq))
7945+
if ((env->flags & LBF_NOHZ_STATS) && update_nohz_stats(rq, false))
79467946
env->flags |= LBF_NOHZ_AGAIN;
79477947

79487948
/* Bias balancing toward CPUs of our domain: */
@@ -9552,8 +9552,7 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle)
95529552

95539553
rq = cpu_rq(balance_cpu);
95549554

9555-
update_blocked_averages(rq->cpu);
9556-
has_blocked_load |= rq->has_blocked_load;
9555+
has_blocked_load |= update_nohz_stats(rq, true);
95579556

95589557
/*
95599558
* If time for next balance is due,

0 commit comments

Comments
 (0)