diff options
author | Omar Sandoval <osandov@fb.com> | 2017-01-18 14:55:21 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-01-18 15:41:49 -0500 |
commit | f66227de5924ed0fde1823f5cbc4d8b8f45faaa2 (patch) | |
tree | 0de01e70f6d96b76b1b38e66a0b4bef2231b9634 /lib/sbitmap.c | |
parent | 4d199c6f1c847151ea393d5b9946a17cc57cdf6d (diff) |
sbitmap: use smp_mb__after_atomic() in sbq_wake_up()
We always do an atomic clear_bit() right before we call sbq_wake_up(),
so we can use smp_mb__after_atomic(). While we're here, comment the
memory barriers in here a little more.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'lib/sbitmap.c')
-rw-r--r-- | lib/sbitmap.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 2cecf05c82fd..df4e472df8a3 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c | |||
@@ -299,8 +299,14 @@ static void sbq_wake_up(struct sbitmap_queue *sbq) | |||
299 | struct sbq_wait_state *ws; | 299 | struct sbq_wait_state *ws; |
300 | int wait_cnt; | 300 | int wait_cnt; |
301 | 301 | ||
302 | /* Ensure that the wait list checks occur after clear_bit(). */ | 302 | /* |
303 | smp_mb(); | 303 | * Pairs with the memory barrier in set_current_state() to ensure the |
304 | * proper ordering of clear_bit()/waitqueue_active() in the waker and | ||
305 | * test_and_set_bit()/prepare_to_wait()/finish_wait() in the waiter. See | ||
306 | * the comment on waitqueue_active(). This is __after_atomic because we | ||
307 | * just did clear_bit() in the caller. | ||
308 | */ | ||
309 | smp_mb__after_atomic(); | ||
304 | 310 | ||
305 | ws = sbq_wake_ptr(sbq); | 311 | ws = sbq_wake_ptr(sbq); |
306 | if (!ws) | 312 | if (!ws) |
@@ -331,7 +337,8 @@ void sbitmap_queue_wake_all(struct sbitmap_queue *sbq) | |||
331 | int i, wake_index; | 337 | int i, wake_index; |
332 | 338 | ||
333 | /* | 339 | /* |
334 | * Make sure all changes prior to this are visible from other CPUs. | 340 | * Pairs with the memory barrier in set_current_state() like in |
341 | * sbq_wake_up(). | ||
335 | */ | 342 | */ |
336 | smp_mb(); | 343 | smp_mb(); |
337 | wake_index = atomic_read(&sbq->wake_index); | 344 | wake_index = atomic_read(&sbq->wake_index); |