Skip to content

Commit a6965b3

Browse files
Shrikanth HegdeIngo Molnar
authored andcommitted
sched/fair: Add READ_ONCE() and use existing helper function to access ->avg_irq
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
1 parent 8b936fc commit a6965b3

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

kernel/sched/fair.c

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

9249-
#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
9250-
if (READ_ONCE(rq->avg_irq.util_avg))
9249+
if (cpu_util_irq(rq))
92519250
return true;
9252-
#endif
92539251

92549252
return false;
92559253
}

kernel/sched/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,7 @@ static inline bool uclamp_rq_is_idle(struct rq *rq)
31363136
#ifdef CONFIG_HAVE_SCHED_AVG_IRQ
31373137
static inline unsigned long cpu_util_irq(struct rq *rq)
31383138
{
3139-
return rq->avg_irq.util_avg;
3139+
return READ_ONCE(rq->avg_irq.util_avg);
31403140
}
31413141

31423142
static inline

0 commit comments

Comments
 (0)