Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3394302pxk; Mon, 28 Sep 2020 16:57:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySBqITgXtJr3FvO7fKIoY+FXcfrh3hPcOxnZvISo/e0cWzaTuXNKHEZq0ou3v6lC2mtgmn X-Received: by 2002:a17:906:f8d2:: with SMTP id lh18mr1272887ejb.44.1601337469127; Mon, 28 Sep 2020 16:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601337469; cv=none; d=google.com; s=arc-20160816; b=K1iJAyGLSQVYNX7MIFAg6gLcck2ft9TRqkjNmBTA9MnntSjNS9o/0WstKJQ8Wqs0A5 PBhAMV3F0F2+SUIMhoma+urcdujnPBNPfGD5qAiIjDS1N+EO4K3U/9whs9Pmz9OTq4Kr MGHGGb5WAf6aIHAGIthuxxItYTLfB6hHGtOvH3qq6eyK9aJtwzHqCq3vZP8svQrL63Dr sVmRirfGa+eC/J75n7HsGSuerTLjlvdLQGwbqGv2di5w90YyaXqg9Lfe2r0gfTW2qraS 4s7sMly0lzissw7rc4zuB9idnZmiiDWAjm6Sdw+uqd0W3xdyoooedWf3QHY8vTJKbtIp v7ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=o8CubHWTNb3lfFQCzeuRmbxzUJJP5UOrwqdUb+2xnbY=; b=SdBoUph//aY9dBOtZ5fg12IyZX8xilevg/aDFrFC1d2LFf+ZPKwr+nNCk04DFIudYj w3qggmKZMl4HhUt4ySsQUIFJLb3keLEn20AB+5QYvdEx3m2hSSpL2OO6ZS3sHtbs98IW dbg1aXBF+pyiYnFfnNK6Ny4oomX9ckaep8Ci01hYwVh0WBzxgRZra45YJtevPGi0090i 62VOP3Ox+zcf0iHmMDtrXLTXrbekV0T5Boz6xl5brO6VUeW80y04Uf8UrILsSCNqC2ul b1/Lg4FSzd0rFjAUbBQth4U7OpWucNecSc9g4ueeZzq8OVdUsnpHn75XYnSrw+cj6ZoY 2Vlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TPpxBphv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si1548557edv.189.2020.09.28.16.57.25; Mon, 28 Sep 2020 16:57:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TPpxBphv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727179AbgI1Xzd (ORCPT + 99 others); Mon, 28 Sep 2020 19:55:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:51780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726522AbgI1Xzc (ORCPT ); Mon, 28 Sep 2020 19:55:32 -0400 Received: from localhost (52.sub-72-107-123.myvzw.com [72.107.123.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFCA52083B; Mon, 28 Sep 2020 21:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601330373; bh=0n1xJcdLngQdEbL6h/atc0mGb4YVbGMJlbNqrb3rWc0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=TPpxBphvz+2D9Uwv5VqfQh0wF+3Q/7TSzzgny4d7237sTORHdrdkk58bs1BWlGT6v zx70R2QzsjjCdGSPdGWmHX1ifdjxKDGigQo4yWcs4p9sTTOTpGuvhuao0t38NmeFAX O1xWNs/AwwHQU1IqkaFmk4+tPRE2S87hvWuuckTY= Date: Mon, 28 Sep 2020 16:59:31 -0500 From: Bjorn Helgaas To: Nitesh Narayan Lal , hch@infradead.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, intel-wired-lan@lists.osuosl.org, frederic@kernel.org, mtosatti@redhat.com, sassmann@redhat.com, jesse.brandeburg@intel.com, lihong.yang@intel.com, jeffrey.t.kirsher@intel.com, jacob.e.keller@intel.com, jlelli@redhat.com, bhelgaas@google.com, mike.marciniszyn@intel.com, dennis.dalessandro@intel.com, thomas.lendacky@amd.com, jiri@nvidia.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, lgoncalv@redhat.com Subject: Re: [PATCH v4 4/4] PCI: Limit pci_alloc_irq_vectors() to housekeeping CPUs Message-ID: <20200928215931.GA2499944@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200928183529.471328-5-nitesh@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [to: Christoph in case he has comments, since I think he wrote this code] On Mon, Sep 28, 2020 at 02:35:29PM -0400, Nitesh Narayan Lal wrote: > If we have isolated CPUs dedicated for use by real-time tasks, we try to > move IRQs to housekeeping CPUs from the userspace to reduce latency > overhead on the isolated CPUs. > > If we allocate too many IRQ vectors, moving them all to housekeeping CPUs > may exceed per-CPU vector limits. > > When we have isolated CPUs, limit the number of vectors allocated by > pci_alloc_irq_vectors() to the minimum number required by the driver, or > to one per housekeeping CPU if that is larger. > > Signed-off-by: Nitesh Narayan Lal Acked-by: Bjorn Helgaas > --- > drivers/pci/msi.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c > index 30ae4ffda5c1..8c156867803c 100644 > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > > #include "pci.h" > > @@ -1191,8 +1192,25 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, > struct irq_affinity *affd) > { > struct irq_affinity msi_default_affd = {0}; > + unsigned int hk_cpus; > int nvecs = -ENOSPC; > > + hk_cpus = housekeeping_num_online_cpus(HK_FLAG_MANAGED_IRQ); > + > + /* > + * If we have isolated CPUs for use by real-time tasks, to keep the > + * latency overhead to a minimum, device-specific IRQ vectors are moved > + * to the housekeeping CPUs from the userspace by changing their > + * affinity mask. Limit the vector usage to keep housekeeping CPUs from > + * running out of IRQ vectors. > + */ > + if (hk_cpus < num_online_cpus()) { > + if (hk_cpus < min_vecs) > + max_vecs = min_vecs; > + else if (hk_cpus < max_vecs) > + max_vecs = hk_cpus; > + } > + > if (flags & PCI_IRQ_AFFINITY) { > if (!affd) > affd = &msi_default_affd; > -- > 2.18.2 >