Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <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

authored by

Shrikanth Hegde and committed by
Ingo Molnar
caac6291 c628db0a

+14 -5
+2 -3
kernel/sched/fair.c
··· 10657 10657 10658 10658 if (!env->sd->parent) { 10659 10659 /* 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); 10662 10661 10663 10662 /* Update over-utilization (tipping point, U >= 0) indicator */ 10664 10663 set_rd_overutilized_status(env->dst_rq->rd, ··· 12390 12391 rcu_read_lock(); 12391 12392 sd = rcu_dereference_check_sched_domain(this_rq->sd); 12392 12393 12393 - if (!READ_ONCE(this_rq->rd->overload) || 12394 + if (!get_rd_overload(this_rq->rd) || 12394 12395 (sd && this_rq->avg_idle < sd->max_newidle_lb_cost)) { 12395 12396 12396 12397 if (sd)
+12 -2
kernel/sched/sched.h
··· 930 930 extern void sched_get_rd(struct root_domain *rd); 931 931 extern void sched_put_rd(struct root_domain *rd); 932 932 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 + 933 944 #ifdef HAVE_RT_PUSH_IPI 934 945 extern void rto_push_irq_work_func(struct irq_work *work); 935 946 #endif ··· 2541 2530 2542 2531 #ifdef CONFIG_SMP 2543 2532 if (prev_nr < 2 && rq->nr_running >= 2) { 2544 - if (!READ_ONCE(rq->rd->overload)) 2545 - WRITE_ONCE(rq->rd->overload, 1); 2533 + set_rd_overload(rq->rd, SG_OVERLOAD); 2546 2534 } 2547 2535 #endif 2548 2536