Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4906939imd; Tue, 30 Oct 2018 09:06:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5dnk9lGBPFMmlO9F/acKwWudILpssgQbB5oGAw8TNiY8QNZGArpKoT7xVHWZKmfe0IJEDDV X-Received: by 2002:a63:cf0e:: with SMTP id j14-v6mr18647222pgg.195.1540915588570; Tue, 30 Oct 2018 09:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540915588; cv=none; d=google.com; s=arc-20160816; b=ad1KH4AFvPLJQ/mqXcoWo12nTEejg7RkhRlnDlzEMGxqmwekJXAz9ptHXs7SsXNN3h 96AOzuAxkZpbKTo61h5vQd+Q2hJqq0/c1PZxmD+bntCrarfv8YESLo3Kg2V/QQNzRubF sS8IPCD6jxM3wGkVUDcp7jHBXfeeHF4JetrFYXpqydi+OWBogyJKMpn5pOqDLo75JWtS 6eNkw3Q5Wu8I5NAbQN/CJqDIUQPTj7obmPWJWGg6Lz05Ed8mTbVBRMvh490RaExS8pgh 7I0kd4i+5f1g3kzrohYNJmyVqgrCQnjWI68GOF8mOmBYWbbyvl6l+1rndCLFYZkODzNj 6ZcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hR6DZYtdN99Bvk97kGeG3yxAhs4TMlyvnIMsftG8zjI=; b=Qv3kLDRazoidW5OgeK4QzU9hjDYBODaxpeKFGi5WeO7FmoBfV7hJAQLSyC+/wiyelD TYUKMCKP1jGDS+60TVkX+KtOSsncvpkLRonHUs/uqNzFC2vIe7SRkF+5B9YtD794x5qx S4waCfH52l8KyXE8mu8EBWEn7NLpA0HZiiVdIRYO40aL6oZKSTOmpPK4yx0Yy0WQiEJH ZwEGOldmOr/XBIFjUk0mUsk0rS2ISDOGUmz7/RXmsXxJtdkKEDe8Z9gIC+D6vsVDRr/R +Xq+ZZCss21/azaJYpfzS5Oyt69v1VZ9lJ0GnS4Bc2QPm1rngz8u1uRs8skSzrQtQvB0 +6/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10-v6si22748324pla.251.2018.10.30.09.06.09; Tue, 30 Oct 2018 09:06:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727710AbeJaA7J (ORCPT + 99 others); Tue, 30 Oct 2018 20:59:09 -0400 Received: from mga09.intel.com ([134.134.136.24]:4372 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeJaA7J (ORCPT ); Tue, 30 Oct 2018 20:59:09 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 09:05:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,445,1534834800"; d="scan'208";a="96294721" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga003.jf.intel.com with ESMTP; 30 Oct 2018 09:05:04 -0700 Date: Tue, 30 Oct 2018 10:02:42 -0600 From: Keith Busch To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH 11/14] irq: add support for allocating (and affinitizing) sets of IRQs Message-ID: <20181030160242.GD18906@localhost.localdomain> References: <20181029163738.10172-1-axboe@kernel.dk> <20181029163738.10172-12-axboe@kernel.dk> <20181030142601.GA18906@localhost.localdomain> <20181030144527.GB18906@localhost.localdomain> <46dbcbcd-799f-9970-a68f-de7e96b1a6bb@kernel.dk> <20181030150840.GC18906@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 09:18:05AM -0600, Jens Axboe wrote: > On 10/30/18 9:08 AM, Keith Busch wrote: > > On Tue, Oct 30, 2018 at 08:53:37AM -0600, Jens Axboe wrote: > >> The sum of the set can't exceed the nvecs passed in, the nvecs passed in > >> should be the less than or equal to nvecs. Granted this isn't enforced, > >> and perhaps that should be the case. > > > > That should at least initially be true for a proper functioning > > driver. It's not enforced as you mentioned, but that's only related to > > the issue I'm referring to. > > > > The problem is pci_alloc_irq_vectors_affinity() takes a range, min_vecs > > and max_vecs, but a range of allowable vector allocations doesn't make > > sense when using sets. > > I feel like we're going in circles here, not sure what you feel the > issue is now? The range is fine, whoever uses sets will need to adjust > their sets based on what pci_alloc_irq_vectors_affinity() returns, > if it didn't return the passed in desired max. Sorry, let me to try again. pci_alloc_irq_vectors_affinity() starts at the provided max_vecs. If that doesn't work, it will iterate down to min_vecs without returning to the caller. The caller doesn't have a chance to adjust its sets between iterations when you provide a range. The 'masks' overrun problem happens if the caller provides min_vecs as a smaller value than the sum of the set (plus any reserved). If it's up to the caller to ensure that doesn't happen, then min and max must both be the same value, and that value must also be the same as the set sum + reserved vectors. The range just becomes redundant since it is already bounded by the set. Using the nvme example, it would need something like this to prevent the 'masks' overrun: --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index a8747b956e43..625eff570eaa 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2120,7 +2120,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) * setting up the full range we need. */ pci_free_irq_vectors(pdev); - result = pci_alloc_irq_vectors_affinity(pdev, 1, nr_io_queues, + result = pci_alloc_irq_vectors_affinity(pdev, nr_io_queues, nr_io_queues, PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY, &affd); if (result <= 0) return -EIO; --