From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, bvanassche@acm.org, ming.lei@redhat.com
Subject: Re: [PATCH 1/2] block/mq-deadline: serialize request dispatching
Date: Fri, 19 Jan 2024 10:40:47 +0800 [thread overview]
Message-ID: <ZanhL+fOWNSz2zJf@fedora> (raw)
In-Reply-To: <20240118180541.930783-2-axboe@kernel.dk>
On Thu, Jan 18, 2024 at 11:04:56AM -0700, Jens Axboe wrote:
> If we're entering request dispatch but someone else is already
> dispatching, then just skip this dispatch. We know IO is inflight and
> this will trigger another dispatch event for any completion. This will
> potentially cause slightly lower queue depth for contended cases, but
> those are slowed down anyway and this should not cause an issue.
>
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
> ---
> block/mq-deadline.c | 28 +++++++++++++++++++++++-----
> 1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/block/mq-deadline.c b/block/mq-deadline.c
> index f958e79277b8..9e0ab3ea728a 100644
> --- a/block/mq-deadline.c
> +++ b/block/mq-deadline.c
> @@ -79,10 +79,20 @@ struct dd_per_prio {
> struct io_stats_per_prio stats;
> };
>
> +enum {
> + DD_DISPATCHING = 0,
> +};
> +
> struct deadline_data {
> /*
> * run time data
> */
> + struct {
> + spinlock_t lock;
> + spinlock_t zone_lock;
> + } ____cacheline_aligned_in_smp;
> +
> + unsigned long run_state;
>
> struct dd_per_prio per_prio[DD_PRIO_COUNT];
>
> @@ -100,9 +110,6 @@ struct deadline_data {
> int front_merges;
> u32 async_depth;
> int prio_aging_expire;
> -
> - spinlock_t lock;
> - spinlock_t zone_lock;
> };
>
> /* Maps an I/O priority class to a deadline scheduler priority. */
> @@ -600,6 +607,15 @@ static struct request *dd_dispatch_request(struct blk_mq_hw_ctx *hctx)
> struct request *rq;
> enum dd_prio prio;
>
> + /*
> + * If someone else is already dispatching, skip this one. This will
> + * defer the next dispatch event to when something completes, and could
> + * potentially lower the queue depth for contended cases.
> + */
> + if (test_bit(DD_DISPATCHING, &dd->run_state) ||
> + test_and_set_bit(DD_DISPATCHING, &dd->run_state))
> + return NULL;
> +
This patch looks fine.
BTW, the current dispatch is actually piggyback in the in-progress dispatch,
see blk_mq_do_dispatch_sched(). And the correctness should depend on
the looping dispatch & retry for nothing to dispatch in
blk_mq_do_dispatch_sched(), maybe we need to document it here.
Thanks,
Ming
next prev parent reply other threads:[~2024-01-19 2:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 18:04 [PATCHSET RFC 0/2] mq-deadline scalability improvements Jens Axboe
2024-01-18 18:04 ` [PATCH 1/2] block/mq-deadline: serialize request dispatching Jens Axboe
2024-01-18 18:24 ` Bart Van Assche
2024-01-18 18:45 ` Jens Axboe
2024-01-18 18:51 ` Bart Van Assche
2024-01-18 18:55 ` Jens Axboe
2024-01-19 2:40 ` Ming Lei [this message]
2024-01-19 15:49 ` Jens Axboe
2024-01-18 18:04 ` [PATCH 2/2] block/mq-deadline: fallback to per-cpu insertion buckets under contention Jens Axboe
2024-01-18 18:25 ` Keith Busch
2024-01-18 18:28 ` Jens Axboe
2024-01-18 18:31 ` Bart Van Assche
2024-01-18 18:33 ` Jens Axboe
2024-01-18 18:53 ` Bart Van Assche
2024-01-18 18:56 ` Jens Axboe
2024-01-18 20:46 ` Bart Van Assche
2024-01-18 20:52 ` Jens Axboe
2024-01-19 23:11 ` Bart Van Assche
2024-01-18 19:29 ` [PATCHSET RFC 0/2] mq-deadline scalability improvements Jens Axboe
2024-01-18 20:22 ` Jens Axboe
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=ZanhL+fOWNSz2zJf@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.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