From: Shradha Gupta <shradhagupta@linux.microsoft.com>
To: Dexuan Cui <decui@microsoft.com>, Wei Liu <wei.liu@kernel.org>,
Haiyang Zhang <haiyangz@microsoft.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Konstantin Taranov <kotaranov@microsoft.com>,
Simon Horman <horms@kernel.org>,
Leon Romanovsky <leon@kernel.org>,
Maxim Levitsky <mlevitsk@redhat.com>,
Erni Sri Satya Vennela <ernis@linux.microsoft.com>,
Peter Zijlstra <peterz@infradead.org>,
Michael Kelley <mhklinux@outlook.com>
Cc: "Shradha Gupta" <shradhagupta@linux.microsoft.com>,
linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, "Nipun Gupta" <nipun.gupta@amd.com>,
"Yury Norov" <yury.norov@gmail.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Jonathan Cameron" <Jonathan.Cameron@huwei.com>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Kevin Tian" <kevin.tian@intel.com>,
"Long Li" <longli@microsoft.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Rob Herring" <robh@kernel.org>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Krzysztof Wilczy�~Dski" <kw@linux.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
"Paul Rosswurm" <paulros@microsoft.com>,
"Shradha Gupta" <shradhagupta@microsoft.com>
Subject: [PATCH v4 4/5] net: mana: Allow irq_setup() to skip cpus for affinity
Date: Tue, 27 May 2025 08:58:44 -0700 [thread overview]
Message-ID: <1748361524-25653-1-git-send-email-shradhagupta@linux.microsoft.com> (raw)
In-Reply-To: <1748361453-25096-1-git-send-email-shradhagupta@linux.microsoft.com>
In order to prepare the MANA driver to allocate the MSI-X IRQs
dynamically, we need to enhance irq_setup() to allow skipping
affinitizing IRQs to the first CPU sibling group.
This would be for cases when the number of IRQs is less than or equal
to the number of online CPUs. In such cases for dynamically added IRQs
the first CPU sibling group would already be affinitized with HWC IRQ.
Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
---
Changes in v4
* fix commit description
* avoided using next_cpumask: label in the irq_setup()
---
drivers/net/ethernet/microsoft/mana/gdma_main.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index f9e8d4d1ba3a..763a548c4a2b 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -1329,7 +1329,8 @@ void mana_gd_free_res_map(struct gdma_resource *r)
* do the same thing.
*/
-static int irq_setup(unsigned int *irqs, unsigned int len, int node)
+static int irq_setup(unsigned int *irqs, unsigned int len, int node,
+ bool skip_first_cpu)
{
const struct cpumask *next, *prev = cpu_none_mask;
cpumask_var_t cpus __free(free_cpumask_var);
@@ -1344,11 +1345,18 @@ static int irq_setup(unsigned int *irqs, unsigned int len, int node)
while (weight > 0) {
cpumask_andnot(cpus, next, prev);
for_each_cpu(cpu, cpus) {
+ cpumask_andnot(cpus, cpus, topology_sibling_cpumask(cpu));
+ --weight;
+
+ if (unlikely(skip_first_cpu)) {
+ skip_first_cpu = false;
+ continue;
+ }
+
if (len-- == 0)
goto done;
+
irq_set_affinity_and_hint(*irqs++, topology_sibling_cpumask(cpu));
- cpumask_andnot(cpus, cpus, topology_sibling_cpumask(cpu));
- --weight;
}
}
prev = next;
@@ -1444,7 +1452,7 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev)
}
}
- err = irq_setup(irqs, (nvec - start_irq_index), gc->numa_node);
+ err = irq_setup(irqs, nvec - start_irq_index, gc->numa_node, false);
if (err)
goto free_irq;
--
2.34.1
next prev parent reply other threads:[~2025-05-27 15:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 15:57 [PATCH v4 0/5] Allow dyn MSI-X vector allocation of MANA Shradha Gupta
2025-05-27 15:57 ` [PATCH v4 1/5] PCI/MSI: Export pci_msix_prepare_desc() for dynamic MSI-X allocations Shradha Gupta
2025-05-29 3:46 ` Saurabh Singh Sengar
2025-05-27 15:58 ` [PATCH v4 2/5] PCI: hv: Allow dynamic MSI-X vector allocation Shradha Gupta
2025-05-29 3:46 ` Saurabh Singh Sengar
2025-05-27 15:58 ` [PATCH v4 3/5] net: mana: explain irq_setup() algorithm Shradha Gupta
2025-05-27 19:10 ` Yury Norov
2025-05-29 13:15 ` Shradha Gupta
2025-05-27 15:58 ` Shradha Gupta [this message]
2025-05-27 15:59 ` [PATCH v4 5/5] net: mana: Allocate MSI-X vectors dynamically Shradha Gupta
2025-05-28 8:16 ` Saurabh Singh Sengar
2025-05-29 13:17 ` Shradha Gupta
2025-05-28 18:52 ` Simon Horman
2025-05-29 13:18 ` Shradha Gupta
2025-05-29 3:45 ` Saurabh Singh Sengar
2025-05-29 13:20 ` Shradha Gupta
2025-05-28 18:55 ` [PATCH v4 0/5] Allow dyn MSI-X vector allocation of MANA Simon Horman
2025-05-29 13:28 ` Shradha Gupta
2025-05-30 18:07 ` Simon Horman
2025-06-03 4:15 ` Shradha Gupta
2025-06-01 14:53 ` Zhu Yanjun
2025-06-03 4:17 ` Shradha Gupta
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=1748361524-25653-1-git-send-email-shradhagupta@linux.microsoft.com \
--to=shradhagupta@linux.microsoft.com \
--cc=Jonathan.Cameron@huwei.com \
--cc=andrew+netdev@lunn.ch \
--cc=anna-maria@linutronix.de \
--cc=bhelgaas@google.com \
--cc=davem@davemloft.net \
--cc=decui@microsoft.com \
--cc=edumazet@google.com \
--cc=ernis@linux.microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=horms@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kotaranov@microsoft.com \
--cc=kuba@kernel.org \
--cc=kw@linux.com \
--cc=kys@microsoft.com \
--cc=leon@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=mhklinux@outlook.com \
--cc=mlevitsk@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nipun.gupta@amd.com \
--cc=pabeni@redhat.com \
--cc=paulros@microsoft.com \
--cc=peterz@infradead.org \
--cc=robh@kernel.org \
--cc=shradhagupta@microsoft.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=yury.norov@gmail.com \
/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).