From: Junxiao Bi <junxiao.bi@oracle.com>
To: Hillf Danton <hdanton@sina.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
axboe@kernel.dk
Subject: Re: [PATCH] block: fix io hung by block throttle
Date: Sat, 17 Apr 2021 14:37:57 -0700 [thread overview]
Message-ID: <0f3ffdbe-b893-7ef1-de69-188146b977c2@oracle.com> (raw)
In-Reply-To: <20210417101008.4132-1-hdanton@sina.com>
On 4/17/21 3:10 AM, Hillf Danton wrote:
>> --- a/block/blk-rq-qos.c
>> +++ b/block/blk-rq-qos.c
>> @@ -260,19 +260,17 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
>> .cb = acquire_inflight_cb,
>> .private_data = private_data,
>> };
>> - bool has_sleeper;
>>
>> - has_sleeper = wq_has_sleeper(&rqw->wait);
>> - if (!has_sleeper && acquire_inflight_cb(rqw, private_data))
>> + if (!wq_has_sleeper(&rqw->wait)
>> + && acquire_inflight_cb(rqw, private_data))
>> return;
>>
>> prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
>> - has_sleeper = !wq_has_single_sleeper(&rqw->wait);
>> 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)) {
>> + if (acquire_inflight_cb(rqw, private_data)) {
>> finish_wait(&rqw->wait, &data.wq);
> Simply removing !has_sleeper is not enough if it is mandatory before
> acquire_inflight_cb() without adding something like a mutex to sieve the
> concurrent sleepers out, see below.
>
>
> --- a/block/blk-rq-qos.c
> +++ b/block/blk-rq-qos.c
> @@ -260,19 +260,18 @@ void rq_qos_wait(struct rq_wait *rqw, vo
> .cb = acquire_inflight_cb,
> .private_data = private_data,
> };
> - bool has_sleeper;
>
> - has_sleeper = wq_has_sleeper(&rqw->wait);
> - if (!has_sleeper && acquire_inflight_cb(rqw, private_data))
> - return;
> + mutex_lock(&rqw->mutex);
> +
> + if (acquire_inflight_cb(rqw, private_data))
This function is to increase atomic variable rq_wait->inflight. What's
the mutex for?
Thanks,
Junxiao.
> + goto out;
>
> prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE);
> - has_sleeper = !wq_has_single_sleeper(&rqw->wait);
> 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)) {
> + if (acquire_inflight_cb(rqw, private_data)) {
> finish_wait(&rqw->wait, &data.wq);
>
> /*
> @@ -286,10 +285,11 @@ void rq_qos_wait(struct rq_wait *rqw, vo
> break;
> }
> io_schedule();
> - has_sleeper = true;
> set_current_state(TASK_UNINTERRUPTIBLE);
> } while (1);
> finish_wait(&rqw->wait, &data.wq);
> +out:
> + mutex_unlock(&rqw->mutex);
> }
next prev parent reply other threads:[~2021-04-17 21:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 21:18 [PATCH] block: fix io hung by block throttle Junxiao Bi
[not found] ` <20210417101008.4132-1-hdanton@sina.com>
2021-04-17 21:37 ` Junxiao Bi [this message]
[not found] ` <20210418123342.13740-1-hdanton@sina.com>
2021-04-19 6:09 ` Junxiao Bi
2021-04-19 16:39 ` Junxiao Bi
[not found] ` <20210415041153.577-1-hdanton@sina.com>
2021-04-15 5:01 ` Junxiao Bi
2021-04-21 21:28 ` Junxiao Bi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f3ffdbe-b893-7ef1-de69-188146b977c2@oracle.com \
--to=junxiao.bi@oracle.com \
--cc=axboe@kernel.dk \
--cc=hdanton@sina.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).