LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Niklas Cassel <Niklas.Cassel@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Bart Van Assche <bvanassche@acm.org>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Paolo Valente <paolo.valente@linaro.org>,
Ming Lei <ming.lei@redhat.com>,
Niklas Cassel <Niklas.Cassel@wdc.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] blk-mq: don't call callbacks for requests that bypassed the scheduler
Date: Tue, 7 Sep 2021 14:21:55 +0000 [thread overview]
Message-ID: <20210907142145.112096-2-Niklas.Cassel@wdc.com> (raw)
In-Reply-To: <20210907142145.112096-1-Niklas.Cassel@wdc.com>
From: Niklas Cassel <niklas.cassel@wdc.com>
Currently, __blk_mq_alloc_request() (via blk_mq_rq_ctx_init()) calls the
I/O scheduler callback e->type->ops.prepare_request(), which will set
RQF_ELVPRIV, even though passthrough (and flush) requests will later
bypass the I/O scheduler in blk_mq_submit_bio().
Later, blk_mq_free_request() checks if the RQF_ELVPRIV flag is set,
if it is, the e->type->ops.finish_request() I/O scheduler callback
will be called.
i.e., the prepare_request and finish_request I/O scheduler callbacks
will be called for requests which were never inserted to the I/O
scheduler.
Fix this by not calling e->type->ops.prepare_request(), nor setting
the RQF_ELVPRIV flag for passthrough requests.
Since the RQF_ELVPRIV flag will not get set for passthrough requests,
e->type->ops.prepare_request() will no longer get called for
passthrough requests which were never inserted to the I/O scheduler.
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
block/blk-mq.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 65d3a63aecc6..0816af125059 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -328,7 +328,12 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
data->ctx->rq_dispatched[op_is_sync(data->cmd_flags)]++;
refcount_set(&rq->ref, 1);
- if (!op_is_flush(data->cmd_flags)) {
+ /*
+ * Flush/passthrough requests are special and go directly to the
+ * dispatch list, bypassing the scheduler.
+ */
+ if (!op_is_flush(data->cmd_flags) &&
+ !blk_op_is_passthrough(data->cmd_flags)) {
struct elevator_queue *e = data->q->elevator;
rq->elv.icq = NULL;
--
2.31.1
next prev parent reply other threads:[~2021-09-07 14:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 14:21 [PATCH 0/2] don't call io scheduler callbacks for passthrough requests Niklas Cassel
2021-09-07 14:21 ` Niklas Cassel [this message]
2021-09-07 14:29 ` [PATCH 1/2] blk-mq: don't call callbacks for requests that bypassed the scheduler Ming Lei
2021-09-07 14:21 ` [PATCH 2/2] Revert "mq-deadline: Fix request accounting" Niklas Cassel
2021-09-07 14:54 ` Bart Van Assche
2021-09-07 16:07 ` Niklas Cassel
2021-09-07 16:49 ` Bart Van Assche
2021-09-07 15:15 ` Bart Van Assche
2021-09-07 16:28 ` Niklas Cassel
2021-09-07 17:12 ` Bart Van Assche
2021-09-08 11:57 ` 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=20210907142145.112096-2-Niklas.Cassel@wdc.com \
--to=niklas.cassel@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=paolo.valente@linaro.org \
--subject='Re: [PATCH 1/2] blk-mq: don'\''t call callbacks for requests that bypassed the scheduler' \
/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
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).