Skip to content

Commit

Permalink
rq-qos: fix missed wake-ups in rq_qos_throttle
Browse files Browse the repository at this point in the history
We saw a hang in production with WBT where there was only one waiter in
the throttle path and no outstanding IO.  This is because of the
has_sleepers optimization that is used to make sure we don't steal an
inflight counter for new submitters when there are people already on the
list.

We can race with our check to see if the waitqueue has any waiters (this
is done locklessly) and the time we actually add ourselves to the
waitqueue.  If this happens we'll go to sleep and never be woken up
because nobody is doing IO to wake us up.

Fix this by checking if the waitqueue has a single sleeper on the list
after we add ourselves, that way we have an uptodate view of the list.

Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Josef Bacik authored and Jens Axboe committed Jul 18, 2019
1 parent a6d81d3 commit 545fbd0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions block/blk-rq-qos.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
return;

prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
has_sleeper = !wq_has_single_sleeper(&rqw->wait);
do {
if (data.got_token)
break;
Expand Down

0 comments on commit 545fbd0

Please sign in to comment.