From: Bart Van Assche <bvanassche@acm.org>
To: Niklas Cassel <Niklas.Cassel@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>, Jaegeuk Kim <jaegeuk@kernel.org>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Hannes Reinecke <hare@suse.de>
Subject: Re: [PATCH] mq-deadline: Fix request accounting
Date: Thu, 26 Aug 2021 19:22:38 -0700 [thread overview]
Message-ID: <18594aff-4a94-8a48-334c-f21ae32120c6@acm.org> (raw)
In-Reply-To: <YSVmEWtARsGyrEW2@x1-carbon>
On 8/24/21 2:35 PM, Niklas Cassel wrote:
> Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
> Tested-by: Niklas Cassel <niklas.cassel@wdc.com>
Hi Niklas,
Thank you for the help, that's really appreciated. Earlier today I discovered
that this patch does not handle requeuing correctly so I have started testing
the patch below.
---
block/mq-deadline.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index dbd74bae9f11..c4c3c2e3f446 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -712,7 +712,10 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
blk_req_zone_write_unlock(rq);
prio = ioprio_class_to_prio[ioprio_class];
- dd_count(dd, inserted, prio);
+ if (!rq->elv.priv[0]) {
+ dd_count(dd, inserted, prio);
+ rq->elv.priv[0] = (void *)(uintptr_t)1;
+ }
if (blk_mq_sched_try_insert_merge(q, rq, &free)) {
blk_mq_free_requests(&free);
@@ -761,12 +764,10 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx,
spin_unlock(&dd->lock);
}
-/*
- * Nothing to do here. This is defined only to ensure that .finish_request
- * method is called upon request completion.
- */
+/* Callback from inside blk_mq_rq_ctx_init(). */
static void dd_prepare_request(struct request *rq)
{
+ rq->elv.priv[0] = NULL;
}
/*
@@ -793,6 +794,14 @@ static void dd_finish_request(struct request *rq)
const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
struct dd_per_prio *per_prio = &dd->per_prio[prio];
+ /*
+ * The block layer core may call dd_finish_request() without having
+ * called dd_insert_requests(). Skip requests that bypassed I/O
+ * scheduling. See also blk_mq_request_bypass_insert().
+ */
+ if (!rq->elv.priv[0])
+ return;
+
dd_count(dd, completed, prio);
if (blk_queue_is_zoned(q)) {
next prev parent reply other threads:[~2021-08-27 2:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 17:05 [PATCH] mq-deadline: Fix request accounting Bart Van Assche
2021-08-24 17:09 ` Jens Axboe
2021-08-24 17:13 ` Bart Van Assche
2021-08-24 17:18 ` Jens Axboe
2021-08-24 21:35 ` Niklas Cassel
2021-08-27 2:22 ` Bart Van Assche [this message]
2021-08-27 9:20 ` Niklas Cassel
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=18594aff-4a94-8a48-334c-f21ae32120c6@acm.org \
--to=bvanassche@acm.org \
--cc=Damien.LeMoal@wdc.com \
--cc=Niklas.Cassel@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-block@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).