From: Paul E. McKenney Date: Tue, 13 May 2014 17:14:51 +0000 (-0700) Subject: documentation: Clarify wake-up/memory-barrier relationship X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5f36afa64035fb83db0a2dc5196396fb5c107b2b;p=karo-tx-linux.git 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 Signed-off-by: Paul E. McKenney --- 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: STORE current->state LOAD event_indicated +To repeat, this write memory barrier is present if and only if something +is actually awakened. To see this, consider the following sequence of +events, where X and Y are both initially zero: + + CPU 1 CPU 2 + =============================== =============================== + X = 1; STORE event_indicated + smp_mb(); wake_up(); + Y = 1; wait_event(wq, Y == 1); + wake_up(); load from Y sees 1, no memory barrier + load from X might see 0 + +In contrast, if a wakeup does occur, CPU 2's load from X would be guaranteed +to see 1. + The available waker functions include: complete();