From: Nitesh Narayan Lal <nitesh@redhat.com>
To: Bjorn Helgaas <helgaas@kernel.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, 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
Date: Fri, 25 Sep 2020 17:38:05 -0400 [thread overview]
Message-ID: <256490f0-0762-447c-a7be-0e5a6bb04fc4@redhat.com> (raw)
In-Reply-To: <20200925202307.GA2456332@bjorn-Precision-5520>
[-- Attachment #1.1: Type: text/plain, Size: 2529 bytes --]
On 9/25/20 4:23 PM, Bjorn Helgaas wrote:
> 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 <nitesh@redhat.com>
>> ---
>> 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 <linux/interrupt.h>
>> #include <linux/io.h>
>> #include <linux/resource_ext.h>
>> +#include <linux/sched/isolation.h>
>> #include <uapi/linux/pci.h>
>>
>> #include <linux/pci_ids.h>
>> @@ -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.
Good point, few drivers directly use this.
I took a quick look and it seems I may also have to take the pre and the
post vectors into consideration.
>> return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
>> NULL);
>> }
>> --
>> 2.18.2
>>
--
Nitesh
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-09-25 21:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-25 18:26 [PATCH v3 0/4] isolation: limit msix vectors to housekeeping CPUs Nitesh Narayan Lal
2020-09-25 18:26 ` [PATCH v3 1/4] sched/isolation: API to get number of " Nitesh Narayan Lal
2020-09-25 18:26 ` [PATCH v3 2/4] sched/isolation: Extend nohz_full to isolate managed IRQs Nitesh Narayan Lal
2020-09-25 18:26 ` [PATCH v3 3/4] i40e: Limit msix vectors to housekeeping CPUs Nitesh Narayan Lal
2020-09-25 18:26 ` [PATCH v3 4/4] PCI: Limit pci_alloc_irq_vectors() " Nitesh Narayan Lal
2020-09-25 20:23 ` Bjorn Helgaas
2020-09-25 21:38 ` Nitesh Narayan Lal [this message]
2020-09-25 23:18 ` Nitesh Narayan Lal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=256490f0-0762-447c-a7be-0e5a6bb04fc4@redhat.com \
--to=nitesh@redhat.com \
--cc=bhelgaas@google.com \
--cc=dennis.dalessandro@intel.com \
--cc=frederic@kernel.org \
--cc=hch@infradead.org \
--cc=helgaas@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jesse.brandeburg@intel.com \
--cc=jiri@nvidia.com \
--cc=jlelli@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=lgoncalv@redhat.com \
--cc=lihong.yang@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mike.marciniszyn@intel.com \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=sassmann@redhat.com \
--cc=thomas.lendacky@amd.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).