public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>,
	Jens Axboe <axboe@kernel.dk>,
	linux-block <linux-block@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Subject: Re: [PATCH] block/mq-deadline: Speed up the dispatch of low-priority requests
Date: Fri, 27 Aug 2021 19:41:12 -0700	[thread overview]
Message-ID: <03d78b73-4208-2234-c85c-7ef34c799ce5@acm.org> (raw)
In-Reply-To: <b653a431-997b-0d94-2823-779f877c314f@huawei.com>

On 8/27/21 6:59 PM, Leizhen (ThunderTown) wrote:
>>> @@ -711,6 +712,8 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
>>>  
>>>  	prio = ioprio_class_to_prio[ioprio_class];
>>>  	dd_count(dd, inserted, prio);
>>> +	per_prio = &dd->per_prio[prio];
>>> +	per_prio->nr_queued++;
>>>  
>>>  	if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
>>>  		blk_mq_free_requests(&free);
>>
>> I think the above is wrong - nr_queued should not be incremented if the
>> request is merged into another request. Please move the code that increments
>> nr_queued past the above if-statement.
> 
> So dd_count(dd, inserted, prio) needs to be moved behind "if-statement" as well?

dd_insert_request() is called if a request is inserted and also if it is
requeued. dd_finish_request() is called once per request. Keeping
dd_count() before blk_mq_sched_try_insert_merge() is fine since
blk_mq_free_requests() will call dd_finish_request() indirectly if a
request is merged. However, dd_count() must only happen once per request
and must not be used if a request is requeued.

Additionally, since dd_insert_request() is called with dd->lock held and
since dd_finish_request() is called directly from inside
dd_insert_request() if a request is merged, acquiring dd->lock from
inside dd_finish_request() may trigger a deadlock. A convenient way to
trigger this code path is by running test block/015 from
https://github.com/osandov/blktests/.

Bart.

  reply	other threads:[~2021-08-28  2:41 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 14:40 [PATCH] block/mq-deadline: Speed up the dispatch of low-priority requests Zhen Lei
2021-08-26 18:09 ` Bart Van Assche
2021-08-26 18:13   ` Jens Axboe
2021-08-26 18:45     ` Jens Axboe
2021-08-26 19:17       ` Bart Van Assche
2021-08-26 19:32         ` Jens Axboe
2021-08-26 23:49       ` Bart Van Assche
2021-08-26 23:51         ` Jens Axboe
2021-08-27  0:03           ` Bart Van Assche
2021-08-27  0:05             ` Jens Axboe
2021-08-27  0:58               ` Bart Van Assche
2021-08-27  2:48               ` Bart Van Assche
2021-08-27  3:13                 ` Jens Axboe
2021-08-27  4:49                   ` Damien Le Moal
2021-08-27 14:34                     ` Bart Van Assche
2021-08-29 23:02                       ` Damien Le Moal
2021-08-30  2:31                         ` Keith Busch
2021-08-30  3:03                           ` Damien Le Moal
2021-08-30  2:40                         ` Bart Van Assche
2021-08-30  3:07                           ` Damien Le Moal
2021-08-30 17:14                             ` Bart Van Assche
2021-08-30 21:42                               ` Damien Le Moal
2021-08-28  1:45                   ` Leizhen (ThunderTown)
2021-08-28  2:19                     ` Bart Van Assche
2021-08-28  2:42                       ` Leizhen (ThunderTown)
2021-08-28 13:14                         ` Leizhen (ThunderTown)
2021-08-28  1:59   ` Leizhen (ThunderTown)
2021-08-28  2:41     ` Bart Van Assche [this message]
2021-08-27  2:30 ` Damien Le Moal
2021-08-28  2:14   ` Leizhen (ThunderTown)

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=03d78b73-4208-2234-c85c-7ef34c799ce5@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thunder.leizhen@huawei.com \
    /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