From: Nilay Shroff <nilay@linux.ibm.com>
To: yukuai@fygo.io, axboe@kernel.dk, tj@kernel.org
Cc: hch@lst.de, dongsheng.yang@linux.dev, cengku@gmail.com,
josef@toxicpanda.com, ming.lei@redhat.com,
linux-block@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/8] block: associate blkg in submit_bio instead of bio_set_dev
Date: Wed, 29 Jul 2026 13:35:40 +0530 [thread overview]
Message-ID: <8d5f5b83-dea7-47cd-ab0f-61d85a3d7ed9@linux.ibm.com> (raw)
In-Reply-To: <933b4285-1c85-4076-831a-0501d5c38e16@fygo.io>
On 7/27/26 1:46 PM, yu kuai wrote:
> Hi,
>
> 在 2026/7/24 20:30, Yu Kuai 写道:
>> From: Yu Kuai<yukuai@fygo.io>
>>
>> bio_set_dev(), bio_init() and bio_reset() associate a bio with a blkg for
>> its target queue. That association may have to create a new blkg, and
>> currently there are lots of callers that are under atomic context.
>>
>> Move the association out of those helpers and into the submit path, which
>> is always sleepable (submit_bio_noacct() already does might_sleep()):
>>
>> - submit_bio() associates new I/O before bio_set_ioprio(), whose
>> blkcg_set_ioprio() reads the policy from bio->bi_blkg.
>>
>> - submit_bio_noacct() (re)associates when a bio has no blkg yet or was
>> remapped to a different queue. blk_throtl_bio() and the rq_qos
>> throttlers (iocost, iolatency) pair bio->bi_blkg with the queue of
>> bio->bi_bdev, so a remapped bio must be reassociated to the new queue.
>>
>> - bio_set_dev() no longer associates; instead it drops the existing blkg
>> when the device changes, since that blkg is tied to the old queue.
>> bio_init()/bio_reset() leave bi_blkg NULL.
>>
>> Introduce bio_disassociate_blkg() to drop a bio's blkg reference and use it
>> from bio_set_dev(), bio_uninit() and the bio freeing path, replacing their
>> open-coded blkg_put().
> Turns out bio will be submitted by kworker for some drivers and for
> blkcg_punt_bio_submit(). Is it possible to record blkcg during bio initialization,
> as blkcg must exist, and then covert it to blkg during submission? I can use union
> for blkcg and blkg to avoid new field in struct bio.
Since blkcg_punt_bio_submit() is the only deferred submission path, and it seems to
me that all of its callers (btrfs mostly) appear to be in sleepable context, would
it be sufficient to associate the blkg before punting the bio rather than changing the
bio lifetime semantics?
Thanks,
--Nilay
next prev parent reply other threads:[~2026-07-29 8:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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-27 8:16 ` yu kuai
2026-07-28 4:23 ` Christoph Hellwig
2026-07-29 8:28 ` yu kuai
2026-07-29 8:35 ` Christoph Hellwig
2026-07-29 8:05 ` Nilay Shroff [this message]
2026-07-29 9:49 ` yu kuai
2026-07-29 7:23 ` Tao Cui
2026-07-29 7:49 ` 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-29 7:29 ` Tao Cui
2026-07-29 7:54 ` 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-29 7:33 ` Tao Cui
2026-07-29 7:56 ` 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
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=8d5f5b83-dea7-47cd-ab0f-61d85a3d7ed9@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=cengku@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=dongsheng.yang@linux.dev \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=tj@kernel.org \
--cc=yukuai@fygo.io \
/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