Re: [PATCH 1/4] blk-mq-debugfs: warn about possible deadlock
From: Ming Lei
Date: Tue Oct 14 2025 - 04:07:14 EST
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@xxxxxxxxxx>
> ---
> 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?
Otherwise, this patch looks good.
Thanks,
Ming