提交 f42073ee 编写于 作者: J Josef Bacik 提交者: Xie XiuQi

rq-qos: fix missed wake-ups in rq_qos_throttle

mainline inclusion
from mainline-5.3-rc2
commit 545fbd0775bafcefc8f7bc844291bd13c44b7fdc
category: bugfix
bugzilla: 21211
CVE: NA

---------------------------

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: NOleg Nesterov <oleg@redhat.com>
Signed-off-by: NJosef Bacik <josef@toxicpanda.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>

Conflicts:
	block/blk-rq-qos.c

[yan: __wbt_wait() has not been turned into rq_qos_wait() yet.]
Signed-off-by: NJason Yan <yanaijie@huawei.com>
Reviewed-by: NYufen Yu <yuyufen@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 6853dd80
...@@ -543,6 +543,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct, ...@@ -543,6 +543,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
return; return;
prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE); prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
has_sleeper = !wq_has_single_sleeper(&rqw->wait);
do { do {
if (data.got_token) if (data.got_token)
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册