History

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.

Andy Lutomirski committed 5 years ago

Commit 2ecedd71 parent a493d1c1 file · +8 −0Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/sched/membarrier.c+8−0
@@ -40,6 +40,14 @@ static void ipi_mb(void *info) · 39 unmodified lines
40 40
41static void ipi_rseq(void *info)41static 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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t