Linux block layer
 help / color / mirror / Atom feed
* [PATCH 0/5] blk-cgroup: fix blkg list and policy data races
@ 2026-06-03 13:27 Yu Kuai
  2026-06-03 13:27 ` [PATCH 1/5] blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutex Yu Kuai
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Yu Kuai @ 2026-06-03 13:27 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Tejun Heo, Josef Bacik, Ming Lei, Nilay Shroff, Bart Van Assche,
	linux-block, cgroups, linux-kernel

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(-)

-- 
2.51.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-06-09 15:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 13:27 [PATCH 0/5] blk-cgroup: fix blkg list and policy data races Yu Kuai
2026-06-03 13:27 ` [PATCH 1/5] blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutex Yu Kuai
2026-06-03 13:27 ` [PATCH 2/5] bfq: protect q->blkg_list iteration in bfq_end_wr_async() " Yu Kuai
2026-06-04 17:31   ` Nilay Shroff
2026-06-08  2:48     ` yu kuai
2026-06-03 13:27 ` [PATCH 3/5] blk-cgroup: fix race between policy activation and blkg destruction Yu Kuai
2026-06-03 13:27 ` [PATCH 4/5] blk-cgroup: skip dying blkg in blkcg_activate_policy() Yu Kuai
2026-06-03 13:27 ` [PATCH 5/5] blk-cgroup: factor policy pd teardown loop into helper Yu Kuai
2026-06-03 14:35 ` [PATCH 0/5] blk-cgroup: fix blkg list and policy data races Jens Axboe
     [not found]   ` <189b8601-87a6-423a-b267-9d550c31c086@fnnas.com>
2026-06-03 15:08     ` Jens Axboe
2026-06-09 15:15 ` Yizhou Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox