Skip to content

Commit 659053d

Browse files
Shrikanth Hegdeopsiff
authored andcommitted
sched/fair: Add READ_ONCE() and use existing helper function to access ->avg_irq
mainline inclusion from mainline-v6.9-rc1 category: other Use existing helper function cpu_util_irq() instead of open-coding access to ->avg_irq. During review it was noted that ->avg_irq could be updated by a different CPU than the one which is trying to access it. ->avg_irq is updated with WRITE_ONCE(), use READ_ONCE to access it in order to avoid any compiler optimizations. Signed-off-by: Shrikanth Hegde <sshegde@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Link: https://lore.kernel.org/r/20240101154624.100981-3-sshegde@linux.vnet.ibm.com (cherry picked from commit a6965b3) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 4df6043 commit 659053d

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

kernel/sched/fair.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9509,10 +9509,8 @@ static inline bool others_have_blocked(struct rq *rq)
95099509
if (thermal_load_avg(rq))
95109510
return true;
95119511

9512-
#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
9513-
if (READ_ONCE(rq->avg_irq.util_avg))
9512+
if (cpu_util_irq(rq))
95149513
return true;
9515-
#endif
95169514

95179515
return false;
95189516
}

kernel/sched/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ static inline bool uclamp_rq_is_idle(struct rq *rq)
33883388

33893389
static inline unsigned long cpu_util_irq(struct rq *rq)
33903390
{
3391-
return rq->avg_irq.util_avg;
3391+
return READ_ONCE(rq->avg_irq.util_avg);
33923392
}
33933393

33943394
static inline

0 commit comments

Comments
 (0)