Skip to content

Commit 2ecedd7

Browse files
amlutoKAGA-KOKO
authored andcommitted
membarrier: Add an actual barrier before rseq_preempt()
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. Fixes: 70216e1 ("membarrier: Provide core serializing command, *_SYNC_CORE") Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Mathieu Desnoyers <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/d3e7197e034fa4852afcf370ca49c30496e58e40.1607058304.git.luto@kernel.org
1 parent a493d1c commit 2ecedd7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/sched/membarrier.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ static void ipi_mb(void *info)
4040

4141
static void ipi_rseq(void *info)
4242
{
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();
4351
rseq_preempt(current);
4452
}
4553

0 commit comments

Comments
 (0)