Skip to content

Commit caac629

Browse files
Shrikanth HegdeIngo Molnar
authored andcommitted
sched/fair: Use helper functions to access root_domain::overload
Introduce two helper functions to access & set the root_domain::overload flag: get_rd_overload() set_rd_overload() To make sure code is always following READ_ONCE()/WRITE_ONCE() access methods. No change in functionality intended. [ mingo: Renamed the accessors to get_/set_rd_overload(), tidied up the changelog. ] Suggested-by: Qais Yousef <[email protected]> Signed-off-by: Shrikanth Hegde <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Qais Yousef <[email protected]> Reviewed-by: Vincent Guittot <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c628db0 commit caac629

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

kernel/sched/fair.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10657,8 +10657,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
1065710657

1065810658
if (!env->sd->parent) {
1065910659
/* update overload indicator if we are at root domain */
10660-
if (READ_ONCE(env->dst_rq->rd->overload) != (sg_status & SG_OVERLOAD))
10661-
WRITE_ONCE(env->dst_rq->rd->overload, sg_status & SG_OVERLOAD);
10660+
set_rd_overload(env->dst_rq->rd, sg_status & SG_OVERLOAD);
1066210661

1066310662
/* Update over-utilization (tipping point, U >= 0) indicator */
1066410663
set_rd_overutilized_status(env->dst_rq->rd,
@@ -12391,7 +12390,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
1239112390
rcu_read_lock();
1239212391
sd = rcu_dereference_check_sched_domain(this_rq->sd);
1239312392

12394-
if (!READ_ONCE(this_rq->rd->overload) ||
12393+
if (!get_rd_overload(this_rq->rd) ||
1239512394
(sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
1239612395

1239712396
if (sd)

kernel/sched/sched.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,17 @@ extern void rq_attach_root(struct rq *rq, struct root_domain *rd);
930930
extern void sched_get_rd(struct root_domain *rd);
931931
extern void sched_put_rd(struct root_domain *rd);
932932

933+
static inline int get_rd_overload(struct root_domain *rd)
934+
{
935+
return READ_ONCE(rd->overload);
936+
}
937+
938+
static inline void set_rd_overload(struct root_domain *rd, int status)
939+
{
940+
if (get_rd_overload(rd) != status)
941+
WRITE_ONCE(rd->overload, status);
942+
}
943+
933944
#ifdef HAVE_RT_PUSH_IPI
934945
extern void rto_push_irq_work_func(struct irq_work *work);
935946
#endif
@@ -2530,8 +2541,7 @@ static inline void add_nr_running(struct rq *rq, unsigned count)
25302541

25312542
#ifdef CONFIG_SMP
25322543
if (prev_nr < 2 && rq->nr_running >= 2) {
2533-
if (!READ_ONCE(rq->rd->overload))
2534-
WRITE_ONCE(rq->rd->overload, 1);
2544+
set_rd_overload(rq->rd, SG_OVERLOAD);
25352545
}
25362546
#endif
25372547

0 commit comments

Comments
 (0)