[PATCH 3.12 040/175] sched/rt: Add missing rmb()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit 7c3f2ab7b844f1a859afbc3d41925e8a0faba5fa upstream.

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 <peterz@xxxxxxxxxxxxx>
Cc: vincent.guittot@xxxxxxxxxx
Cc: luca.abeni@xxxxxxxx
Cc: bruce.ashfield@xxxxxxxxxxxxx
Cc: dhaval.giani@xxxxxxxxx
Cc: rostedt@xxxxxxxxxxx
Cc: hgu1972@xxxxxxxxx
Cc: oleg@xxxxxxxxxx
Cc: fweisbec@xxxxxxxxx
Cc: darren@xxxxxxxxxx
Cc: johan.eker@xxxxxxxxxxxx
Cc: p.faure@xxxxxxxxxx
Cc: paulmck@xxxxxxxxxxxxxxxxxx
Cc: raistlin@xxxxxxxx
Cc: claudio@xxxxxxxxxxxxxxx
Cc: insop.song@xxxxxxxxx
Cc: michael@xxxxxxxxxxxxxxxxxxxx
Cc: liming.wang@xxxxxxxxxxxxx
Cc: fchecconi@xxxxxxxxx
Cc: jkacur@xxxxxxxxxx
Cc: tommaso.cucinotta@xxxxxxxx
Cc: Juri Lelli <juri.lelli@xxxxxxxxx>
Cc: harald.gustafsson@xxxxxxxxxxxx
Cc: nicola.manica@xxxxxxxxxxxxx
Cc: tglx@xxxxxxxxxxxxx
Link: http://lkml.kernel.org/r/20131015103507.GF10651@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
 kernel/sched/rt.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 417b1b3fd7e9..0c7886ff263e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -246,8 +246,10 @@ static inline void rt_set_overload(struct rq *rq)
 	 * if we should look at the mask. It would be a shame
 	 * if we looked at the mask, but the mask was not
 	 * updated yet.
+	 *
+	 * Matched by the barrier in pull_rt_task().
 	 */
-	wmb();
+	smp_wmb();
 	atomic_inc(&rq->rd->rto_count);
 }
 
@@ -1644,6 +1646,12 @@ static int pull_rt_task(struct rq *this_rq)
 	if (likely(!rt_overloaded(this_rq)))
 		return 0;
 
+	/*
+	 * Match the barrier from rt_set_overloaded; this guarantees that if we
+	 * see overloaded we must also see the rto_mask bit.
+	 */
+	smp_rmb();
+
 	for_each_cpu(cpu, this_rq->rd->rto_mask) {
 		if (this_cpu == cpu)
 			continue;
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]