aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/futex.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2016-02-09 14:15:13 -0500
committerIngo Molnar <mingo@kernel.org>2016-02-17 04:42:17 -0500
commit8ad7b378d0d016309014cae0f640434bca7b5e11 (patch)
treed09f50e75566b76d8595c37f9625cc4d7a45a98f /kernel/futex.c
parente2d6f8a5f596b1f09839990b11a3c2e0c9f0dbc2 (diff)
futex: Rename barrier references in ordering guarantees
Ingo suggested we rename how we reference barriers A and B regarding futex ordering guarantees. This patch replaces, for both barriers, MB (A) with smp_mb(); (A), such that: - We explicitly state that the barriers are SMP, and - We standardize how we reference these across futex.c helping readers follow what barrier does what and where. Suggested-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Chris Mason <clm@fb.com> Cc: Darren Hart <dvhart@linux.intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: dave@stgolabs.net Link: http://lkml.kernel.org/r/1455045314-8305-2-git-send-email-dave@stgolabs.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/futex.c')
-rw-r--r--kernel/futex.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index 5d6ce6413ef1..08ac7009488b 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -124,16 +124,16 @@
124 * futex_wait(futex, val); 124 * futex_wait(futex, val);
125 * 125 *
126 * waiters++; (a) 126 * waiters++; (a)
127 * mb(); (A) <-- paired with -. 127 * smp_mb(); (A) <-- paired with -.
128 * | 128 * |
129 * lock(hash_bucket(futex)); | 129 * lock(hash_bucket(futex)); |
130 * | 130 * |
131 * uval = *futex; | 131 * uval = *futex; |
132 * | *futex = newval; 132 * | *futex = newval;
133 * | sys_futex(WAKE, futex); 133 * | sys_futex(WAKE, futex);
134 * | futex_wake(futex); 134 * | futex_wake(futex);
135 * | 135 * |
136 * `-------> mb(); (B) 136 * `--------> smp_mb(); (B)
137 * if (uval == val) 137 * if (uval == val)
138 * queue(); 138 * queue();
139 * unlock(hash_bucket(futex)); 139 * unlock(hash_bucket(futex));
@@ -334,7 +334,7 @@ static inline void futex_get_mm(union futex_key *key)
334 /* 334 /*
335 * Ensure futex_get_mm() implies a full barrier such that 335 * Ensure futex_get_mm() implies a full barrier such that
336 * get_futex_key() implies a full barrier. This is relied upon 336 * get_futex_key() implies a full barrier. This is relied upon
337 * as full barrier (B), see the ordering comment above. 337 * as smp_mb(); (B), see the ordering comment above.
338 */ 338 */
339 smp_mb__after_atomic(); 339 smp_mb__after_atomic();
340} 340}
@@ -407,10 +407,10 @@ static void get_futex_key_refs(union futex_key *key)
407 407
408 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) { 408 switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
409 case FUT_OFF_INODE: 409 case FUT_OFF_INODE:
410 ihold(key->shared.inode); /* implies MB (B) */ 410 ihold(key->shared.inode); /* implies smp_mb(); (B) */
411 break; 411 break;
412 case FUT_OFF_MMSHARED: 412 case FUT_OFF_MMSHARED:
413 futex_get_mm(key); /* implies MB (B) */ 413 futex_get_mm(key); /* implies smp_mb(); (B) */
414 break; 414 break;
415 default: 415 default:
416 /* 416 /*
@@ -418,7 +418,7 @@ static void get_futex_key_refs(union futex_key *key)
418 * mm, therefore the only purpose of calling get_futex_key_refs 418 * mm, therefore the only purpose of calling get_futex_key_refs
419 * is because we need the barrier for the lockless waiter check. 419 * is because we need the barrier for the lockless waiter check.
420 */ 420 */
421 smp_mb(); /* explicit MB (B) */ 421 smp_mb(); /* explicit smp_mb(); (B) */
422 } 422 }
423} 423}
424 424
@@ -497,7 +497,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
497 if (!fshared) { 497 if (!fshared) {
498 key->private.mm = mm; 498 key->private.mm = mm;
499 key->private.address = address; 499 key->private.address = address;
500 get_futex_key_refs(key); /* implies MB (B) */ 500 get_futex_key_refs(key); /* implies smp_mb(); (B) */
501 return 0; 501 return 0;
502 } 502 }
503 503
@@ -572,7 +572,7 @@ again:
572 key->shared.pgoff = basepage_index(page); 572 key->shared.pgoff = basepage_index(page);
573 } 573 }
574 574
575 get_futex_key_refs(key); /* implies MB (B) */ 575 get_futex_key_refs(key); /* implies smp_mb(); (B) */
576 576
577out: 577out:
578 unlock_page(page); 578 unlock_page(page);
@@ -1864,7 +1864,7 @@ static inline struct futex_hash_bucket *queue_lock(struct futex_q *q)
1864 1864
1865 q->lock_ptr = &hb->lock; 1865 q->lock_ptr = &hb->lock;
1866 1866
1867 spin_lock(&hb->lock); /* implies MB (A) */ 1867 spin_lock(&hb->lock); /* implies smp_mb(); (A) */
1868 return hb; 1868 return hb;
1869} 1869}
1870 1870