From: Ming Lei <ming.lei@redhat.com>
To: Yu Kuai <yukuai@fnnas.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org, tj@kernel.org,
nilay@linux.ibm.com, bvanassche@acm.org
Subject: Re: [PATCH v3 06/10] blk-wbt: fix incorrect lock order for rq_qos_mutex and freeze queue
Date: Mon, 1 Dec 2025 08:29:06 +0800 [thread overview]
Message-ID: <aSzhUuotVA2a5h2h@fedora> (raw)
In-Reply-To: <20251130024349.2302128-7-yukuai@fnnas.com>
On Sun, Nov 30, 2025 at 10:43:45AM +0800, Yu Kuai wrote:
> wbt_init() can be called from sysfs attribute and wbt_enable_default(),
> however the lock order are inversely.
>
> - queue_wb_lat_store() freeze queue first, and then wbt_init() hold
> rq_qos_mutex. In this case queue will be frozen again inside
> rq_qos_add(), however, in this case freeze queue recursively is
> inoperative;
> - wbt_enable_default() from elevator switch will hold rq_qos_mutex
> first, and then rq_qos_add() will freeze queue;
>
> Fix this problem by converting to use new helper rq_qos_add_frozen() in
> wbt_init(), and for wbt_enable_default(), freeze queue before calling
> wbt_init().
>
> Fixes: a13bd91be223 ("block/rq_qos: protect rq_qos apis with a new lock")
> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
> ---
> block/blk-wbt.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> index b1ab0f297f24..5e7e481103a1 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -725,7 +725,11 @@ void wbt_enable_default(struct gendisk *disk)
> return;
>
> if (queue_is_mq(q) && enable) {
> + unsigned int memflags = blk_mq_freeze_queue(q);
> +
> wbt_init(disk);
> + blk_mq_unfreeze_queue(q, memflags);
> +
This change causes new lockdep warning, see the report in:
https://lore.kernel.org/linux-block/692c17ca.a70a0220.d98e3.016c.GAE@google.com/
Thanks,
Ming
next prev parent reply other threads:[~2025-12-01 0:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-30 2:43 [PATCH v3 00/10] blk-mq: fix possible deadlocks Yu Kuai
2025-11-30 2:43 ` [PATCH v3 01/10] blk-mq-debugfs: factor out a helper to register debugfs for all rq_qos Yu Kuai
2025-11-30 2:43 ` [PATCH v3 02/10] blk-rq-qos: fix possible debugfs_mutex deadlock Yu Kuai
2025-11-30 2:43 ` [PATCH v3 03/10] blk-mq-debugfs: make blk_mq_debugfs_register_rqos() static Yu Kuai
2025-11-30 2:43 ` [PATCH v3 04/10] blk-mq-debugfs: warn about possible deadlock Yu Kuai
2025-11-30 2:43 ` [PATCH v3 05/10] block/blk-rq-qos: add a new helper rq_qos_add_frozen() Yu Kuai
2025-11-30 2:43 ` [PATCH v3 06/10] blk-wbt: fix incorrect lock order for rq_qos_mutex and freeze queue Yu Kuai
2025-12-01 0:29 ` Ming Lei [this message]
2025-11-30 2:43 ` [PATCH v3 07/10] blk-iocost: " Yu Kuai
2025-11-30 2:43 ` [PATCH v3 08/10] blk-iolatency: " Yu Kuai
2025-11-30 2:43 ` [PATCH v3 09/10] blk-throttle: remove useless queue frozen Yu Kuai
2025-11-30 2:43 ` [PATCH v3 10/10] block/blk-rq-qos: cleanup rq_qos_add() Yu Kuai
2025-11-30 10:09 ` [syzbot ci] Re: blk-mq: fix possible deadlocks syzbot ci
2025-11-30 19:50 ` Yu Kuai
2025-12-01 0:26 ` Ming Lei
2025-12-01 4:43 ` Yu Kuai
2025-12-01 8:37 ` Ming Lei
2025-12-01 8:41 ` 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=aSzhUuotVA2a5h2h@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=linux-block@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=tj@kernel.org \
--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