It seems that most RSEQ membarrier users will expect any stores done before the membarrier() syscall to be visible to the target task(s). While this is extremely likely to be true in practice, nothing actually guarantees it by a strict reading of the x86 manuals. Rather than providing this guarantee by accident and potentially causing a problem down the road, just add an explicit barrier.
Unified · Split
| @@ -40,6 +40,14 @@ static void ipi_mb(void *info) · 39 unmodified lines | |||
| 40 | 40 | ||
| 41 | static void ipi_rseq(void *info) | 41 | static void ipi_rseq(void *info) |
| 42 | { | 42 | { |
| 43 | /* | ||
| 44 | * Ensure that all stores done by the calling thread are visible | ||
| 45 | * to the current task before the current task resumes. We could | ||
| 46 | * probably optimize this away on most architectures, but by the | ||
| 47 | * time we've already sent an IPI, the cost of the extra smp_mb() | ||
| 48 | * is negligible. | ||
| 49 | */ | ||
| 50 | smp_mb(); | ||
| 43 | rseq_preempt(current); | 51 | rseq_preempt(current); |
| 44 | } | 52 | } |
| 45 | 53 | ||