public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/7] blk-cgroup: fix races and deadlocks
@ 2026-02-03  8:05 Yu Kuai
  2026-02-03  8:05 ` [PATCH v2 1/7] blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutex Yu Kuai
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Yu Kuai @ 2026-02-03  8:05 UTC (permalink / raw)
  To: tj, josef, axboe
  Cc: cgroups, linux-block, linux-kernel, yukuai, zhengqixing, mkoutny,
	hch, ming.lei, nilay

Changes in v2:
 - check dying blkg early in patch 4;
 - add patch 7 to fix rq_qos_mutex related deadlocks;

This series fixes race conditions between blkcg_activate_policy() and
blkg destruction, and optimizes the policy activation path.

Patches 1-2 add missing blkcg_mutex protection for q->blkg_list iteration.

Patches 3-5 from Zheng Qixing fix use-after-free and memory leak issues
caused by races between policy activation and blkg destruction.

Patch 6 restructures blkcg_activate_policy() to allocate pds before
freezing the queue. This is a prep patch to fix deadlocks related to
percpu allocation with queue frozen, since some policies like iocost
and iolatency do percpu allocation in pd_alloc_fn().

Patch 7 reduces freeze queue contex by moving rq_qos_mutex into
rq_qos_add/del, so that allocate memory without queue frozen.

Yu Kuai (4):
  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
  blk-cgroup: allocate pds before freezing queue in
    blkcg_activate_policy()
  blk-rq-qos: move rq_qos_mutex acquisition inside rq_qos_add/del

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 |   2 +
 block/blk-cgroup.c  | 200 ++++++++++++++------------------------------
 block/blk-cgroup.h  |   2 -
 block/blk-iocost.c  |  11 +--
 block/blk-rq-qos.c  |  31 ++++---
 block/blk-wbt.c     |   2 -
 7 files changed, 90 insertions(+), 161 deletions(-)

-- 
2.51.0


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

end of thread, other threads:[~2026-02-04  6:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03  8:05 [PATCH v2 0/7] blk-cgroup: fix races and deadlocks Yu Kuai
2026-02-03  8:05 ` [PATCH v2 1/7] blk-cgroup: protect q->blkg_list iteration in blkg_destroy_all() with blkcg_mutex Yu Kuai
2026-02-03  8:05 ` [PATCH v2 2/7] bfq: protect q->blkg_list iteration in bfq_end_wr_async() " Yu Kuai
2026-02-03 12:54   ` kernel test robot
2026-02-03 13:07     ` Yu Kuai
2026-02-03 13:36   ` kernel test robot
2026-02-03  8:05 ` [PATCH v2 3/7] blk-cgroup: fix race between policy activation and blkg destruction Yu Kuai
2026-02-03  8:05 ` [PATCH v2 4/7] blk-cgroup: skip dying blkg in blkcg_activate_policy() Yu Kuai
2026-02-03  8:06 ` [PATCH v2 5/7] blk-cgroup: factor policy pd teardown loop into helper Yu Kuai
2026-02-03  8:06 ` [PATCH v2 6/7] blk-cgroup: allocate pds before freezing queue in blkcg_activate_policy() Yu Kuai
2026-02-03  9:06   ` Michal Koutný
2026-02-04  6:44     ` Yu Kuai
2026-02-03  8:06 ` [PATCH v2 7/7] blk-rq-qos: move rq_qos_mutex acquisition inside rq_qos_add/del Yu Kuai

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