Skip to content

Commit b0c7922

Browse files
Valentin SchneiderIngo Molnar
authored andcommitted
sched/fair: Clean up definition of NOHZ blocked load functions
cfs_rq_has_blocked() and others_have_blocked() are only used within update_blocked_averages(). The !CONFIG_FAIR_GROUP_SCHED version of the latter calls them within a #define CONFIG_NO_HZ_COMMON block, whereas the CONFIG_FAIR_GROUP_SCHED one calls them unconditionnally. As reported by Qian, the above leads to this warning in !CONFIG_NO_HZ_COMMON configs: kernel/sched/fair.c: In function 'update_blocked_averages': kernel/sched/fair.c:7750:7: warning: variable 'done' set but not used [-Wunused-but-set-variable] It wouldn't be wrong to keep cfs_rq_has_blocked() and others_have_blocked() as they are, but since their only current use is to figure out when we can stop calling update_blocked_averages() on fully decayed NOHZ idle CPUs, we can give them a new definition for !CONFIG_NO_HZ_COMMON. Change the definition of cfs_rq_has_blocked() and others_have_blocked() for !CONFIG_NO_HZ_COMMON so that the NOHZ-specific blocks of update_blocked_averages() become no-ops and the 'done' variable gets optimised out. While at it, remove the CONFIG_NO_HZ_COMMON block from the !CONFIG_FAIR_GROUP_SCHED definition of update_blocked_averages() by using the newly-introduced update_blocked_load_status() helper. No change in functionality intended. [ Additions by Peter Zijlstra. ] Reported-by: Qian Cai <[email protected]> Signed-off-by: Valentin Schneider <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Vincent Guittot <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent e3b929b commit b0c7922

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

kernel/sched/fair.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7393,6 +7393,7 @@ static void attach_tasks(struct lb_env *env)
73937393
rq_unlock(env->dst_rq, &rf);
73947394
}
73957395

7396+
#ifdef CONFIG_NO_HZ_COMMON
73967397
static inline bool cfs_rq_has_blocked(struct cfs_rq *cfs_rq)
73977398
{
73987399
if (cfs_rq->avg.load_avg)
@@ -7420,6 +7421,19 @@ static inline bool others_have_blocked(struct rq *rq)
74207421
return false;
74217422
}
74227423

7424+
static inline void update_blocked_load_status(struct rq *rq, bool has_blocked)
7425+
{
7426+
rq->last_blocked_load_update_tick = jiffies;
7427+
7428+
if (!has_blocked)
7429+
rq->has_blocked_load = 0;
7430+
}
7431+
#else
7432+
static inline bool cfs_rq_has_blocked(struct cfs_rq *cfs_rq) { return false; }
7433+
static inline bool others_have_blocked(struct rq *rq) { return false; }
7434+
static inline void update_blocked_load_status(struct rq *rq, bool has_blocked) {}
7435+
#endif
7436+
74237437
#ifdef CONFIG_FAIR_GROUP_SCHED
74247438

74257439
static inline bool cfs_rq_is_decayed(struct cfs_rq *cfs_rq)
@@ -7485,11 +7499,7 @@ static void update_blocked_averages(int cpu)
74857499
if (others_have_blocked(rq))
74867500
done = false;
74877501

7488-
#ifdef CONFIG_NO_HZ_COMMON
7489-
rq->last_blocked_load_update_tick = jiffies;
7490-
if (done)
7491-
rq->has_blocked_load = 0;
7492-
#endif
7502+
update_blocked_load_status(rq, !done);
74937503
rq_unlock_irqrestore(rq, &rf);
74947504
}
74957505

@@ -7555,11 +7565,7 @@ static inline void update_blocked_averages(int cpu)
75557565
update_rt_rq_load_avg(rq_clock_pelt(rq), rq, curr_class == &rt_sched_class);
75567566
update_dl_rq_load_avg(rq_clock_pelt(rq), rq, curr_class == &dl_sched_class);
75577567
update_irq_load_avg(rq, 0);
7558-
#ifdef CONFIG_NO_HZ_COMMON
7559-
rq->last_blocked_load_update_tick = jiffies;
7560-
if (!cfs_rq_has_blocked(cfs_rq) && !others_have_blocked(rq))
7561-
rq->has_blocked_load = 0;
7562-
#endif
7568+
update_blocked_load_status(rq, cfs_rq_has_blocked(cfs_rq) || others_have_blocked(rq));
75637569
rq_unlock_irqrestore(rq, &rf);
75647570
}
75657571

0 commit comments

Comments
 (0)