Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp33801ima; Thu, 25 Oct 2018 14:58:18 -0700 (PDT) X-Google-Smtp-Source: AJdET5fXUu1Gbqu4U0ohMbPjXGXzpg4LQa05nVVqkYbPkhl6Vu9H8GZBc4RnjRLUKaKqk7N85YGR X-Received: by 2002:a62:f541:: with SMTP id n62-v6mr903767pfh.59.1540504697999; Thu, 25 Oct 2018 14:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540504697; cv=none; d=google.com; s=arc-20160816; b=BeirTlDa5fT1gigfsjWoL9KfQOROg8SNU6SWacNUv7lufjXXmIpQyM57zogR9XT9Ay ZAjcRREUxvjW5EVBop9CU3I+sd0/32qUeQq5Ldwm98Red7rMTgYzWjxwpFTkU75iN6FF JKvHR6nEN8SxdniLeZZSSuVWClJnYC2ngequ2h5kGaGuXXQ9m07EOmJPW4UCSMTGnTZZ nY9Or0rgN8pWoR5UrC6Rd6EJaxaIkdsaQQONc3/Ye5+Ei2QpUIl25yvJkTgeDpAqf3qT II7Gf//hfMCNqP/H1PAQR8l3AqMM/vk64OLASlWuwiEWDL9nRYngz0VRZPj/H3CtKuWY O+tw== 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=EX8K456m/o7iuemv4uyZdRRH1yeiTY+eeNmvpeGFPs4=; b=JHgQiRX9uNoWLzUjwuCrT5WD41QZBi2tOLpRZFzYgg/czEOru7P1pfdB7eRLVPY9KJ D51bDT6PVHxKVuDk8Qh2u1wYoy8mMLJ+5E1WLXsKH53Rjob4o2onEd34lWiSvttqPeAh esyQXZKZlzslr2E41fDdDrKK94NzS6ZVil9jZ8TfW9sm6JqxDBuHfbD20VZVC4oE4JEu rw2fm10F3+KgOGlnI4i7SSlfnUCuM6k1UV8bXNhDvU14R724lxDWex20zTyRMC4EGvsr uoiYmo5u4E5xolzzymZsn/tn80qaPHrLqdnjXjQuEWR1+zP3iImQrTYm+Qn1yUG8Vabq 7+7g== 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 b6-v6si8922068plr.267.2018.10.25.14.57.51; Thu, 25 Oct 2018 14:58:17 -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 S1727684AbeJZG3K (ORCPT + 99 others); Fri, 26 Oct 2018 02:29:10 -0400 Received: from mga18.intel.com ([134.134.136.126]:54492 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbeJZG3K (ORCPT ); Fri, 26 Oct 2018 02:29:10 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 14:54:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,425,1534834800"; d="scan'208";a="268837411" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga005.jf.intel.com with ESMTP; 25 Oct 2018 14:54:44 -0700 Date: Thu, 25 Oct 2018 15:52:13 -0600 From: Keith Busch To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/14] irq: add support for allocating (and affinitizing) sets of IRQs Message-ID: <20181025215213.GA8141@localhost.localdomain> References: <20181025211626.12692-1-axboe@kernel.dk> <20181025211626.12692-12-axboe@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181025211626.12692-12-axboe@kernel.dk> 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 Thu, Oct 25, 2018 at 03:16:23PM -0600, Jens Axboe wrote: > A driver may have a need to allocate multiple sets of MSI/MSI-X > interrupts, and have them appropriately affinitized. Add support for > defining a number of sets in the irq_affinity structure, of varying > sizes, and get each set affinitized correctly across the machine. <> > @@ -258,13 +272,18 @@ int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity > { > int resv = affd->pre_vectors + affd->post_vectors; > int vecs = maxvec - resv; > + int i, set_vecs; > int ret; > > if (resv > minvec) > return 0; > > get_online_cpus(); > - ret = min_t(int, cpumask_weight(cpu_possible_mask), vecs) + resv; > + ret = min_t(int, cpumask_weight(cpu_possible_mask), vecs); > put_online_cpus(); > - return ret; > + > + for (i = 0, set_vecs = 0; i < affd->nr_sets; i++) > + set_vecs += affd->sets[i]; > + > + return resv + max(ret, set_vecs); > } This is looking pretty good, but we may risk getting into an infinite loop in __pci_enable_msix_range() if we're requesting too many vectors in a set: the above code may continue returning set_vecs, overriding the reduced nvec that pci requested, and pci msix initialization will continue to fail because it is repeatedly requesting to activate the same vector count that failed before.