* [PATCH v2 0/2] block: skip quiescing the queue for the default elevator
@ 2026-10-15 1:52 Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 1/2] block: don't quiesce the queue when setting " Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 2/2] block: rename the out_unfreeze label in elevator_switch() Qiliang Yuan
0 siblings, 2 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-10-15 1:52 UTC (permalink / raw)
To: Jens Axboe, Ming Lei, Nilay Shroff, Hannes Reinecke
Cc: linux-block, linux-kernel, Qiliang Yuan, stable
Setting the default elevator of a new disk quiesces the queue, so every
disk added with a default elevator waits for an RCU grace period. Patch
1 skips the quiesce there, which brings START_DEV of a single-queue ublk
device from 7.74ms to 0.68ms at p50. Patch 2 renames a misleading label
in elevator_switch().
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
V1 -> V2:
- Add Reviewed-by from Ming Lei and Nilay Shroff to patch 1.
- Rename out_unfreeze to out_unquiesce in a separate patch 2 (Nilay).
- Rebase onto for-7.4/block.
v1: https://lore.kernel.org/r/20261001-bug-block-elevator-init-quiesce-v1-1-5c85fa0ec59b@gmail.com
---
Qiliang Yuan (2):
block: don't quiesce the queue when setting the default elevator
block: rename the out_unfreeze label in elevator_switch()
block/elevator.c | 11 +++++++----
block/elevator.h | 2 ++
2 files changed, 9 insertions(+), 4 deletions(-)
---
base-commit: 0f6b042f9a13968c4cd6cde1a70a7b242009ef46
change-id: 20260930-bug-block-elevator-init-quiesce-35d73f9b462d
Best regards,
--
Qiliang Yuan <odys.yuan@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] block: don't quiesce the queue when setting the default elevator
2026-10-15 1:52 [PATCH v2 0/2] block: skip quiescing the queue for the default elevator Qiliang Yuan
@ 2026-10-15 1:52 ` Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 2/2] block: rename the out_unfreeze label in elevator_switch() Qiliang Yuan
1 sibling, 0 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-10-15 1:52 UTC (permalink / raw)
To: Jens Axboe, Ming Lei, Nilay Shroff, Hannes Reinecke
Cc: linux-block, linux-kernel, Qiliang Yuan, stable
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>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.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;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] block: rename the out_unfreeze label in elevator_switch()
2026-10-15 1:52 [PATCH v2 0/2] block: skip quiescing the queue for the default elevator Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 1/2] block: don't quiesce the queue when setting " Qiliang Yuan
@ 2026-10-15 1:52 ` Qiliang Yuan
1 sibling, 0 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-10-15 1:52 UTC (permalink / raw)
To: Jens Axboe, Ming Lei, Nilay Shroff, Hannes Reinecke
Cc: linux-block, linux-kernel, Qiliang Yuan
Commit f8e111c859b9 ("block: don't call freeze queue in
elevator_switch() and elevator_disable()") moved freezing the queue
out of elevator_switch() into its callers, but kept the out_unfreeze
label, which used to unquiesce and unfreeze the queue.
The code at the label now unquiesces the queue but never unfreezes it,
so the name is misleading.
Rename the label to out_unquiesce.
Suggested-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
block/elevator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index da9ba70ac9321..80cbac91581b0 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -584,7 +584,7 @@ static int elevator_switch(struct request_queue *q, struct elv_change_ctx *ctx)
if (new_e) {
ret = blk_mq_init_sched(q, new_e, &ctx->res);
if (ret)
- goto out_unfreeze;
+ goto out_unquiesce;
ctx->new = q->elevator;
} else {
blk_queue_flag_clear(QUEUE_FLAG_SQ_SCHED, q);
@@ -594,7 +594,7 @@ 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:
+out_unquiesce:
if (!ctx->no_quiesce)
blk_mq_unquiesce_queue(q);
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-15 1:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 1:52 [PATCH v2 0/2] block: skip quiescing the queue for the default elevator Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 1/2] block: don't quiesce the queue when setting " Qiliang Yuan
2026-10-15 1:52 ` [PATCH v2 2/2] block: rename the out_unfreeze label in elevator_switch() Qiliang Yuan
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®