Skip to content

Commit 08657a4

Browse files
author
Maxim Levitsky
committed
net: mana: explain irq_setup() algorithm
JIRA: https://issues.redhat.com/browse/RHEL-109580 commit 4607617 Author: Yury Norov <yury.norov@gmail.com> Date: Wed Jun 11 07:10:29 2025 -0700 net: mana: explain irq_setup() algorithm Commit 91bfe21 ("net: mana: add a function to spread IRQs per CPUs") added the irq_setup() function that distributes IRQs on CPUs according to a tricky heuristic. The corresponding commit message explains the heuristic. Duplicate it in the source code to make available for readers without digging git in history. Also, add more detailed explanation about how the heuristics is implemented. Signed-off-by: Yury Norov <yury.norov@gmail.com> Signed-off-by: Shradha Gupta <shradhagupta@linux.microsoft.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
1 parent ccffa58 commit 08657a4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

drivers/net/ethernet/microsoft/mana/gdma_main.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,47 @@ void mana_gd_free_res_map(struct gdma_resource *r)
13671367
r->size = 0;
13681368
}
13691369

1370+
/*
1371+
* Spread on CPUs with the following heuristics:
1372+
*
1373+
* 1. No more than one IRQ per CPU, if possible;
1374+
* 2. NUMA locality is the second priority;
1375+
* 3. Sibling dislocality is the last priority.
1376+
*
1377+
* Let's consider this topology:
1378+
*
1379+
* Node 0 1
1380+
* Core 0 1 2 3
1381+
* CPU 0 1 2 3 4 5 6 7
1382+
*
1383+
* The most performant IRQ distribution based on the above topology
1384+
* and heuristics may look like this:
1385+
*
1386+
* IRQ Nodes Cores CPUs
1387+
* 0 1 0 0-1
1388+
* 1 1 1 2-3
1389+
* 2 1 0 0-1
1390+
* 3 1 1 2-3
1391+
* 4 2 2 4-5
1392+
* 5 2 3 6-7
1393+
* 6 2 2 4-5
1394+
* 7 2 3 6-7
1395+
*
1396+
* The heuristics is implemented as follows.
1397+
*
1398+
* The outer for_each() loop resets the 'weight' to the actual number
1399+
* of CPUs in the hop. Then inner for_each() loop decrements it by the
1400+
* number of sibling groups (cores) while assigning first set of IRQs
1401+
* to each group. IRQs 0 and 1 above are distributed this way.
1402+
*
1403+
* Now, because NUMA locality is more important, we should walk the
1404+
* same set of siblings and assign 2nd set of IRQs (2 and 3), and it's
1405+
* implemented by the medium while() loop. We do like this unless the
1406+
* number of IRQs assigned on this hop will not become equal to number
1407+
* of CPUs in the hop (weight == 0). Then we switch to the next hop and
1408+
* do the same thing.
1409+
*/
1410+
13701411
static int irq_setup(unsigned int *irqs, unsigned int len, int node)
13711412
{
13721413
const struct cpumask *next, *prev = cpu_none_mask;

0 commit comments

Comments
 (0)