summaryrefslogtreecommitdiffstats
path: root/block/blk-rq-qos.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2019-07-16 16:19:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-16 10:11:00 +0200
commitae3afb0ab0b6650644f7d0487d01d62322e4ac58 (patch)
treeeed22dc723c71e04a28b8b6323b3172f3267c769 /block/blk-rq-qos.c
parent32d1d7051c67ecd8f070c45785efab0322380db3 (diff)
downloadlinux-stable-ae3afb0ab0b6650644f7d0487d01d62322e4ac58.tar.gz
linux-stable-ae3afb0ab0b6650644f7d0487d01d62322e4ac58.tar.bz2
linux-stable-ae3afb0ab0b6650644f7d0487d01d62322e4ac58.zip
rq-qos: use a mb for got_token
[ Upstream commit ac38297f7038cd5b80d66f8809c7bbf5b70031f3 ] Oleg noticed that our checking of data.got_token is unsafe in the cleanup case, and should really use a memory barrier. Use a wmb on the write side, and a rmb() on the read side. We don't need one in the main loop since we're saved by set_current_state(). Reviewed-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block/blk-rq-qos.c')
-rw-r--r--block/blk-rq-qos.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
index e3ab75e4df9e..06d024204f50 100644
--- a/block/blk-rq-qos.c
+++ b/block/blk-rq-qos.c
@@ -202,6 +202,7 @@ static int rq_qos_wake_function(struct wait_queue_entry *curr,
return -1;
data->got_token = true;
+ smp_wmb();
list_del_init(&curr->entry);
wake_up_process(data->task);
return 1;
@@ -245,6 +246,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
do {
+ /* The memory barrier in set_task_state saves us here. */
if (data.got_token)
break;
if (!has_sleeper && acquire_inflight_cb(rqw, private_data)) {
@@ -255,6 +257,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
* which means we now have two. Put our local token
* and wake anyone else potentially waiting for one.
*/
+ smp_rmb();
if (data.got_token)
cleanup_cb(rqw, private_data);
break;