From: Jan Kara <jack@suse.cz>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: axboe@kernel.dk, hch@lst.de, jack@suse.cz,
andriy.shevchenko@linux.intel.com, qiulaibin@huawei.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] blk-mq: count changed hctx as active in blk_mq_get_tag
Date: Thu, 9 Feb 2023 14:55:39 +0100 [thread overview]
Message-ID: <20230209135539.mokecz63dsolmemj@quack3> (raw)
In-Reply-To: <20230209201116.579809-3-shikemeng@huaweicloud.com>
On Fri 10-02-23 04:11:11, Kemeng Shi wrote:
> Commit d263ed9926823 ("blk-mq: count the hctx as active before allocating
> tag") active hctx before blk_mq_get_tag to avoid petential starvation.
> However, the hctx to alloc tag may change in blk_mq_get_tag if
> BLK_MQ_REQ_NOWAIT is not set, then there are two problems:
> 1. The hctx without real allocation is marked active.
> 2. The starvation problem mentioned in Commit d263ed9926823 ("blk-mq:
> count the hctx as active before allocating tag") still exists on the
> changed hctx as it maybe not marked active before tag allocation.
>
> For problem 1, the hctx which is marked active probably gets IO
> soon or will be marked inactive after lazy detection of tag idle.
> Mark changed hctx active to fix problem 2.
>
> Fixes: d263ed992682 ("blk-mq: count the hctx as active before allocating tag")
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Yeah, makes sense to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> block/blk-mq-tag.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index 1d3135acfc98..e566fd96dc26 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -191,6 +191,9 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)
> data->ctx = blk_mq_get_ctx(data->q);
> data->hctx = blk_mq_map_queue(data->q, data->cmd_flags,
> data->ctx);
> + if (!(data->rq_flags & RQF_ELV))
> + blk_mq_tag_busy(data->hctx);
> +
> tags = blk_mq_tags_from_data(data);
> if (data->flags & BLK_MQ_REQ_RESERVED)
> bt = &tags->breserved_tags;
> --
> 2.30.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-02-09 13:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 20:11 [PATCH 0/7] A few bugfix and cleanup patches to blk-mq Kemeng Shi
2023-02-09 20:11 ` [PATCH 1/7] blk-mq: sync wake_batch update and users number change Kemeng Shi
2023-02-09 13:43 ` Jan Kara
2023-02-09 20:11 ` [PATCH 2/7] blk-mq: count changed hctx as active in blk_mq_get_tag Kemeng Shi
2023-02-09 13:55 ` Jan Kara [this message]
2023-02-09 20:11 ` [PATCH 3/7] blk-mq: remove wake_batch recalculation for reserved tags Kemeng Shi
2023-02-09 20:11 ` [PATCH 4/7] blk-mq: remove unnecessary bit clear in __blk_mq_alloc_requests_batch Kemeng Shi
2023-02-09 20:11 ` [PATCH 5/7] blk-mq: remove unnecessary "set->queue_depth == 0" check in blk_mq_alloc_set_map_and_rqs Kemeng Shi
2023-02-09 20:11 ` [PATCH 6/7] blk-mq: Remove unnecessary hctx check in function blk_mq_alloc_and_init_hctx Kemeng Shi
2023-02-09 20:11 ` [PATCH 7/7] blk-mq: remove stale comment of function called for iterated request Kemeng Shi
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=20230209135539.mokecz63dsolmemj@quack3 \
--to=jack@suse.cz \
--cc=andriy.shevchenko@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qiulaibin@huawei.com \
--cc=shikemeng@huaweicloud.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