Skip to content

Commit 7c3f2ab

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/rt: Add missing rmb()
While discussing the proposed SCHED_DEADLINE patches which in parts mimic the existing FIFO code it was noticed that the wmb in rt_set_overloaded() didn't have a matching barrier. The only site using rt_overloaded() to test the rto_count is pull_rt_task() and we should issue a matching rmb before then assuming there's an rto_mask bit set. Without that smp_rmb() in there we could actually miss seeing the rto_mask bit. Also, change to using smp_[wr]mb(), even though this is SMP only code; memory barriers without smp_ always make me think they're against hardware of some sort. Signed-off-by: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Juri Lelli <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent ed1b773 commit 7c3f2ab

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/sched/rt.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ static inline void rt_set_overload(struct rq *rq)
246246
* if we should look at the mask. It would be a shame
247247
* if we looked at the mask, but the mask was not
248248
* updated yet.
249+
*
250+
* Matched by the barrier in pull_rt_task().
249251
*/
250-
wmb();
252+
smp_wmb();
251253
atomic_inc(&rq->rd->rto_count);
252254
}
253255

@@ -1626,6 +1628,12 @@ static int pull_rt_task(struct rq *this_rq)
16261628
if (likely(!rt_overloaded(this_rq)))
16271629
return 0;
16281630

1631+
/*
1632+
* Match the barrier from rt_set_overloaded; this guarantees that if we
1633+
* see overloaded we must also see the rto_mask bit.
1634+
*/
1635+
smp_rmb();
1636+
16291637
for_each_cpu(cpu, this_rq->rd->rto_mask) {
16301638
if (this_cpu == cpu)
16311639
continue;

0 commit comments

Comments
 (0)