All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/8] blk-cgroup: protect blkgs with blkcg_mutex
@ 2026-07-24 12:30 Yu Kuai
  2026-07-24 12:30 ` [RFC PATCH v2 1/8] block: associate blkg in submit_bio instead of bio_set_dev Yu Kuai
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Yu Kuai @ 2026-07-24 12:30 UTC (permalink / raw)
  To: axboe, tj
  Cc: hch, dongsheng.yang, cengku, josef, nilay, ming.lei, yukuai,
	linux-block, cgroups

From: Yu Kuai <yukuai@fygo.io>

This RFC moves queue-local blkg topology synchronization from q->queue_lock
to q->blkcg_mutex -- the same goal as v1 [1] -- but is restructured around
moving blkg association from bio_set_dev()/bio_init() into the submit path.

bio_set_dev() and bio allocation with a bdev currently associate a bio with
the destination queue's blkg.  Those helpers run from locked, irq-disabled
and GFP_NOWAIT contexts, so once missing-blkg creation is serialized by
q->blkcg_mutex they could no longer sleep safely.  Rather than auditing and
patching each such caller (as v1 did), v2 moves blkg association out of
bio_set_dev()/bio_init()/bio_reset() and into submit_bio()/
submit_bio_noacct(), which are always sleepable; bio_set_dev() now only
records the target device and drops the stale blkg.  This follows Christoph
Hellwig's review of v1.

q->blkcg_mutex then serializes blkg lookup/create/destroy, policy
[de]activation and configuration preparation; blkg allocation moves into
blkg_create() with a gfp_t argument; radix-tree preloading is removed; and
creation is shared between the bio path and configuration.

Nowait: REQ_NOWAIT I/O must not sleep to create a blkg.  The nowait
association path trylocks q->blkcg_mutex and allocates with GFP_ATOMIC; on
atomic context, mutex contention or allocation failure it leaves the bio
unassociated and submit_bio() completes it with BLK_STS_AGAIN so the
submitter retries.  This replaces v1's nowait-threading through the
bio_set_dev() callers.

Changes since v1 [1]:

- Reworked on top of "associate blkg in submit_bio instead of bio_set_dev"
- Dropped the per-subsystem bio_set_dev() workarounds -- NVMe multipath
  retarget (v1 1), dm-thin (v1 2), dm-snapshot (v1 3), bcache (v1 8),
  dm-bufio (v1 9), dm-pcache (v1 10), DM NOWAIT remaps (v1 12) -- no longer
  needed because bio_set_dev() no longer associates.
- Dropped atomic bio allocation -- bio_alloc_atomic() (v1 5) and
  non-blocking bio allocation with a bdev (v1 7); the
  nd_virtio/ocfs2 callers are handled separately.
- Dropped the nowait-bio-allocation association helpers (v1 6, 11); nowait
  is handled once, at submit, by failing the bio.
- Kept and adapted: blk-throttle private runtime lock (v1 4); the
  blkcg_mutex conversion (v1 14, now also annotating submit_bio() with
  might_sleep() since association may sleep there); radix preload removal
  (v1 15); blkg_create() allocation (v1 16); shared creation (v1 17); and
  the BFQ locked-cgroup-update fix (v1 13).

[1] v1: https://lore.kernel.org/r/20260704195124.1375075-1-yukuai@kernel.org

Yu Kuai (8):
  block: associate blkg in submit_bio instead of bio_set_dev
  blk-throttle: protect throttle state with td lock
  blk-cgroup: protect blkgs with blkcg_mutex
  blk-cgroup: remove blkg radix tree preloading
  blk-cgroup: allocate blkgs in blkg_create
  blk-cgroup: share blkg creation between lookup and config prep
  bfq: avoid blkg lookup from locked cgroup update
  block: fail nowait bio submit if blkg allocation can't sleep

 block/bfq-cgroup.c    |  26 ++-
 block/bio.c           |  18 +-
 block/blk-cgroup.c    | 434 +++++++++++++++++++-----------------------
 block/blk-cgroup.h    |  16 +-
 block/blk-core.c      |  36 ++++
 block/blk-iocost.c    |   5 +-
 block/blk-iolatency.c |   7 +-
 block/blk-throttle.c  |  93 ++++++---
 include/linux/bio.h   |  18 +-
 9 files changed, 350 insertions(+), 303 deletions(-)


base-commit: 093fbffe03f5c1bb9c10a9e5aa65b23250844403
-- 
2.51.0


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

end of thread, other threads:[~2026-07-26  7:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 12:30 [RFC PATCH v2 0/8] blk-cgroup: protect blkgs with blkcg_mutex Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 1/8] block: associate blkg in submit_bio instead of bio_set_dev Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 2/8] blk-throttle: protect throttle state with td lock Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 3/8] blk-cgroup: protect blkgs with blkcg_mutex Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 4/8] blk-cgroup: remove blkg radix tree preloading Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 5/8] blk-cgroup: allocate blkgs in blkg_create Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 6/8] blk-cgroup: share blkg creation between lookup and config prep Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 7/8] bfq: avoid blkg lookup from locked cgroup update Yu Kuai
2026-07-24 12:30 ` [RFC PATCH v2 8/8] block: fail nowait bio submit if blkg allocation can't sleep Yu Kuai
2026-07-26  7:08 ` [syzbot ci] Re: blk-cgroup: protect blkgs with blkcg_mutex syzbot ci

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.