mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] blk-mq: stop waiting for an SRCU grace period when freeing a tag set
@ 2026-10-01  9:17 Qiliang Yuan
  2026-10-01  9:17 ` [PATCH 1/2] blk-mq: share one tags_srcu instance across all tag sets Qiliang Yuan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Qiliang Yuan @ 2026-10-01  9:17 UTC (permalink / raw)
  To: Jens Axboe, Ming Lei
  Cc: Yu Kuai, Hannes Reinecke, Martin K. Petersen, Paul E. McKenney,
	linux-block, linux-kernel, Qiliang Yuan

blk_mq_free_tag_set() calls srcu_barrier() on the tag set's own
tags_srcu before cleaning it up. That costs a full SRCU grace period,
1-3 ms, on every tag set teardown. When the free happens under a lock,
the cost multiplies. ublk drops its last device reference under the
global ublk_ctl_mutex, which caps 16-thread deletion of 4000 devices at
19 s on 7.3-rc5.

The SRCU callbacks free only blk-mq-owned memory and never touch the
tag set, so patch 1 makes the SRCU instance global and drops the
per-set barrier and cleanup. Patch 2 removes the tag_set argument that
was added to blk_mq_free_rq_map() and blk_mq_free_tags() only to reach
the per-set instance.

With patch 1, 16-thread deletion of 4000 ublk devices takes 2.9 s and
serial DEL_DEV drops from 3.45 ms to 0.17 ms. Destroying 256 null_blk
devices from 16 threads goes from 5.15 s to 4.30 s.

Tested on 7.3-rc5 with ublk and null_blk create/destroy loops. A
KASAN + lockdep + DEBUG_OBJECTS_RCU_HEAD kernel ran a 10-minute stress
that raced device creation and destruction, I/O, scheduler and
nr_requests changes, and CPU hotplug against inflight, debugfs busy and
tags readers. It produced no reports.

Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
Qiliang Yuan (2):
      blk-mq: share one tags_srcu instance across all tag sets
      blk-mq: drop the tag_set argument from blk_mq_free_rq_map/tags

 block/blk-mq-tag.c     | 19 +++++++++++++------
 block/blk-mq.c         | 25 +++++++++----------------
 block/blk-mq.h         |  6 ++++--
 include/linux/blk-mq.h |  3 ---
 4 files changed, 26 insertions(+), 27 deletions(-)
---
base-commit: 551c722f40809618230001baccf219193e22fc5a
change-id: 20261001-bug-blk-mq-global-tags-srcu-811e8d958281

Best regards,
-- 
Qiliang Yuan <odys.yuan@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-15  2: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  9:17 [PATCH 0/2] blk-mq: stop waiting for an SRCU grace period when freeing a tag set Qiliang Yuan
2026-10-01  9:17 ` [PATCH 1/2] blk-mq: share one tags_srcu instance across all tag sets Qiliang Yuan
2026-10-01  9:17 ` [PATCH 2/2] blk-mq: drop the tag_set argument from blk_mq_free_rq_map/tags Qiliang Yuan
2026-10-01 16:10 ` [PATCH 0/2] blk-mq: stop waiting for an SRCU grace period when freeing a tag set Paul E. McKenney
2026-10-15  2:26 ` 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®