Re: [RFC PATCH v2 1/8] block: associate blkg in submit_bio instead of bio_set_dev
"yu kuai" <[email protected]> Wed, 29 Jul 2026 16:28:10 +0800
| Newsgroups | org.kernel.vger.cgroups,org.kernel.vger.linux-block |
|---|---|
| Message-ID | <[email protected]> |
Hi, 在 2026/7/28 12:23, Christoph Hellwig 写道: > On Mon, Jul 27, 2026 at 04:16:29PM +0800, yu kuai wrote: >>> 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. > Mixing the two up sounds like a receipt for a lot of problems > unfortunately. I wonder if we could switch to only store the blkcg in > the bio and look up the blkg as needed. This assumes we can get away > with a relatively small numbers of lookups for typical setups. I'm not > really sure how much the different users are combined - if not much this > might actually be a big net benefit, if on the other hand we'd have to > do a lot of separate lookups it might not work very well. This sounds interesting, take a quick look, some places are using bi_blkg to get blkcg and this can be optimized, while other places are all related to blkcg policies. And I think the blkg slow path radix tree lookup should be fine, because when we enable blkcg policies, it's expected performance should already be affected. On the other hand, if no policies are enabled, looks like no blkg will be created, and this will be beneficial as there should be many environments that blkcg policies are not enabled. The only problem I see is rq_qos_merge(), where bi_blkg is deference with elevator spinlock held. However, I think this can be avoided as well, we can only do fast path blkg lookup, and skip merge if blkg do not exist, as we only require same blkcg bio merge, there is no IO to merge if this bio is the first blkcg bio. If you agree, I'll start to cook a new pre-set to convert bi_blkg to bi_blkcg, and then convert queuelock to blkcg_mutex. > > This could be combined with a way to do more efficient blkg lookups > using e.g. a rhashtable. > -- Thanks, Kuai