diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-05-13 13:14:51 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2014-07-08 11:13:03 -0400 |
commit | 5726ce06ad6bcd8dd75a204d1465c99a2f897d3a (patch) | |
tree | c3240a49d769fc49f0fee614f63c897ddce87f3b /Documentation | |
parent | 4a81e8328d3791a4f99bf5b436d050f6dc5ffea3 (diff) |
documentation: Clarify wake-up/memory-barrier relationship
This commit adds an example demonstrating that if a wake_up() doesn't
actually wake something up, no memory ordering is provided.
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/memory-barriers.txt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index f1dc4a215593..a6ca533a73fc 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -1893,6 +1893,21 @@ between the STORE to indicate the event and the STORE to set TASK_RUNNING: | |||
1893 | <general barrier> STORE current->state | 1893 | <general barrier> STORE current->state |
1894 | LOAD event_indicated | 1894 | LOAD event_indicated |
1895 | 1895 | ||
1896 | To repeat, this write memory barrier is present if and only if something | ||
1897 | is actually awakened. To see this, consider the following sequence of | ||
1898 | events, where X and Y are both initially zero: | ||
1899 | |||
1900 | CPU 1 CPU 2 | ||
1901 | =============================== =============================== | ||
1902 | X = 1; STORE event_indicated | ||
1903 | smp_mb(); wake_up(); | ||
1904 | Y = 1; wait_event(wq, Y == 1); | ||
1905 | wake_up(); load from Y sees 1, no memory barrier | ||
1906 | load from X might see 0 | ||
1907 | |||
1908 | In contrast, if a wakeup does occur, CPU 2's load from X would be guaranteed | ||
1909 | to see 1. | ||
1910 | |||
1896 | The available waker functions include: | 1911 | The available waker functions include: |
1897 | 1912 | ||
1898 | complete(); | 1913 | complete(); |