Re: [PATCH v4 0/4] blk-cgroup: fix blkg list and policy data races

"yu kuai" <[email protected]> Mon, 3 Aug 2026 16:20:38 +0800
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi,

=E5=9C=A8 2026/8/3 14:51, Nilay Shroff =E5=86=99=E9=81=93:
> On 8/2/26 4:55 PM, Yu Kuai wrote:
>> From: Yu Kuai <[email protected]>
>>
>> This set fix some problems that are reported long time ago with=20
>> minimal changes,
>> the blkcg_mutex refactor I'm working on can fix these problems as=20
>> well, but it's
>> complicated and may not land in this merge window. So I think this=20
>> set should land
>> in this merge window first.
>>
>> Patch 1 protects blkg_destroy_all()'s q->blkg_list walk with
>> blkcg_mutex.
>>
>> Patches 2-3 fix races between blkcg_activate_policy() and concurrent
>> blkg destruction.
>>
>> Patch 4 factors the policy data teardown loop into a helper after the
>> race fixes.
>>
>
> This series looks good to me, however as I recall, we discussed about
> protecting blkg_create() as well using ->blkcg_mutex. I remember the
> blkg_create() is not protected with ->blkcg_mutex under each call path,
> so would you to also cover that change in this patchset?

I can't do this for now without a big refactor, because it's possible that
blkg_create() can be called from bio_set_dev(), and bio_set_dev() can be
called from many atomic contexts, examples are patch 1,2,3,5,8,9,10 from th=
e
following RFC v1 set:

[RFC PATCH v1 00/17] blk-cgroup: protect blkgs with blkcg_mutex - Yu Kuai <=
https://lore.kernel.org/all/[email protected]/>

>
> Thanks,
> --Nilay
>
--=20
Thanks,
Kuai