* [PATCH] blk-mq-debugfs: Fix warning about possible deadlock
@ 2026-02-13 22:45 Mohamed Khalfella
2026-02-15 13:36 ` Nilay Shroff
0 siblings, 1 reply; 3+ messages in thread
From: Mohamed Khalfella @ 2026-02-13 22:45 UTC (permalink / raw)
To: Jens Axboe, Omar Sandoval, Ming Lei
Cc: Hannes Reinecke, Yu Kuai, Nilay Shroff, linux-block, linux-kernel,
Mohamed Khalfella
Commit 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
added WARN_ONCE_ON() to debugfs_create_files() to prevent potential
deadlock if the queue is frozen. We hit this warning with the stacktrace
below
WARNING: block/blk-mq-debugfs.c:620 at debugfs_create_files+0x9c/0x1d0
Workqueue: nvme-wq nvme_tcp_reconnect_ctrl_work [nvme_tcp]
RIP: 0010:debugfs_create_files+0x9c/0x1d0
Call Trace:
<TASK>
blk_mq_debugfs_register_hctx+0x186/0x320
blk_mq_debugfs_register_hctxs+0x80/0xa0
blk_mq_update_nr_hw_queues+0xc8f/0xd50
nvme_tcp_setup_ctrl+0xcfa/0xda0 [nvme_tcp]
nvme_tcp_reconnect_ctrl_work+0x51/0x180 [nvme_tcp]
process_scheduled_works+0x840/0xd80
worker_thread+0x36d/0x4a0
kthread+0x366/0x380
ret_from_fork+0x7b/0x670
ret_from_fork_asm+0x1a/0x30
</TASK>
Here __blk_mq_update_nr_hw_queues() did set PF_MEMALLOC_NOIO flag before
calling blk_mq_debugfs_register_hctxs() and this should guarantee the
described deadlock will not happen. Warn only if the queue is frozen and
NOIO flag is not set.
Fixes: 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
---
block/blk-mq-debugfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index faeaa1fc86a7..ec6670dc0a3d 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -612,12 +612,14 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
void *data,
const struct blk_mq_debugfs_attr *attr)
{
+ unsigned int pflags = READ_ONCE(current->flags);
+
lockdep_assert_held(&q->debugfs_mutex);
/*
* Creating new debugfs entries with queue freezed has the risk of
* deadlock.
*/
- WARN_ON_ONCE(q->mq_freeze_depth != 0);
+ WARN_ON_ONCE((q->mq_freeze_depth != 0) && !(pflags & PF_MEMALLOC_NOIO));
/*
* debugfs_mutex should not be nested under other locks that can be
* grabbed while queue is frozen.
base-commit: cd7a5651db263b5384aef1950898e5e889425134
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] blk-mq-debugfs: Fix warning about possible deadlock
2026-02-13 22:45 [PATCH] blk-mq-debugfs: Fix warning about possible deadlock Mohamed Khalfella
@ 2026-02-15 13:36 ` Nilay Shroff
2026-02-16 2:45 ` Mohamed Khalfella
0 siblings, 1 reply; 3+ messages in thread
From: Nilay Shroff @ 2026-02-15 13:36 UTC (permalink / raw)
To: Mohamed Khalfella, Jens Axboe, Omar Sandoval, Ming Lei
Cc: Hannes Reinecke, Yu Kuai, linux-block, linux-kernel
On 2/14/26 4:15 AM, Mohamed Khalfella wrote:
> Commit 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
> added WARN_ONCE_ON() to debugfs_create_files() to prevent potential
> deadlock if the queue is frozen. We hit this warning with the stacktrace
> below
>
> WARNING: block/blk-mq-debugfs.c:620 at debugfs_create_files+0x9c/0x1d0
> Workqueue: nvme-wq nvme_tcp_reconnect_ctrl_work [nvme_tcp]
> RIP: 0010:debugfs_create_files+0x9c/0x1d0
> Call Trace:
> <TASK>
> blk_mq_debugfs_register_hctx+0x186/0x320
> blk_mq_debugfs_register_hctxs+0x80/0xa0
> blk_mq_update_nr_hw_queues+0xc8f/0xd50
> nvme_tcp_setup_ctrl+0xcfa/0xda0 [nvme_tcp]
> nvme_tcp_reconnect_ctrl_work+0x51/0x180 [nvme_tcp]
> process_scheduled_works+0x840/0xd80
> worker_thread+0x36d/0x4a0
> kthread+0x366/0x380
> ret_from_fork+0x7b/0x670
> ret_from_fork_asm+0x1a/0x30
> </TASK>
>
> Here __blk_mq_update_nr_hw_queues() did set PF_MEMALLOC_NOIO flag before
> calling blk_mq_debugfs_register_hctxs() and this should guarantee the
> described deadlock will not happen. Warn only if the queue is frozen and
> NOIO flag is not set.
>
> Fixes: 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
> Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
> ---
> block/blk-mq-debugfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> index faeaa1fc86a7..ec6670dc0a3d 100644
> --- a/block/blk-mq-debugfs.c
> +++ b/block/blk-mq-debugfs.c
> @@ -612,12 +612,14 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
> void *data,
> const struct blk_mq_debugfs_attr *attr)
> {
> + unsigned int pflags = READ_ONCE(current->flags);
> +
> lockdep_assert_held(&q->debugfs_mutex);
> /*
> * Creating new debugfs entries with queue freezed has the risk of
> * deadlock.
> */
> - WARN_ON_ONCE(q->mq_freeze_depth != 0);
> + WARN_ON_ONCE((q->mq_freeze_depth != 0) && !(pflags & PF_MEMALLOC_NOIO));
> /*
> * debugfs_mutex should not be nested under other locks that can be
> * grabbed while queue is frozen.
>
> base-commit: cd7a5651db263b5384aef1950898e5e889425134
This issue is already being addressed here:
https://lore.kernel.org/all/20260214054350.2322436-1-yukuai@fnnas.com/
Thanks,
--Nilay
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] blk-mq-debugfs: Fix warning about possible deadlock
2026-02-15 13:36 ` Nilay Shroff
@ 2026-02-16 2:45 ` Mohamed Khalfella
0 siblings, 0 replies; 3+ messages in thread
From: Mohamed Khalfella @ 2026-02-16 2:45 UTC (permalink / raw)
To: Nilay Shroff
Cc: Jens Axboe, Omar Sandoval, Ming Lei, Hannes Reinecke, Yu Kuai,
linux-block, linux-kernel
On Sun 2026-02-15 19:06:21 +0530, Nilay Shroff wrote:
>
>
> On 2/14/26 4:15 AM, Mohamed Khalfella wrote:
> > Commit 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
> > added WARN_ONCE_ON() to debugfs_create_files() to prevent potential
> > deadlock if the queue is frozen. We hit this warning with the stacktrace
> > below
> >
> > WARNING: block/blk-mq-debugfs.c:620 at debugfs_create_files+0x9c/0x1d0
> > Workqueue: nvme-wq nvme_tcp_reconnect_ctrl_work [nvme_tcp]
> > RIP: 0010:debugfs_create_files+0x9c/0x1d0
> > Call Trace:
> > <TASK>
> > blk_mq_debugfs_register_hctx+0x186/0x320
> > blk_mq_debugfs_register_hctxs+0x80/0xa0
> > blk_mq_update_nr_hw_queues+0xc8f/0xd50
> > nvme_tcp_setup_ctrl+0xcfa/0xda0 [nvme_tcp]
> > nvme_tcp_reconnect_ctrl_work+0x51/0x180 [nvme_tcp]
> > process_scheduled_works+0x840/0xd80
> > worker_thread+0x36d/0x4a0
> > kthread+0x366/0x380
> > ret_from_fork+0x7b/0x670
> > ret_from_fork_asm+0x1a/0x30
> > </TASK>
> >
> > Here __blk_mq_update_nr_hw_queues() did set PF_MEMALLOC_NOIO flag before
> > calling blk_mq_debugfs_register_hctxs() and this should guarantee the
> > described deadlock will not happen. Warn only if the queue is frozen and
> > NOIO flag is not set.
> >
> > Fixes: 65d466b62984 ("blk-mq-debugfs: warn about possible deadlock")
> > Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
> > ---
> > block/blk-mq-debugfs.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> > index faeaa1fc86a7..ec6670dc0a3d 100644
> > --- a/block/blk-mq-debugfs.c
> > +++ b/block/blk-mq-debugfs.c
> > @@ -612,12 +612,14 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent,
> > void *data,
> > const struct blk_mq_debugfs_attr *attr)
> > {
> > + unsigned int pflags = READ_ONCE(current->flags);
> > +
> > lockdep_assert_held(&q->debugfs_mutex);
> > /*
> > * Creating new debugfs entries with queue freezed has the risk of
> > * deadlock.
> > */
> > - WARN_ON_ONCE(q->mq_freeze_depth != 0);
> > + WARN_ON_ONCE((q->mq_freeze_depth != 0) && !(pflags & PF_MEMALLOC_NOIO));
> > /*
> > * debugfs_mutex should not be nested under other locks that can be
> > * grabbed while queue is frozen.
> >
> > base-commit: cd7a5651db263b5384aef1950898e5e889425134
>
> This issue is already being addressed here:
> https://lore.kernel.org/all/20260214054350.2322436-1-yukuai@fnnas.com/
Got it. Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-16 2:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-13 22:45 [PATCH] blk-mq-debugfs: Fix warning about possible deadlock Mohamed Khalfella
2026-02-15 13:36 ` Nilay Shroff
2026-02-16 2:45 ` Mohamed Khalfella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox