All of lore.kernel.org
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH v7 12/16] blk-iocost: fix incorrect lock order for rq_qos_mutex and freeze queue
Date: Wed, 7 Jan 2026 20:17:04 +0800	[thread overview]
Message-ID: <aV5OwAvw1sRF1IW1@fedora> (raw)
In-Reply-To: <20251231085126.205310-13-yukuai@fnnas.com>

On Wed, Dec 31, 2025 at 04:51:22PM +0800, Yu Kuai wrote:
> Like wbt, rq_qos_add() can be called from two path and the lock order
> are inversely:
> 
> - From ioc_qos_write(), queue is already frozen before rq_qos_add();
> - From ioc_cost_model_write(), rq_qos_add() is called directly;
> 
> Fix this problem by converting to use blkg_conf_open_bdev_frozen()
> from ioc_cost_model_write(), then since all rq_qos_add() callers
> already freeze queue, convert to use rq_qos_add_frozen().
> 
> Signed-off-by: Yu Kuai <yukuai@fnnas.com>
> ---
>  block/blk-iocost.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index a0416927d33d..929fc1421d7e 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -2925,7 +2925,7 @@ static int blk_iocost_init(struct gendisk *disk)
>  	 * called before policy activation completion, can't assume that the
>  	 * target bio has an iocg associated and need to test for NULL iocg.
>  	 */
> -	ret = rq_qos_add(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops);
> +	ret = rq_qos_add_frozen(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops);
>  	if (ret)
>  		goto err_free_ioc;
>  
> @@ -3408,7 +3408,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input,
>  {
>  	struct blkg_conf_ctx ctx;
>  	struct request_queue *q;
> -	unsigned int memflags;
> +	unsigned long memflags;
>  	struct ioc *ioc;
>  	u64 u[NR_I_LCOEFS];
>  	bool user;
> @@ -3417,9 +3417,11 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input,
>  
>  	blkg_conf_init(&ctx, input);
>  
> -	ret = blkg_conf_open_bdev(&ctx);
> -	if (ret)
> +	memflags = blkg_conf_open_bdev_frozen(&ctx);
> +	if (IS_ERR_VALUE(memflags)) {
> +		ret = memflags;
>  		goto err;
> +	}
>  

The following blk_iocost_init() runs into percpu allocation, so it will
create new lockdep warning.



Thanks,
Ming


  parent reply	other threads:[~2026-01-07 12:17 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31  8:51 [PATCH v7 00/16] blk-mq: fix possible deadlocks Yu Kuai
2025-12-31  8:51 ` [PATCH v7 01/16] blk-wbt: factor out a helper wbt_set_lat() Yu Kuai
2025-12-31  8:51 ` [PATCH v7 02/16] blk-wbt: fix possible deadlock to nest pcpu_alloc_mutex under q_usage_counter Yu Kuai
2026-01-07  9:30   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 03/16] blk-mq-debugfs: factor out a helper to register debugfs for all rq_qos Yu Kuai
2025-12-31  8:51 ` [PATCH v7 04/16] blk-rq-qos: fix possible debugfs_mutex deadlock Yu Kuai
2026-01-07  9:41   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 05/16] blk-mq-debugfs: make blk_mq_debugfs_register_rqos() static Yu Kuai
2026-01-07  9:42   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 06/16] blk-mq-debugfs: remove blk_mq_debugfs_unregister_rqos() Yu Kuai
2026-01-04 16:37   ` Nilay Shroff
2026-01-07  9:48   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 07/16] blk-mq-debugfs: add missing debugfs_mutex in blk_mq_debugfs_register_hctxs() Yu Kuai
2026-01-04 16:37   ` Nilay Shroff
2026-01-07  9:51   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 08/16] blk-mq-debugfs: warn about possible deadlock Yu Kuai
2026-01-04 16:38   ` Nilay Shroff
2026-01-07  9:56   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 09/16] blk-throttle: fix possible deadlock for fs reclaim under rq_qos_mutex Yu Kuai
2026-01-04 16:38   ` Nilay Shroff
2026-01-07 12:04   ` Ming Lei
2026-01-08 16:56     ` Yu Kuai
2026-01-09  2:18       ` Ming Lei
2026-01-09  2:22         ` Yu Kuai
2026-01-09  2:26           ` Ming Lei
2026-01-09  9:09       ` Nilay Shroff
2026-02-11  2:07         ` Yu Kuai
2025-12-31  8:51 ` [PATCH v7 10/16] block/blk-rq-qos: add a new helper rq_qos_add_frozen() Yu Kuai
2026-01-04 16:39   ` Nilay Shroff
2026-01-07 12:14   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 11/16] blk-wbt: fix incorrect lock order for rq_qos_mutex and freeze queue Yu Kuai
2026-01-04 16:39   ` Nilay Shroff
2026-01-07 12:14   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 12/16] blk-iocost: " Yu Kuai
2026-01-04 16:39   ` Nilay Shroff
2026-01-07 12:17   ` Ming Lei [this message]
2025-12-31  8:51 ` [PATCH v7 13/16] blk-iolatency: " Yu Kuai
2026-01-04 16:40   ` Nilay Shroff
2026-01-07 12:20   ` Ming Lei
2025-12-31  8:51 ` [PATCH v7 14/16] block/blk-rq-qos: cleanup rq_qos_add() Yu Kuai
2026-01-04 16:40   ` Nilay Shroff
2025-12-31  8:51 ` [PATCH v7 15/16] blk-rq-qos: remove queue frozen from rq_qos_del() Yu Kuai
2026-01-04 16:40   ` Nilay Shroff
2025-12-31  8:51 ` [PATCH v7 16/16] blk-cgroup: remove queue frozen from blkcg_activate_policy() Yu Kuai
2026-01-04 16:41   ` 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=aV5OwAvw1sRF1IW1@fedora \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.