Skip to content

Commit 7ad8135

Browse files
author
Maxim Levitsky
committed
net: mana: explain irq_setup() algorithm
JIRA: https://issues.redhat.com/browse/RHEL-109583 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 94711d3 commit 7ad8135

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
@@ -1368,6 +1368,47 @@ void mana_gd_free_res_map(struct gdma_resource *r)
13681368
r->size = 0;
13691369
}
13701370

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

0 commit comments

Comments
 (0)