* [PATCH] block: don't quiesce the queue when setting the default elevator
@ 2026-10-01 3:10 Qiliang Yuan
2026-10-10 2:36 ` Qiliang Yuan
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-01 3:10 UTC (permalink / raw)
To: Jens Axboe, Nilay Shroff, Hannes Reinecke, Ming Lei
Cc: linux-block, linux-kernel, stable, Qiliang Yuan
elevator_set_default() runs from blk_register_queue() while the disk is
still being added: the block device is not visible yet and uevents are
suppressed, so no file system I/O can be issued. elevator_change()
freezes the queue and cancels the dispatch work before switching, which
is enough to drain dispatch activity from passthrough requests, as the
comment in elevator_change() already states.
elevator_switch() still quiesces the queue unconditionally, though, so
every disk added with a default elevator waits for an RCU grace period.
Commit 245a489e81e1 ("block: avoid to quiesce queue in
elevator_init_mq") had removed this wait from the default elevator
setup, and it came back when that setup was folded into
elevator_change().
The wait is paid in full by callers that add disks one at a time. ublk
adds the disk of a single-queue device from START_DEV, which takes 7.7ms
at p50 in a 16 vCPU KVM guest, most of it in blk_mq_quiesce_queue()
called from elevator_set_default().
Skip quiescing in elevator_switch() when setting the default elevator.
ublk null target, 1000 single-queue devices created one by one:
before after
START_DEV p50 7.74ms 0.68ms
START_DEV p99 14.61ms 1.32ms
devices/s 114 971
Fixes: 1e44bedbc921 ("block: unifying elevator change")
Cc: stable@vger.kernel.org
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
block/elevator.c | 7 +++++--
block/elevator.h | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index 2161b6eea680c..da9ba70ac9321 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -573,7 +573,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
return -EINVAL;
}
- blk_mq_quiesce_queue(q);
+ if (!ctx->no_quiesce)
+ blk_mq_quiesce_queue(q);
if (q->elevator) {
ctx->old = q->elevator;
@@ -594,7 +595,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
blk_add_trace_msg(q, "elv switch: %s", ctx->name);
out_unfreeze:
- blk_mq_unquiesce_queue(q);
+ if (!ctx->no_quiesce)
+ blk_mq_unquiesce_queue(q);
if (ret) {
pr_warn("elv: switch to \"%s\" failed, falling back to \"none\"\n",
@@ -731,6 +733,7 @@ void elevator_set_default(struct request_queue *q)
struct elv_change_ctx ctx = {
.name = "mq-deadline",
.no_uevent = true,
+ .no_quiesce = true,
};
int err;
diff --git a/block/elevator.h b/block/elevator.h
index 3eb32516be0b1..3886d97427e33 100644
--- a/block/elevator.h
+++ b/block/elevator.h
@@ -43,6 +43,8 @@ struct elevator_resources {
struct elv_change_ctx {
const char *name;
bool no_uevent;
+ /* the disk isn't added yet, so skip quiescing the queue */
+ bool no_quiesce;
/* for unregistering old elevator */
struct elevator_queue *old;
---
base-commit: 551c722f40809618230001baccf219193e22fc5a
change-id: 20260930-bug-block-elevator-init-quiesce-35d73f9b462d
Best regards,
--
Qiliang Yuan <odys.yuan@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: don't quiesce the queue when setting the default elevator
2026-10-01 3:10 [PATCH] block: don't quiesce the queue when setting the default elevator Qiliang Yuan
@ 2026-10-10 2:36 ` Qiliang Yuan
2026-10-10 3:17 ` Qiliang Yuan
2026-10-10 4:18 ` Ming Lei
2026-10-12 8:26 ` Nilay Shroff
2 siblings, 1 reply; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-10 2:36 UTC (permalink / raw)
To: Ming Lei, Jens Axboe, Nilay Shroff, Hannes Reinecke
Cc: linux-block, linux-kernel, stable
Hi Ming, Jens,
Gentle ping. Since 1e44bedbc921 ("block: unifying elevator change"),
setting the default elevator quiesces the queue again, which
245a489e81e1 had avoided, so every disk added with a default elevator
waits for an RCU grace period. START_DEV of a single-queue ublk device
takes 7.74ms at p50 instead of 0.68ms.
Ming, as the author of 1e44bedbc921, could you take a look when you
have a moment?
Thanks,
Qiliang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: don't quiesce the queue when setting the default elevator
2026-10-10 2:36 ` Qiliang Yuan
@ 2026-10-10 3:17 ` Qiliang Yuan
0 siblings, 0 replies; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-10 3:17 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, Nilay Shroff, Hannes Reinecke, linux-block,
linux-kernel, stable
Hi Ming,
The patch and my ping went to your Red Hat address, which I think you
no longer use, so adding your current one. The patch is here:
https://lore.kernel.org/r/20261001-bug-block-elevator-init-quiesce-v1-1-5c85fa0ec59b@gmail.com
Thanks,
Qiliang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: don't quiesce the queue when setting the default elevator
2026-10-01 3:10 [PATCH] block: don't quiesce the queue when setting the default elevator Qiliang Yuan
2026-10-10 2:36 ` Qiliang Yuan
@ 2026-10-10 4:18 ` Ming Lei
2026-10-12 8:26 ` Nilay Shroff
2 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2026-10-10 4:18 UTC (permalink / raw)
To: Qiliang Yuan
Cc: Jens Axboe, Nilay Shroff, Hannes Reinecke, Ming Lei, linux-block,
linux-kernel, stable
On Wed, Sep 30, 2026 at 10:12 PM Qiliang Yuan <odys.yuan@gmail.com> wrote:
>
> elevator_set_default() runs from blk_register_queue() while the disk is
> still being added: the block device is not visible yet and uevents are
> suppressed, so no file system I/O can be issued. elevator_change()
> freezes the queue and cancels the dispatch work before switching, which
> is enough to drain dispatch activity from passthrough requests, as the
> comment in elevator_change() already states.
>
> elevator_switch() still quiesces the queue unconditionally, though, so
> every disk added with a default elevator waits for an RCU grace period.
> Commit 245a489e81e1 ("block: avoid to quiesce queue in
> elevator_init_mq") had removed this wait from the default elevator
> setup, and it came back when that setup was folded into
> elevator_change().
>
> The wait is paid in full by callers that add disks one at a time. ublk
> adds the disk of a single-queue device from START_DEV, which takes 7.7ms
> at p50 in a 16 vCPU KVM guest, most of it in blk_mq_quiesce_queue()
> called from elevator_set_default().
>
> Skip quiescing in elevator_switch() when setting the default elevator.
>
> ublk null target, 1000 single-queue devices created one by one:
>
> before after
> START_DEV p50 7.74ms 0.68ms
> START_DEV p99 14.61ms 1.32ms
> devices/s 114 971
>
> Fixes: 1e44bedbc921 ("block: unifying elevator change")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
> ---
> block/elevator.c | 7 +++++--
> block/elevator.h | 2 ++
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/block/elevator.c b/block/elevator.c
> index 2161b6eea680c..da9ba70ac9321 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -573,7 +573,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
> return -EINVAL;
> }
>
> - blk_mq_quiesce_queue(q);
> + if (!ctx->no_quiesce)
> + blk_mq_quiesce_queue(q);
>
> if (q->elevator) {
> ctx->old = q->elevator;
> @@ -594,7 +595,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
> blk_add_trace_msg(q, "elv switch: %s", ctx->name);
>
> out_unfreeze:
> - blk_mq_unquiesce_queue(q);
> + if (!ctx->no_quiesce)
> + blk_mq_unquiesce_queue(q);
>
> if (ret) {
> pr_warn("elv: switch to \"%s\" failed, falling back to \"none\"\n",
> @@ -731,6 +733,7 @@ void elevator_set_default(struct request_queue *q)
> struct elv_change_ctx ctx = {
> .name = "mq-deadline",
> .no_uevent = true,
> + .no_quiesce = true,
> };
> int err;
Looks good given elevator_set_default() is only called on new added disk,
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Thanks,
Ming Lei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: don't quiesce the queue when setting the default elevator
2026-10-01 3:10 [PATCH] block: don't quiesce the queue when setting the default elevator Qiliang Yuan
2026-10-10 2:36 ` Qiliang Yuan
2026-10-10 4:18 ` Ming Lei
@ 2026-10-12 8:26 ` Nilay Shroff
2 siblings, 0 replies; 5+ messages in thread
From: Nilay Shroff @ 2026-10-12 8:26 UTC (permalink / raw)
To: Qiliang Yuan, Jens Axboe, Hannes Reinecke, Ming Lei
Cc: linux-block, linux-kernel, stable
On 10/1/26 8:40 AM, Qiliang Yuan wrote:
> elevator_set_default() runs from blk_register_queue() while the disk is
> still being added: the block device is not visible yet and uevents are
> suppressed, so no file system I/O can be issued. elevator_change()
> freezes the queue and cancels the dispatch work before switching, which
> is enough to drain dispatch activity from passthrough requests, as the
> comment in elevator_change() already states.
>
> elevator_switch() still quiesces the queue unconditionally, though, so
> every disk added with a default elevator waits for an RCU grace period.
> Commit 245a489e81e1 ("block: avoid to quiesce queue in
> elevator_init_mq") had removed this wait from the default elevator
> setup, and it came back when that setup was folded into
> elevator_change().
>
> The wait is paid in full by callers that add disks one at a time. ublk
> adds the disk of a single-queue device from START_DEV, which takes 7.7ms
> at p50 in a 16 vCPU KVM guest, most of it in blk_mq_quiesce_queue()
> called from elevator_set_default().
>
> Skip quiescing in elevator_switch() when setting the default elevator.
>
> ublk null target, 1000 single-queue devices created one by one:
>
> before after
> START_DEV p50 7.74ms 0.68ms
> START_DEV p99 14.61ms 1.32ms
> devices/s 114 971
>
> Fixes: 1e44bedbc921 ("block: unifying elevator change")
> Cc:stable@vger.kernel.org
> Signed-off-by: Qiliang Yuan<odys.yuan@gmail.com>
> ---
> block/elevator.c | 7 +++++--
> block/elevator.h | 2 ++
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/block/elevator.c b/block/elevator.c
> index 2161b6eea680c..da9ba70ac9321 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -573,7 +573,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
> return -EINVAL;
> }
>
> - blk_mq_quiesce_queue(q);
> + if (!ctx->no_quiesce)
> + blk_mq_quiesce_queue(q);
>
> if (q->elevator) {
> ctx->old = q->elevator;
> @@ -594,7 +595,8 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
> blk_add_trace_msg(q, "elv switch: %s", ctx->name);
>
> out_unfreeze:
> - blk_mq_unquiesce_queue(q);
> + if (!ctx->no_quiesce)
> + blk_mq_unquiesce_queue(q);
>
One minor nit: Since we only unquiesce the queue at the out_unfreeze label,
could you rename it to out_unquiesce while you're at it? I realize this label
predates your change, but the new name would better reflect what happens there.
Otherwise, this change looks good to me.
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-12 8:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 3:10 [PATCH] block: don't quiesce the queue when setting the default elevator Qiliang Yuan
2026-10-10 2:36 ` Qiliang Yuan
2026-10-10 3:17 ` Qiliang Yuan
2026-10-10 4:18 ` Ming Lei
2026-10-12 8:26 ` Nilay Shroff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®