From: Christoph Hellwig <hch@infradead.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 07/14] block: change plugging to use a singly linked list
Date: Mon, 18 Oct 2021 02:19:12 -0700 [thread overview]
Message-ID: <YW08EPYhH73m7nUj@infradead.org> (raw)
In-Reply-To: <20211017013748.76461-8-axboe@kernel.dk>
On Sat, Oct 16, 2021 at 07:37:41PM -0600, Jens Axboe wrote:
> Use a singly linked list for the blk_plug. This saves 8 bytes in the
> blk_plug struct, and makes for faster list manipulations than doubly
> linked lists. As we don't use the doubly linked lists for anything,
> singly linked is just fine.
This patch also does a few other thing, like changing the same_queue_rq
type and adding a has_elevator flag to the plug. Can you please split
this out and document the changes better?
>static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
> {
> + struct blk_mq_hw_ctx *hctx = NULL;
> + int queued = 0;
> + int errors = 0;
> +
> + while (!rq_list_empty(plug->mq_list)) {
> + struct request *rq;
> + blk_status_t ret;
> +
> + rq = rq_list_pop(&plug->mq_list);
>
> + if (!hctx)
> + hctx = rq->mq_hctx;
> + else if (hctx != rq->mq_hctx && hctx->queue->mq_ops->commit_rqs) {
> + trace_block_unplug(hctx->queue, queued, !from_schedule);
> + hctx->queue->mq_ops->commit_rqs(hctx);
> + queued = 0;
> + hctx = rq->mq_hctx;
> + }
> +
> + ret = blk_mq_request_issue_directly(rq,
> + rq_list_empty(plug->mq_list));
> + if (ret != BLK_STS_OK) {
> + if (ret == BLK_STS_RESOURCE ||
> + ret == BLK_STS_DEV_RESOURCE) {
> + blk_mq_request_bypass_insert(rq, false,
> + rq_list_empty(plug->mq_list));
> + break;
> + }
> + blk_mq_end_request(rq, ret);
> + errors++;
> + } else
> + queued++;
> + }
This all looks a bit messy to me. I'd suggest reordering this a bit
including a new helper:
static void blk_mq_commit_rqs(struct blk_mq_hw_ctx *hctx, int *queued,
bool from_schedule)
{
if (hctx->queue->mq_ops->commit_rqs) {
trace_block_unplug(hctx->queue, *queued, !from_schedule);
hctx->queue->mq_ops->commit_rqs(hctx);
}
*queued = 0;
}
static void blk_mq_plug_issue_direct(struct blk_plug *plug, bool from_schedule)
{
struct blk_mq_hw_ctx *hctx = NULL;
int queued = 0;
int errors = 0;
while ((rq = rq_list_pop(&plug->mq_list))) {
bool last = rq_list_empty(plug->mq_list);
blk_status_t ret;
if (hctx != rq->mq_hctx) {
if (hctx)
blk_mq_commit_rqs(hctx, &queued, from_schedule);
hctx = rq->mq_hctx;
}
ret = blk_mq_request_issue_directly(rq, last);
switch (ret) {
case BLK_STS_OK:
queued++;
break;
case BLK_STS_RESOURCE:
case BLK_STS_DEV_RESOURCE:
blk_mq_request_bypass_insert(rq, false, last);
blk_mq_commit_rqs(hctx, &queued, from_schedule);
return;
default:
blk_mq_end_request(rq, ret);
errors++;
break;
}
}
/*
* If we didn't flush the entire list, we could have told the driver
* there was more coming, but that turned out to be a lie.
*/
if (errors)
blk_mq_commit_rqs(hctx, &queued, from_schedule);
}
next prev parent reply other threads:[~2021-10-18 9:19 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-17 1:37 [PATCHSET 0/14] Various block layer optimizations Jens Axboe
2021-10-17 1:37 ` [PATCH 01/14] block: inline fast path of driver tag allocation Jens Axboe
2021-10-18 8:42 ` Christoph Hellwig
2021-10-18 14:38 ` Jens Axboe
2021-10-17 1:37 ` [PATCH 02/14] block: don't bother iter advancing a fully done bio Jens Axboe
2021-10-18 8:42 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 03/14] block: remove useless caller argument to print_req_error() Jens Axboe
2021-10-18 8:42 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 04/14] block: move update request helpers into blk-mq.c Jens Axboe
2021-10-18 8:43 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 05/14] block: don't call blk_status_to_errno() for success status Jens Axboe
2021-10-18 8:53 ` Christoph Hellwig
2021-10-18 10:49 ` Pavel Begunkov
2021-10-17 1:37 ` [PATCH 06/14] block: store elevator state in request Jens Axboe
2021-10-18 8:58 ` Christoph Hellwig
2021-10-18 14:34 ` Jens Axboe
2021-10-19 22:21 ` Guillaume Tucker
2021-10-19 22:26 ` Jens Axboe
2021-10-17 1:37 ` [PATCH 07/14] block: change plugging to use a singly linked list Jens Axboe
2021-10-18 9:19 ` Christoph Hellwig [this message]
2021-10-18 16:10 ` Jens Axboe
2021-10-18 12:56 ` Pavel Begunkov
2021-10-18 13:34 ` Jens Axboe
2021-10-17 1:37 ` [PATCH 08/14] block: improve layout of struct request Jens Axboe
2021-10-18 9:19 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 09/14] block: only mark bio as tracked if it really is tracked Jens Axboe
2021-10-18 9:19 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 10/14] block: move blk_mq_tag_to_rq() inline Jens Axboe
2021-10-17 1:37 ` [PATCH 11/14] block: optimize blk_mq_rq_ctx_init() Jens Axboe
2021-10-18 9:20 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 12/14] block: align blkdev_dio inlined bio to a cacheline Jens Axboe
2021-10-18 9:21 ` Christoph Hellwig
2021-10-18 14:36 ` Jens Axboe
2021-10-17 1:37 ` [PATCH 13/14] block: remove debugfs blk_mq_ctx dispatched/merged/completed attributes Jens Axboe
2021-10-18 9:21 ` Christoph Hellwig
2021-10-17 1:37 ` [PATCH 14/14] block: remove some blk_mq_hw_ctx debugfs entries Jens Axboe
2021-10-18 9:22 ` Christoph Hellwig
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=YW08EPYhH73m7nUj@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--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).