From: Nilay Shroff <nilay@linux.ibm.com>
To: Yu Kuai <yukuai@fnnas.com>, Jens Axboe <axboe@kernel.dk>,
ming.lei@redhat.com, hch@lst.de,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Yi Zhang <yi.zhang@redhat.com>,
Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blk-mq: use NOIO context to prevent deadlock during debugfs creation
Date: Thu, 12 Feb 2026 14:16:02 +0530 [thread overview]
Message-ID: <88a12e1c-05b6-44de-806e-06a8e2ff7c0a@linux.ibm.com> (raw)
In-Reply-To: <20260212080135.1673063-1-yukuai@fnnas.com>
On 2/12/26 1:31 PM, Yu Kuai wrote:
> Creating debugfs entries can trigger fs reclaim, which can enter back
> into the block layer request_queue. This can cause deadlock if the
> queue is frozen.
>
> Previously, a WARN_ON_ONCE check was used in debugfs_create_files()
> to detect this condition, but it was racy since the queue can be frozen
> from another context at any time.
>
> Introduce blk_debugfs_mutex_lock()/blk_debugfs_mutex_unlock() helpers
> that combine the debugfs_mutex with memalloc_noio_save()/restore() to
> prevent fs reclaim from triggering block I/O. Replace all raw
> debugfs_mutex lock/unlock pairs with these helpers.
It looks like there are still a few places where ->debugfs_mutex is
taken but the code paths do not enter fs-reclaim. For those cases,
it may not be necessary to wrap the critical section in a NOIO context.
Perhaps it would make sense to provide two separate helper APIs: one
that acquires ->debugfs_mutex and also saves/restores the NOIO context
(using memalloc_noio_save()/restore()), and another that simply acquires
and releases ->debugfs_mutex without entering NOIO. Callers could then
choose the appropriate helper depending on whether the code path may
trigger fs-reclaim.
For reference,
blk_mq_freeze_queue()/blk_mq_unfreeze_queue() vs
blk_mq_freeze_queue_nomemsave()/blk_mq_unfreeze_queue_nomemrestore()
Thanks,
--Nilay
next prev parent reply other threads:[~2026-02-12 8:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-12 8:01 [PATCH] blk-mq: use NOIO context to prevent deadlock during debugfs creation Yu Kuai
2026-02-12 8:46 ` Nilay Shroff [this message]
2026-02-13 4:08 ` Yu Kuai
2026-02-13 4:43 ` Ming Lei
2026-02-13 5:39 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88a12e1c-05b6-44de-806e-06a8e2ff7c0a@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=ming.lei@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
--cc=yi.zhang@redhat.com \
--cc=yukuai@fnnas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox