aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/memory-barriers.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/memory-barriers.txt')
-rw-r--r--Documentation/memory-barriers.txt27
1 files changed, 23 insertions, 4 deletions
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index f1dc4a215593..a4de88fb55f0 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -757,10 +757,14 @@ SMP BARRIER PAIRING
757When dealing with CPU-CPU interactions, certain types of memory barrier should 757When dealing with CPU-CPU interactions, certain types of memory barrier should
758always be paired. A lack of appropriate pairing is almost certainly an error. 758always be paired. A lack of appropriate pairing is almost certainly an error.
759 759
760A write barrier should always be paired with a data dependency barrier or read 760General barriers pair with each other, though they also pair with
761barrier, though a general barrier would also be viable. Similarly a read 761most other types of barriers, albeit without transitivity. An acquire
762barrier or a data dependency barrier should always be paired with at least an 762barrier pairs with a release barrier, but both may also pair with other
763write barrier, though, again, a general barrier is viable: 763barriers, including of course general barriers. A write barrier pairs
764with a data dependency barrier, an acquire barrier, a release barrier,
765a read barrier, or a general barrier. Similarly a read barrier or a
766data dependency barrier pairs with a write barrier, an acquire barrier,
767a release barrier, or a general barrier:
764 768
765 CPU 1 CPU 2 769 CPU 1 CPU 2
766 =============== =============== 770 =============== ===============
@@ -1893,6 +1897,21 @@ between the STORE to indicate the event and the STORE to set TASK_RUNNING:
1893 <general barrier> STORE current->state 1897 <general barrier> STORE current->state
1894 LOAD event_indicated 1898 LOAD event_indicated
1895 1899
1900To repeat, this write memory barrier is present if and only if something
1901is actually awakened. To see this, consider the following sequence of
1902events, where X and Y are both initially zero:
1903
1904 CPU 1 CPU 2
1905 =============================== ===============================
1906 X = 1; STORE event_indicated
1907 smp_mb(); wake_up();
1908 Y = 1; wait_event(wq, Y == 1);
1909 wake_up(); load from Y sees 1, no memory barrier
1910 load from X might see 0
1911
1912In contrast, if a wakeup does occur, CPU 2's load from X would be guaranteed
1913to see 1.
1914
1896The available waker functions include: 1915The available waker functions include:
1897 1916
1898 complete(); 1917 complete();