Commit caac6291 authored by Shrikanth Hegde's avatar Shrikanth Hegde Committed by Ingo Molnar

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: default avatarQais Yousef <qyousef@layalina.io>
Signed-off-by: default avatarShrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarQais Yousef <qyousef@layalina.io>
Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20240325054505.201995-3-sshegde@linux.ibm.com
parent c628db0a
...@@ -10657,8 +10657,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd ...@@ -10657,8 +10657,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
if (!env->sd->parent) { if (!env->sd->parent) {
/* update overload indicator if we are at root domain */ /* update overload indicator if we are at root domain */
if (READ_ONCE(env->dst_rq->rd->overload) != (sg_status & SG_OVERLOAD)) set_rd_overload(env->dst_rq->rd, sg_status & SG_OVERLOAD);
WRITE_ONCE(env->dst_rq->rd->overload, sg_status & SG_OVERLOAD);
/* Update over-utilization (tipping point, U >= 0) indicator */ /* Update over-utilization (tipping point, U >= 0) indicator */
set_rd_overutilized_status(env->dst_rq->rd, 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) ...@@ -12391,7 +12390,7 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
rcu_read_lock(); rcu_read_lock();
sd = rcu_dereference_check_sched_domain(this_rq->sd); sd = rcu_dereference_check_sched_domain(this_rq->sd);
if (!READ_ONCE(this_rq->rd->overload) || if (!get_rd_overload(this_rq->rd) ||
(sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) { (sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) {
if (sd) if (sd)
......
...@@ -930,6 +930,17 @@ extern void rq_attach_root(struct rq *rq, struct root_domain *rd); ...@@ -930,6 +930,17 @@ extern void rq_attach_root(struct rq *rq, struct root_domain *rd);
extern void sched_get_rd(struct root_domain *rd); extern void sched_get_rd(struct root_domain *rd);
extern void sched_put_rd(struct root_domain *rd); extern void sched_put_rd(struct root_domain *rd);
static inline int get_rd_overload(struct root_domain *rd)
{
return READ_ONCE(rd->overload);
}
static inline void set_rd_overload(struct root_domain *rd, int status)
{
if (get_rd_overload(rd) != status)
WRITE_ONCE(rd->overload, status);
}
#ifdef HAVE_RT_PUSH_IPI #ifdef HAVE_RT_PUSH_IPI
extern void rto_push_irq_work_func(struct irq_work *work); extern void rto_push_irq_work_func(struct irq_work *work);
#endif #endif
...@@ -2530,8 +2541,7 @@ static inline void add_nr_running(struct rq *rq, unsigned count) ...@@ -2530,8 +2541,7 @@ static inline void add_nr_running(struct rq *rq, unsigned count)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
if (prev_nr < 2 && rq->nr_running >= 2) { if (prev_nr < 2 && rq->nr_running >= 2) {
if (!READ_ONCE(rq->rd->overload)) set_rd_overload(rq->rd, SG_OVERLOAD);
WRITE_ONCE(rq->rd->overload, 1);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment