Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5070050imd; Tue, 30 Oct 2018 11:29:11 -0700 (PDT) X-Google-Smtp-Source: AJdET5f086ttm4Mdj995W5IUIdjiN8S5dzoB/8JTx3sr0+rS153qu7LbB+QIhfTomtuWzuXKtyUJ X-Received: by 2002:a63:cd45:: with SMTP id a5-v6mr19513209pgj.43.1540924151874; Tue, 30 Oct 2018 11:29:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540924151; cv=none; d=google.com; s=arc-20160816; b=EPLjvaqTmo4Cj5VWCCNKCm/TF7PU25WEibgGvaxMdCyxaE7Jnbu+B4n4UjVlp3GICZ DBs0IIzmmwoHwLLiAAB0BKWWkP18uyiVko4idsywznMuA67yiqzMV/sH5Cx6eyDuGvzb smyBxbyay08yUvtQbLNqDmIGuFN3fzTQwxy/7nL5ehsUPHNzw0IphcQoD+57MWr0rKgC 8cQxk7KW3yHjYiLI8cgceouqwIO2nkTt4SOcFWamKA3AqOYB3dIiiNMBxMoRNuKpnEVD j5iMir+VUMabERDrYQWqLq6hLEqkUejYKNL/K2TUbvDGREJ5Aix7B3iUXxH44ORCIffM 7Ofg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=fXZuj2PUkEBxkp0mB4ciBomhyvPqdg/88irWDb8Hpos=; b=PJvX+HCNYrb92k42zMfVZAg4Zro/lnjNz5bOchYQqPs/EgwtVx7rSyMdYuHNpkkSjL dk3z6bgqCURskz42C1FMuxzWuAsO7k8gBZE3iL2ajYBJMaA9cR9hFW+PhhIDqx2DW/Il fzQJfe/Lcvxhpl3zZgoTZpEdOysUUZUnYZLwAomv/0CjA0GOb6gtu9JQqPx9JnLCFJd0 wayA1yiC0iHyipei2rE+1QpF187bQhmklhn9BJlrn8pmhl3z3Nkai+9RRvSxYw7DlTAq 7Wvm3Wn1sFdeb6MEsHt9e3TzHC+OxOvs8fJnWQXps6UgltXJMEakFbCW/oAYCE1M5nfo ZyBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=XhjVdugX; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23-v6si15702461pfu.2.2018.10.30.11.28.54; Tue, 30 Oct 2018 11:29:11 -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; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=XhjVdugX; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbeJaChk (ORCPT + 99 others); Tue, 30 Oct 2018 22:37:40 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:37645 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727732AbeJaChk (ORCPT ); Tue, 30 Oct 2018 22:37:40 -0400 Received: by mail-it1-f193.google.com with SMTP id e74-v6so14758793ita.2 for ; Tue, 30 Oct 2018 10:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=fXZuj2PUkEBxkp0mB4ciBomhyvPqdg/88irWDb8Hpos=; b=XhjVdugXFhDtF7NVsobCj4Dp3DRmT9Ded536s7MNF9UFE06ZdAS9me0jqEK9dgvpfy V5lhGafLZsE4KC3TIwWK+phhCLuzhf8CQFlAK/KyUtxvznP6jUkFlUh58Jg6EVjm4h0/ rhawsaHobv+5WwHfJtn09GpJMwZuYmCIdk4Ddut0fT99X8vwlgSsoJgutqjkNuhwTcof wInaiEG0ucjRRZzQOGyuYU9expXiXhgVWWsfHkNpjMySOYJGme02kJCPbOQH6Hxb5MHj N+Xke9e7WOuODtXCPjbc2Qd1m4scGEDd4FEAUG3IB1f2b2PZONxNyYW6QKmk7UJYF85s a/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fXZuj2PUkEBxkp0mB4ciBomhyvPqdg/88irWDb8Hpos=; b=ZvvBB2WQ6kEycvrsF+LbT+7lvaWJJYY91pD2lyZD589MQv8jP/X2ZODqbOt8yR9qeS iPPYkKJXyKExfolVqah7mM/GGih+wBAoTYeOnLNYR5nmBEAT8ACrxcNXxn38jBrnaRkZ 8xmpJG3wL034OjL2/ompP5YwTt9a1qRGK5saEc8eOV+ZMQ8jNOPDPer8iyRLUJ9S4Lx3 Uco7tDd+uj5iVrD0vHJNpn2r4tWcTBOsKJRzoGJShX31xf9iXzj6bMYAiFk1AukpMUn1 f6it2p1t6xEQoLXc9qYPSxFnCBwfZcKHEoN+mqaFIODTktMHsUWoeH5o6W57LBaMyLUJ Ly/w== X-Gm-Message-State: AGRZ1gL45ZVoIm25hYr2XLeJP7Udzrof3xcTRspFJMXrafNU5V3jFCOM 9evyshUWt7c9giVRpuWr1ED6umMWI4g= X-Received: by 2002:a24:d086:: with SMTP id m128-v6mr2007777itg.13.1540921393951; Tue, 30 Oct 2018 10:43:13 -0700 (PDT) Received: from [192.168.1.56] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id q185-v6sm6673351itc.30.2018.10.30.10.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 10:43:12 -0700 (PDT) Subject: Re: [PATCH 11/14] irq: add support for allocating (and affinitizing) sets of IRQs From: Jens Axboe To: Thomas Gleixner Cc: Keith Busch , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org 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> <20181030160242.GD18906@localhost.localdomain> <27c1017a-9560-80cb-038d-f64727a162c3@kernel.dk> Message-ID: Date: Tue, 30 Oct 2018 11:43:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/30/18 11:34 AM, Jens Axboe wrote: > On 10/30/18 11:25 AM, Thomas Gleixner wrote: >> Jens, >> >> On Tue, 30 Oct 2018, Jens Axboe wrote: >>> On 10/30/18 10:02 AM, Keith Busch wrote: >>>> 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: >>> >>> OK, now I hear what you are saying. And you are right, the callers needs >>> to provide minvec == maxvec for sets, and then have a loop around that >>> to adjust as needed. >> >> But then we should enforce it in the core code, right? > > Yes, I was going to ask you if you want a followup patch for that, or > an updated version of the original? Here's an incremental, I'm going to fold this into the original unless I hear otherwise. diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index af24ed50a245..e6c6e10b9ceb 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1036,6 +1036,13 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, if (maxvec < minvec) return -ERANGE; + /* + * If the caller is passing in sets, we can't support a range of + * vectors. The caller needs to handle that. + */ + if (affd->nr_sets && minvec != maxvec) + return -EINVAL; + if (WARN_ON_ONCE(dev->msi_enabled)) return -EINVAL; @@ -1087,6 +1094,13 @@ static int __pci_enable_msix_range(struct pci_dev *dev, if (maxvec < minvec) return -ERANGE; + /* + * If the caller is passing in sets, we can't support a range of + * supported vectors. The caller needs to handle that. + */ + if (affd->nr_sets && minvec != maxvec) + return -EINVAL; + if (WARN_ON_ONCE(dev->msix_enabled)) return -EINVAL; -- Jens Axboe