From: "yu kuai" <yukuai@fygo.io>
To: "Christoph Hellwig" <hch@lst.de>, "yu kuai" <yukuai@fygo.io>
Cc: <axboe@kernel.dk>, <tj@kernel.org>, <dongsheng.yang@linux.dev>,
<cengku@gmail.com>, <josef@toxicpanda.com>,
<nilay@linux.ibm.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 16:28:10 +0800 [thread overview]
Message-ID: <169a04be-2af6-4df3-9308-e2c0d5d4334a@fygo.io> (raw)
In-Reply-To: <20260728042313.GA19817@lst.de>
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
next prev parent reply other threads:[~2026-07-29 8:28 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 [this message]
2026-07-29 8:35 ` Christoph Hellwig
2026-07-29 8:05 ` Nilay Shroff
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=169a04be-2af6-4df3-9308-e2c0d5d4334a@fygo.io \
--to=yukuai@fygo.io \
--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=nilay@linux.ibm.com \
--cc=tj@kernel.org \
/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