From: Ming Lei <ming.lei@redhat.com>
To: Yu Kuai <yukuai@fnnas.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com
Subject: Re: [PATCH RESEND 1/5] block/blk-rq-qos: add a new helper rq_qos_add_freezed()
Date: Mon, 17 Nov 2025 19:01:08 +0800 [thread overview]
Message-ID: <aRsAdF3GxNJ3Q1Qv@fedora> (raw)
In-Reply-To: <20251116041024.120500-2-yukuai@fnnas.com>
On Sun, Nov 16, 2025 at 12:10:20PM +0800, Yu Kuai wrote:
> queue should not be freezed under rq_qos_mutex, see example index
> commit 9730763f4756 ("block: correct locking order for protecting blk-wbt
> parameters"), which means current implementation of rq_qos_add() is
> problematic. Add a new helper and prepare to fix this problem in
> following patches.
>
> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
> ---
> block/blk-rq-qos.c | 27 +++++++++++++++++++++++++++
> block/blk-rq-qos.h | 2 ++
> 2 files changed, 29 insertions(+)
>
> diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c
> index 654478dfbc20..353397d7e126 100644
> --- a/block/blk-rq-qos.c
> +++ b/block/blk-rq-qos.c
> @@ -322,6 +322,33 @@ void rq_qos_exit(struct request_queue *q)
> mutex_unlock(&q->rq_qos_mutex);
> }
>
> +int rq_qos_add_freezed(struct rq_qos *rqos, struct gendisk *disk,
> + enum rq_qos_id id, const struct rq_qos_ops *ops)
> +{
> + struct request_queue *q = disk->queue;
> +
> + WARN_ON_ONCE(q->mq_freeze_depth == 0);
> + lockdep_assert_held(&q->rq_qos_mutex);
> +
> + if (rq_qos_id(q, id))
> + return -EBUSY;
> +
> + rqos->disk = disk;
> + rqos->id = id;
> + rqos->ops = ops;
> + rqos->next = q->rq_qos;
> + q->rq_qos = rqos;
> + blk_queue_flag_set(QUEUE_FLAG_QOS_ENABLED, q);
> +
> + if (rqos->ops->debugfs_attrs) {
> + mutex_lock(&q->debugfs_mutex);
> + blk_mq_debugfs_register_rqos(rqos);
> + mutex_unlock(&q->debugfs_mutex);
> + }
It will cause more lockdep splat to let q->debugfs_mutex depend on queue freeze,
Also blk_mq_debugfs_register_rqos() does _not_ require queue to be frozen,
and it should be fine to move blk_mq_debugfs_register_rqos() out of queue
freeze.
Thanks,
Ming
next prev parent reply other threads:[~2025-11-17 11:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-16 4:10 [PATCH RESEND 0/5] block/blk-rq-qos: fix incorrect lock order for rq_qos_mutex and freeze queue Yu Kuai
2025-11-16 4:10 ` [PATCH RESEND 1/5] block/blk-rq-qos: add a new helper rq_qos_add_freezed() Yu Kuai
2025-11-17 10:10 ` Nilay Shroff
2025-11-17 11:01 ` Ming Lei [this message]
2025-11-17 11:13 ` Nilay Shroff
2025-11-17 11:30 ` Ming Lei
2025-11-17 11:39 ` Yu Kuai
2025-11-17 11:54 ` Ming Lei
2025-11-17 11:59 ` Yu Kuai
2025-11-17 23:32 ` Bart Van Assche
2025-11-16 4:10 ` [PATCH RESEND 2/5] blk-wbt: fix incorrect lock order for rq_qos_mutex and freeze queue Yu Kuai
2025-11-17 10:11 ` Nilay Shroff
2025-11-19 6:55 ` kernel test robot
2025-11-16 4:10 ` [PATCH RESEND 3/5] blk-iocost: " Yu Kuai
2025-11-17 10:11 ` Nilay Shroff
2025-11-16 4:10 ` [PATCH RESEND 4/5] blk-iolatency: " Yu Kuai
2025-11-17 10:12 ` Nilay Shroff
2025-11-16 4:10 ` [PATCH RESEND 5/5] block/blk-rq-qos: cleanup rq_qos_add() Yu Kuai
2025-11-17 10:13 ` Nilay Shroff
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=aRsAdF3GxNJ3Q1Qv@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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