All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Christoph Hellwig <hch@infradead.org>,
	Hannes Reinecke <hare@suse.com>,
	Johannes Thumshirn <jth@kernel.org>,
	syzbot+d44e1b26ce5c3e77458d@syzkaller.appspotmail.com
Subject: Re: [PATCH 2/5] blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync
Date: Tue, 18 Feb 2020 11:16:43 +0800	[thread overview]
Message-ID: <20200218031643.GB30750@ming.t460p> (raw)
In-Reply-To: <20200217210839.28535-3-bvanassche@acm.org>

On Mon, Feb 17, 2020 at 01:08:36PM -0800, Bart Van Assche wrote:
> This patch fixes the following kernel warning:
> 
> WARNING: CPU: 0 PID: 2501 at include/linux/cpumask.h:137
> Call Trace:
>  blk_mq_run_hw_queue+0x19d/0x350 block/blk-mq.c:1508
>  blk_mq_run_hw_queues+0x112/0x1a0 block/blk-mq.c:1525
>  blk_mq_requeue_work+0x502/0x780 block/blk-mq.c:775
>  process_one_work+0x9af/0x1740 kernel/workqueue.c:2269
>  worker_thread+0x98/0xe40 kernel/workqueue.c:2415
>  kthread+0x361/0x430 kernel/kthread.c:255
> 
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Johannes Thumshirn <jth@kernel.org>
> Reported-by: syzbot+d44e1b26ce5c3e77458d@syzkaller.appspotmail.com
> Fixes: ed76e329d74a ("blk-mq: abstract out queue map") # v5.0
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  block/blk-mq.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index f298500e6dda..2b9f490f5a64 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -3050,6 +3050,16 @@ static int blk_mq_update_queue_map(struct blk_mq_tag_set *set)
>  	}
>  }
>  
> +static void blk_mq_set_nr_hw_queues(struct blk_mq_tag_set *set,
> +				    int new_nr_hw_queues)
> +{
> +	int i;
> +
> +	set->nr_hw_queues = new_nr_hw_queues;
> +	for (i = 0; i < set->nr_maps; i++)
> +		set->map[i].nr_queues = new_nr_hw_queues;
> +}
> +
>  static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
>  				  int cur_nr_hw_queues, int new_nr_hw_queues)
>  {
> @@ -3068,7 +3078,7 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
>  		       sizeof(*set->tags));
>  	kfree(set->tags);
>  	set->tags = new_tags;
> -	set->nr_hw_queues = new_nr_hw_queues;
> +	blk_mq_set_nr_hw_queues(set, new_nr_hw_queues);
>  
>  	return 0;
>  }
> @@ -3330,7 +3340,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
>  		goto reregister;
>  
>  	prev_nr_hw_queues = set->nr_hw_queues;
> -	set->nr_hw_queues = nr_hw_queues;
> +	blk_mq_set_nr_hw_queues(set, nr_hw_queues);
>  	blk_mq_update_queue_map(set);
>  fallback:
>  	list_for_each_entry(q, &set->tag_list, tag_set_list) {
> @@ -3338,7 +3348,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
>  		if (q->nr_hw_queues != set->nr_hw_queues) {
>  			pr_warn("Increasing nr_hw_queues to %d fails, fallback to %d\n",
>  					nr_hw_queues, prev_nr_hw_queues);
> -			set->nr_hw_queues = prev_nr_hw_queues;
> +			blk_mq_set_nr_hw_queues(set, prev_nr_hw_queues);
>  			blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
>  			goto fallback;
>  		}
> 

I guess the issue can be fixed by the following change, and we do not
need to touch each queue map:

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 5f5c43ae3792..f7340afb89ec 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3046,6 +3046,7 @@ static int blk_mq_update_queue_map(struct blk_mq_tag_set *set)
                return set->ops->map_queues(set);
        } else {
                BUG_ON(set->nr_maps > 1);
+               set->map[HCTX_TYPE_DEFAULT].nr_queues = set->nr_hw_queues;
                return blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
        }
 }


Thanks,
Ming


  reply	other threads:[~2020-02-18  3:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 21:08 [PATCH 0/5] Five patches related to changing the number of hardware queues Bart Van Assche
2020-02-17 21:08 ` [PATCH 1/5] blk-mq: Fix a comment in include/linux/blk-mq.h Bart Van Assche
2020-02-18  3:04   ` Ming Lei
2020-02-17 21:08 ` [PATCH 2/5] blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync Bart Van Assche
2020-02-18  3:16   ` Ming Lei [this message]
2020-02-19  4:24     ` Bart Van Assche
2020-02-17 21:08 ` [PATCH 3/5] blk-mq: Fix a recently introduced regression in blk_mq_realloc_hw_ctxs() Bart Van Assche
2020-02-18  3:45   ` Ming Lei
2020-02-17 21:08 ` [PATCH 4/5] null_blk: Suppress an UBSAN complaint triggered when setting 'memory_backed' Bart Van Assche
2020-02-17 21:08 ` [PATCH 5/5] null_blk: Fix changing the number of hardware queues Bart Van Assche

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=20200218031643.GB30750@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.com \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jth@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=syzbot+d44e1b26ce5c3e77458d@syzkaller.appspotmail.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.