public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Christoph Hellwig <hch@lst.de>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"kch@nvidia.com" <kch@nvidia.com>
Subject: Re: [PATCH 2/2] blk-mq: simplify blk_mq_realloc_tag_set_tags
Date: Fri, 18 Nov 2022 14:06:42 +0000	[thread overview]
Message-ID: <20221118140640.featvt3fxktfquwh@shindev> (raw)
In-Reply-To: <20221109100811.2413423-2-hch@lst.de>

On Nov 09, 2022 / 11:08, Christoph Hellwig wrote:
> Use set->nr_hw_queues for the current number of tags, and remove the
> duplicate set->nr_hw_queues update in the caller.

Chaitanya found that blktests test cases block/029 and block/030 fail on
linux-block/for-next branch [1]. The test cases modify null_blk devices'
submit_queues number during test, and it caused the failures.

[1] https://lore.kernel.org/linux-block/5183bc2c-746b-5806-9ace-31a3a7000e6d@nvidia.com/

I bisected and confirmed that this patch is the trigger. As I noted below,
one of its hunks looks wrong for me.

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  block/blk-mq.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 8c630dbdf107e..9fa0b9a1435f2 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4381,11 +4381,11 @@ static void blk_mq_update_queue_map(struct blk_mq_tag_set *set)
>  }
>  
>  static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
> -				  int cur_nr_hw_queues, int new_nr_hw_queues)
> +				       int new_nr_hw_queues)
>  {
>  	struct blk_mq_tags **new_tags;
>  
> -	if (cur_nr_hw_queues >= new_nr_hw_queues)
> +	if (set->nr_hw_queues >= new_nr_hw_queues)
>  		return 0;
>

When the condition of the if statement above is true, set->nr_hw_queues is no
longer updated with new_nr_hw_queues. In nullb_update_nr_hw_queues(), null_blk
calls blk_mq_update_nr_hw_queues() and refers set->nr_hw_queues. With unexpected
set->nr_hw_queues value, null_blk fails to update submit_queues number.

With a quick fix below, the blktests failures were avoided. Could you take look
and see if this is the right fix?

diff --git a/block/blk-mq.c b/block/blk-mq.c
index a3a5fb4d4ef6..604e19be9648 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4384,8 +4384,10 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
 {
        struct blk_mq_tags **new_tags;

-       if (set->nr_hw_queues >= new_nr_hw_queues)
+       if (set->nr_hw_queues >= new_nr_hw_queues) {
+               set->nr_hw_queues = new_nr_hw_queues;
                return 0;
+       }

        new_tags = kcalloc_node(new_nr_hw_queues, sizeof(struct blk_mq_tags *),
                                GFP_KERNEL, set->numa_node);

-- 
Shin'ichiro Kawasaki

  parent reply	other threads:[~2022-11-18 14:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 10:08 [PATCH 1/2] blk-mq: remove blk_mq_alloc_tag_set_tags Christoph Hellwig
2022-11-09 10:08 ` [PATCH 2/2] blk-mq: simplify blk_mq_realloc_tag_set_tags Christoph Hellwig
2022-11-09 19:45   ` Chaitanya Kulkarni
2022-11-18 14:06   ` Shinichiro Kawasaki [this message]
2022-11-21  7:58     ` Christoph Hellwig
2022-11-21 11:14       ` Shinichiro Kawasaki
2022-11-21 13:19         ` Christoph Hellwig
2022-11-22  6:54           ` Shinichiro Kawasaki
2022-11-09 19:45 ` [PATCH 1/2] blk-mq: remove blk_mq_alloc_tag_set_tags Chaitanya Kulkarni
2022-11-10 18:18 ` Jens Axboe

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=20221118140640.featvt3fxktfquwh@shindev \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-block@vger.kernel.org \
    /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