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 v2 2/8] blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync
Date: Fri, 21 Feb 2020 04:47:13 +0800	[thread overview]
Message-ID: <20200220204713.GB28199@ming.t460p> (raw)
In-Reply-To: <37505ee7-fba6-1b25-64c4-f632280e8b70@acm.org>

On Thu, Feb 20, 2020 at 08:14:11AM -0800, Bart Van Assche wrote:
> On 2/20/20 2:05 AM, Ming Lei wrote:
> > On Wed, Feb 19, 2020 at 06:44:35PM -0800, Bart Van Assche wrote:
> > > blk_mq_map_queues() and multiple .map_queues() implementations expect that
> > > set->map[HCTX_TYPE_DEFAULT].nr_queues is set to the number of hardware
> > 
> > Only single queue mapping expects set->map[HCTX_TYPE_DEFAULT].nr_queues
> > to be set->nr_hw_queues. For multiple mapping, set->nr_hw_queues should
> > be sum of each mapping's nr_queue.
> 
> That's how it should work but that doesn't match what I found in the kernel
> tree. Here is an example of a .map_queues() implementation that depends on
> .nr_queues being set before it is called:
> 
> static int scsi_map_queues(struct blk_mq_tag_set *set)
> {
> 	struct Scsi_Host *shost = container_of(set, struct Scsi_Host,
> 					       tag_set);
> 
> 	if (shost->hostt->map_queues)
> 		return shost->hostt->map_queues(shost);
> 	return blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]);
> }
> 
> If shost->hostt->map_queues == NULL, the above function only works correctly
> if .nr_queues is set before this function is called. Additionally,
> scsi_map_queues() may call e.g. the following function:
> 
> static int qla2xxx_map_queues(struct Scsi_Host *shost)
> {
> 	int rc;
> 	scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata;
> 	struct blk_mq_queue_map *qmap =
> 		&shost->tag_set.map[HCTX_TYPE_DEFAULT];
> 
> 	if (USER_CTRL_IRQ(vha->hw) || !vha->hw->mqiobase)
> 		rc = blk_mq_map_queues(qmap);
> 	else
> 		rc = blk_mq_pci_map_queues(qmap, vha->hw->pdev,
> 			vha->irq_offset);
> 	return rc;
> }
> 
> Both blk_mq_map_queues() and blk_mq_pci_map_queues() assume that
> blk_mq_queue_map.nr_queues is set before these functions are called.

Actually, I suggested to do the following way:

if (set->nr_maps == 1)
	set->map[HCTX_TYPE_DEFAULT].nr_queues = set->nr_hw_queues;

then people won't be confused wrt. relation between set->nr_hw_queues
and .nr_queues of each mapping.

Thanks, 
Ming


  reply	other threads:[~2020-02-20 20:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20  2:44 [PATCH v2 0/8] Eight patches related to changing the number of hardware queues Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 1/8] blk-mq: Fix a comment in include/linux/blk-mq.h Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 2/8] blk-mq: Keep set->nr_hw_queues and set->map[].nr_queues in sync Bart Van Assche
2020-02-20 10:05   ` Ming Lei
2020-02-20 16:14     ` Bart Van Assche
2020-02-20 20:47       ` Ming Lei [this message]
2020-02-21  2:50         ` Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 3/8] blk-mq: Fix a recently introduced regression in blk_mq_realloc_hw_ctxs() Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 4/8] null_blk: Suppress an UBSAN complaint triggered when setting 'memory_backed' Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 5/8] null_blk: Fix changing the number of hardware queues Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 6/8] null_blk: Fix the null_add_dev() error path Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 7/8] null_blk: Handle null_add_dev() failures properly Bart Van Assche
2020-02-20  2:44 ` [PATCH v2 8/8] null_blk: Add support for init_hctx() fault injection 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=20200220204713.GB28199@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.