[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33c009e6-0cc3-bfc3-f7e5-8227cb467696@huaweicloud.com>
Date: Tue, 14 Oct 2025 16:21:30 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Ming Lei <ming.lei@...hat.com>
Cc: nilay@...ux.ibm.com, tj@...nel.org, josef@...icpanda.com,
axboe@...nel.dk, cgroups@...r.kernel.org, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org, yukuai1@...weicloud.com, yi.zhang@...wei.com,
yangerkun@...wei.com, johnny.chenyi@...wei.com,
"yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH 1/4] blk-mq-debugfs: warn about possible deadlock
Hi,
在 2025/10/14 16:06, Ming Lei 写道:
> On Tue, Oct 14, 2025 at 10:21:46AM +0800, Yu Kuai wrote:
>> Creating new debugfs entries can trigger fs reclaim, hence we can't do
>> this with queue freezed, meanwhile, other locks that can be held while
>> queue is freezed should not be held as well.
>>
>> Signed-off-by: Yu Kuai <yukuai3@...wei.com>
>> ---
>> block/blk-mq-debugfs.c | 31 ++++++++++++++++++++++++-------
>> 1 file changed, 24 insertions(+), 7 deletions(-)
>>
>> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
>> index 4896525b1c05..66864ed0b77f 100644
>> --- a/block/blk-mq-debugfs.c
>> +++ b/block/blk-mq-debugfs.c
>> @@ -608,9 +608,23 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
>> {},
>> };
>>
>> -static void debugfs_create_files(struct dentry *parent, void *data,
>> +static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
>> + void *data,
>> const struct blk_mq_debugfs_attr *attr)
>> {
>> + /*
>> + * Creating new debugfs entries with queue freezed has the rist of
>> + * deadlock.
>> + */
>> + WARN_ON_ONCE(q->mq_freeze_depth != 0);
>> + /*
>> + * debugfs_mutex should not be nested under other locks that can be
>> + * grabbed while queue is freezed.
>> + */
>> + lockdep_assert_not_held(&q->elevator_lock);
>> + lockdep_assert_not_held(&q->rq_qos_mutex);
>
> ->rq_qos_mutex use looks one real mess, in blk-cgroup.c, it is grabbed after
> queue is frozen. However, inside block/blk-rq-qos.c, the two are re-ordered,
> maybe we need to fix order between queue freeze and q->rq_qos_mutex first?
> Or move on by removing the above line?
Yeah, I see this reoder as well, and I tried to fix this in the other
thread for blkg configuration.
- queue is freezed by new helper blkg_conf_start(), and unfreezed after
blkg_conf_end(), rq_qos_add() is now called between them.
And for wbt, there are two cases:
- for blk-sysfs, queue is alredy freezed before rq_qos_add() as well;
- for wbt_enable_default(), this looks still problemaic, we should fix
the reorder seperatly.
Perhaps, should I fix this simple problem first, and then rebase the
thread to convert queue_lock to blkcg_mtuex?
Thanks,
Kuai
Thanks,
Kuai
>
> Otherwise, this patch looks good.
>
>
> Thanks,
> Ming
>
>
> .
>
Powered by blists - more mailing lists