Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933384AbcLGWRu (ORCPT ); Wed, 7 Dec 2016 17:17:50 -0500 Received: from mga07.intel.com ([134.134.136.100]:13865 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932339AbcLGWRt (ORCPT ); Wed, 7 Dec 2016 17:17:49 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,315,1477983600"; d="scan'208";a="909855439" Date: Wed, 7 Dec 2016 17:27:46 -0500 From: Keith Busch To: Dan Streetman Cc: Jens Axboe , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Dan Streetman Subject: Re: [PATCH] nvme: create the correct number of queues Message-ID: <20161207222746.GD22478@localhost.localdomain> References: <20161207220326.8461-1-ddstreet@ieee.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161207220326.8461-1-ddstreet@ieee.org> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1700 Lines: 43 On Wed, Dec 07, 2016 at 05:03:26PM -0500, Dan Streetman wrote: > Change nr_io_queues variable name to nr_queues, as it includes not > only the io queues but also the admin queue in its count; and change > the variable name in functions that it is passed into, for clarity. > > Also correct misuses of the nr_queue count: > > In the db_bar_size() function, the calculation added 1 to the > nr_io_queues value to account for the admin queue, but since that's > actually already in the nr_queue count, don't add it. > > In the nvme_setup_io_queues() function when allocating irq vectors, > it considers the minimum number of queues to be 1, but actually 2 > queues are needed; 1 admin queue + at least 1 io queue. > > When setting the device's max_qid (maximum queue index id), it's > currently set to nr_io_queues, but since nr_queues counts all > queues, and because max_qid is 0-based and nr_queues is 1-based, > max_qid must be set to nr_queues - 1. > > Signed-off-by: Dan Streetman > > --- [snip] > static int nvme_setup_io_queues(struct nvme_dev *dev) > { > struct nvme_queue *adminq = dev->queues[0]; > struct pci_dev *pdev = to_pci_dev(dev->dev); > - int result, nr_io_queues, size; > + int result, nr_queues, size; > > - nr_io_queues = num_online_cpus(); > - result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues); > + nr_queues = num_online_cpus(); I'm not sure I follow. If you want to say nr_queues includes the admin queue, the above is incorrect. We want the number of io queues to equal the number of online cpus, so if nr_queues includes the admin, we're off by one. I don't think there's anything wrong with the code as it is, though.