]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched/fair: Use helper functions to access root_domain::overload
authorShrikanth Hegde <sshegde@linux.ibm.com>
Mon, 25 Mar 2024 05:45:05 +0000 (11:15 +0530)
committerIngo Molnar <mingo@kernel.org>
Thu, 28 Mar 2024 10:30:13 +0000 (11:30 +0100)
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 <qyousef@layalina.io>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Qais Yousef <qyousef@layalina.io>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20240325054505.201995-3-sshegde@linux.ibm.com
kernel/sched/fair.c
kernel/sched/sched.h

index 600fdde1e7acef81a75c94ddc608e514007db576..0cc0582653086734dcfebf1a6354ecbd4c72e6ff 100644 (file)
@@ -10657,8 +10657,7 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd
 
        if (!env->sd->parent) {
                /* update overload indicator if we are at root domain */
-               if (READ_ONCE(env->dst_rq->rd->overload) != (sg_status & SG_OVERLOAD))
-                       WRITE_ONCE(env->dst_rq->rd->overload, sg_status & SG_OVERLOAD);
+               set_rd_overload(env->dst_rq->rd, sg_status & SG_OVERLOAD);
 
                /* Update over-utilization (tipping point, U >= 0) indicator */
                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)
        rcu_read_lock();
        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)) {
 
                if (sd)
index 4f9e952d4fad00031fd942d8a95f193084027e6f..e86ee262d2f33eef76ebc68706cf31b80b5d2cd5 100644 (file)
@@ -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_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
 extern void rto_push_irq_work_func(struct irq_work *work);
 #endif
@@ -2530,8 +2541,7 @@ static inline void add_nr_running(struct rq *rq, unsigned count)
 
 #ifdef CONFIG_SMP
        if (prev_nr < 2 && rq->nr_running >= 2) {
-               if (!READ_ONCE(rq->rd->overload))
-                       WRITE_ONCE(rq->rd->overload, 1);
+               set_rd_overload(rq->rd, SG_OVERLOAD);
        }
 #endif