[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ec605aa-dd61-46eb-bcb6-282b482b90ea@huawei.com>
Date: Thu, 15 Jan 2026 13:44:10 +0800
From: Zheng Qixing <zhengqixing@...wei.com>
To: <yukuai@...as.com>
CC: <cgroups@...r.kernel.org>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <mkoutny@...e.com>, <yi.zhang@...wei.com>,
<yangerkun@...wei.com>, <houtao1@...wei.com>, <tj@...nel.org>,
<josef@...icpanda.com>, <axboe@...nel.dk>, <hch@...radead.org>, Zheng Qixing
<zhengqixing@...wei.com>
Subject: Re: [PATCH v2 1/3] blk-cgroup: fix race between policy activation and
blkg destruction
>> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
>> index 3cffb68ba5d8..600f8c5843ea 100644
>> --- a/block/blk-cgroup.c
>> +++ b/block/blk-cgroup.c
>> @@ -1596,6 +1596,8 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol)
>>
>> if (queue_is_mq(q))
>> memflags = blk_mq_freeze_queue(q);
>> +
>> + mutex_lock(&q->blkcg_mutex);
>> retry:
>> spin_lock_irq(&q->queue_lock);
>>
>> @@ -1658,6 +1660,7 @@ int blkcg_activate_policy(struct gendisk *disk, const struct blkcg_policy *pol)
>>
>> spin_unlock_irq(&q->queue_lock);
>> out:
>> + mutex_unlock(&q->blkcg_mutex);
>> if (queue_is_mq(q))
>> blk_mq_unfreeze_queue(q, memflags);
>> if (pinned_blkg)
> Can you also protect blkg_destroy_all() will blkcg_mutex as well? Then all access for q->blkg_list will
> be protected.
Why does blkg_destroy_all() also need blkcg_mutex?
After finishing ->pd_offline_fn() for blkgs and scheduling
blkg_free_workfn() in blkg_destroy(),
blkg_destroy_all() clears the corresponding policy bit in q->blkcg_pols
to avoid duplicate policy
teardown in blkcg_deactivate_policy().
Powered by blists - more mailing lists