Skip to content

blk-cgroup: fix blkg list and policy data races

Yu Kuai cgroups linux-block lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutexblock/blk-cgroup.c+3 -00 replies
2/5bfq: protect q->blkg_list iteration in bfq_end_wr_async() with blkcg_mutexblock/bfq-cgroup.c block/bfq-iosched.c+8 -12 replies
3/5blk-cgroup: fix race between policy activation and blkg destructionblock/blk-cgroup.c+3 -00 replies
4/5blk-cgroup: skip dying blkg in blkcg_activate_policy()block/blk-cgroup.c+2 -00 replies
5/5blk-cgroup: factor policy pd teardown loop into helperblock/blk-cgroup.c+27 -300 replies

Reviews trailers per patch

1 of 5 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchChristoph HellwigYu KuaiTang Yizhou
SeriesR-b
1/5
2/5
3/5
4/5
5/5R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/5] blk-cgroup: fix blkg list and policy data races

This small series fixes races between blkg destruction, q->blkg_list iteration, and blkcg policy activation.

The first two patches serialize q->blkg_list walks in blkg_destroy_all() and BFQ writeback weight-raising teardown with blkcg_mutex. The next two patches close policy activation races with concurrent blkg destruction, including skipping blkgs that are already dying. The final patch factors the common policy data teardown loop.

This uses blkcg_mutex rather than extending queue_lock coverage because the races are about blkg list visibility and policy-data lifetime, not request-queue dispatch state. blkg_free_workfn() already uses blkcg_mutex to serialize policy-data freeing with policy deactivation and removes blkgs from q->blkg_list only after that teardown. Taking the same mutex around the remaining q->blkg_list walkers gives one sleepable serialization point for blkg lifetime, avoids adding more queue_lock nesting, and prepares the follow-up conversion that removes queue_lock from blkcg list protection entirely.

Yu Kuai (2):
blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with
blkcg_mutex
bfq: protect q->blkg_list iteration in bfq_end_wr_async() 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/bfq-cgroup.c  |  3 ++-
 block/bfq-iosched.c |  6 +++++
 block/blk-cgroup.c  | 65 ++++++++++++++++++++++++---------------------
 3 files changed, 43 insertions(+), 31 deletions(-)
Signature · 1 line
2.51.0