Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1392155pxk; Fri, 25 Sep 2020 13:34:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMgX6xKvrc9xUCu2B+5C8f7FNlSbUn522m/XpQ4PHpYnxzHZov9Ax8dUcYAeCw3ZdgYPjl X-Received: by 2002:a17:906:d94:: with SMTP id m20mr4746862eji.133.1601066099024; Fri, 25 Sep 2020 13:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601066099; cv=none; d=google.com; s=arc-20160816; b=sJxY0fYQuW4kvROyZj07J2sdGFuIUetz+TusDiAHbEcZ8JwlkmpL3r5ej5Eaau2iqi HXurm/+StPFm4lYKITLTpemRq6kqEfZG28C7VDesLMttSk3N0IZvEM/cqDA75QaMnzc1 nl9Ka7wtpaBcoVWzIt4ymKJRz8ZKdtOGg1GNvqQkwWriAJLn2FtgTAocbCyInjL4jDHI vm0udlM1Ka3nBy6EzlQnpKpPXkCP+4TC26swkda6hjb1PQTxXYg94xWlEtpVu5wPK62h gQlBAEajB+PD82evY5jBkcKmiPRAO3Eb7m0+awo3a2oYJ4hdPh9m7iTqSQJt5nJYqqLK xDqg== 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=CHBAKjKraZ39+AI16pPDtyjgGl0qo95YBi0WVfL33Mw=; b=MRAuti99T36QMmAme/lLWOd5EqKPBkMoQyOpB5ijb9vYOzAMrPGM8+6ki3k0fO+sqC hoWX/1BIVmDhRYz1UgkSzsb+kS0pw4y61tf60NIoD8Qb1ysD6oFlWGffX1FRlLjc6OW4 yQBKKF71jbhCXu6EcmafN4kHBlPDlXnJ12abWPcrY7gr1Pu4qUHMMtnpdeG5CwF+lL7y UYxnYiXXwfDk97DVGekupERjaCY36k60BMQWnm5hPGSnAHdXBdGn5Yq0qyUFDFQKLaqB V2ut18iWDVwC49IHc5e/qG0JCn8yTn034UBtFG1RZaRsakTZXT4fWu8wiTm1jOdcxqQd e52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IP0ezM9H; 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 dc4si2606102ejb.526.2020.09.25.13.34.36; Fri, 25 Sep 2020 13:34:59 -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=IP0ezM9H; 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 S1729030AbgIYUda (ORCPT + 99 others); Fri, 25 Sep 2020 16:33:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:44042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbgIYUXK (ORCPT ); Fri, 25 Sep 2020 16:23:10 -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 A06632086A; Fri, 25 Sep 2020 20:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601065390; bh=aAD9nZhpTjqZoeBXICyqCwtEuwV7OkIfU4T3ggIlc10=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=IP0ezM9Hn3/SEbnXK8TrCpPU7kRkkU4GntqwiLY9scgvlBhza9gfYs4fDlR+UTw5E 7meYkbHytKkecaciibT3kRIDoZvHZ5bhjtn7r5lSZ6JMAEMa0Fxet1Bn5KanI+X0A2 EvYfgyhUyriYf30OHWamCVzv44rklq3Ah2VB2B4o= Date: Fri, 25 Sep 2020 15:23:07 -0500 From: Bjorn Helgaas To: Nitesh Narayan Lal 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, hch@infradead.org, 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 v3 4/4] PCI: Limit pci_alloc_irq_vectors() to housekeeping CPUs Message-ID: <20200925202307.GA2456332@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200925182654.224004-5-nitesh@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 02:26:54PM -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 > --- > include/linux/pci.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 835530605c0d..a7b10240b778 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -1797,6 +1798,22 @@ static inline int > pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, > unsigned int max_vecs, unsigned int flags) > { > + unsigned int hk_cpus; > + > + hk_cpus = housekeeping_num_online_cpus(HK_FLAG_MANAGED_IRQ); Add blank line here before the block comment. > + /* > + * 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; > + } It seems like you'd want to do this inside pci_alloc_irq_vectors_affinity() since that's an exported interface, and drivers that use it will bypass the limiting you're doing here. > return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, > NULL); > } > -- > 2.18.2 >