block/blk-cgroup.c | 65 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 30 deletions(-)
From: Yu Kuai <yukuai@fygo.io>
This set fix some problems that are reported long time ago with minimal changes,
the blkcg_mutex refactor I'm working on can fix these problems as well, but it's
complicated and may not land in this merge window. So I think this 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.
Changes since v3:
- Rebase on the latest for-7.3/block branch.
Changes since v2:
- Rebase on the latest block-7.2 branch.
Changes since v1:
- Drop the BFQ q->blkg_list patch because the current block tree already
has a stronger fix in commit 17b2d950a3c0 ("block, bfq: protect async
queue reset with blkcg locks").
- Add Reviewed-by tags from Tang Yizhou.
Yu Kuai (1):
blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with
blkcg_mutex
Zheng Qixing (3):
blk-cgroup: fix race between policy activation and blkg destruction
blk-cgroup: skip dying blkg in blkcg_activate_policy()
blk-cgroup: factor policy pd teardown loop into helper
block/blk-cgroup.c | 65 +++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 30 deletions(-)
--
2.51.0
From: Yu Kuai <yukuai@fygo.io>
This set fix some problems that are reported long time ago with minimal changes,
the blkcg_mutex refactor I'm working on can fix these problems as well, but it's
complicated and may not land in this merge window. So I think this 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.
Changes since v3:
- Rebase on the latest for-7.3/block branch.
Changes since v2:
- Rebase on the latest block-7.2 branch.
Changes since v1:
- Drop the BFQ q->blkg_list patch because the current block tree already
has a stronger fix in commit 17b2d950a3c0 ("block, bfq: protect async
queue reset with blkcg locks").
- Add Reviewed-by tags from Tang Yizhou.
Yu Kuai (1):
blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with
blkcg_mutex
Zheng Qixing (3):
blk-cgroup: fix race between policy activation and blkg destruction
blk-cgroup: skip dying blkg in blkcg_activate_policy()
blk-cgroup: factor policy pd teardown loop into helper
block/blk-cgroup.c | 65 +++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 30 deletions(-)
--
2.51.0
On 8/2/26 4:55 PM, Yu Kuai wrote: > From: Yu Kuai <yukuai@fygo.io> > > This set fix some problems that are reported long time ago with minimal changes, > the blkcg_mutex refactor I'm working on can fix these problems as well, but it's > complicated and may not land in this merge window. So I think this 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? Thanks, --Nilay
Hi, 在 2026/8/3 14:51, Nilay Shroff 写道: > On 8/2/26 4:55 PM, Yu Kuai wrote: >> From: Yu Kuai <yukuai@fygo.io> >> >> This set fix some problems that are reported long time ago with >> minimal changes, >> the blkcg_mutex refactor I'm working on can fix these problems as >> well, but it's >> complicated and may not land in this merge window. So I think this >> 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 the following RFC v1 set: [RFC PATCH v1 00/17] blk-cgroup: protect blkgs with blkcg_mutex - Yu Kuai <https://lore.kernel.org/all/20260704195124.1375075-1-yukuai@kernel.org/> > > Thanks, > --Nilay > -- Thanks, Kuai
On 8/3/26 1:50 PM, yu kuai wrote: > Hi, > > 在 2026/8/3 14:51, Nilay Shroff 写道: >> On 8/2/26 4:55 PM, Yu Kuai wrote: >>> From: Yu Kuai <yukuai@fygo.io> >>> >>> This set fix some problems that are reported long time ago with >>> minimal changes, >>> the blkcg_mutex refactor I'm working on can fix these problems as >>> well, but it's >>> complicated and may not land in this merge window. So I think this >>> 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 the > following RFC v1 set: > > [RFC PATCH v1 00/17] blk-cgroup: protect blkgs with blkcg_mutex - Yu Kuai <https://lore.kernel.org/all/20260704195124.1375075-1-yukuai@kernel.org/> > Okay understood. With that, for this entire patchset: Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
On Sun, 02 Aug 2026 19:25:16 +0800, Yu Kuai wrote:
> This set fix some problems that are reported long time ago with minimal changes,
> the blkcg_mutex refactor I'm working on can fix these problems as well, but it's
> complicated and may not land in this merge window. So I think this set should land
> in this merge window first.
>
> Patch 1 protects blkg_destroy_all()'s q->blkg_list walk with
> blkcg_mutex.
>
> [...]
Applied, thanks!
[1/4] blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutex
(no commit info)
[2/4] blk-cgroup: fix race between policy activation and blkg destruction
(no commit info)
[3/4] blk-cgroup: skip dying blkg in blkcg_activate_policy()
(no commit info)
[4/4] blk-cgroup: factor policy pd teardown loop into helper
(no commit info)
Best regards,
--
Jens Axboe
© 2016 - 2026 Red Hat, Inc.