Skip to content

Commit b182566

Browse files
authored
Merge pull request ArmDeveloperEcosystem#2271 from kielfriedt/irq
IRQ tuning guide
2 parents ec5eeef + 9d44738 commit b182566

File tree

5 files changed

+202
-0
lines changed

5 files changed

+202
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Learn about the impact of NIC IRQs and patterns on cloud
3+
4+
draft: true
5+
cascade:
6+
draft: true
7+
8+
minutes_to_complete: 20
9+
10+
who_is_this_for: This is anyone interested in understanding how IRQ patterns can enhance networking workload performance on cloud.
11+
12+
13+
learning_objectives:
14+
- Analyze the current IRQ layout on the machine.
15+
- Test different options and patterns to improve performance.
16+
17+
prerequisites:
18+
- An Arm computer running Linux installed.
19+
- Some familiarity with running Linux command line commands.
20+
21+
author: Kiel Friedt
22+
23+
### Tags
24+
skilllevels: Introductory
25+
subjects: Performance and Architecture
26+
armips:
27+
- AArch64
28+
tools_software_languages:
29+
30+
operatingsystems:
31+
- Linux
32+
33+
34+
further_reading:
35+
- resource:
36+
title: Perf for Linux on Arm (LinuxPerf)
37+
link: https://learn.arm.com/install-guides/perf/
38+
type: website
39+
40+
### FIXED, DO NOT MODIFY
41+
# ================================================================================
42+
weight: 1 # _index.md always has weight of 1 to order correctly
43+
layout: "learningpathall" # All files under learning paths have this same wrapper
44+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
45+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: checking IRQs
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
First you should run the following command to identify all IRQs on the system. Identify the NIC IRQs and adjust the system by experirmenting and seeing how performance improves.
10+
11+
```
12+
grep '' /proc/irq/*/smp_affinity_list | while IFS=: read path cpus; do
13+
irq=$(basename $(dirname $path))
14+
device=$(grep -E "^ *$irq:" /proc/interrupts | awk '{print $NF}')
15+
printf "IRQ %s -> CPUs %s -> Device %s\n" "$irq" "$cpus" "$device"
16+
done
17+
```
18+
19+
20+
{{% notice Note %}}
21+
output should look similar to this:
22+
```
23+
IRQ 104 -> CPUs 12 -> Device ens34-Tx-Rx-5
24+
IRQ 105 -> CPUs 5 -> Device ens34-Tx-Rx-6
25+
IRQ 106 -> CPUs 10 -> Device ens34-Tx-Rx-7
26+
IRQ 11 -> CPUs 0-15 -> Device
27+
IRQ 14 -> CPUs 0-15 -> Device ttyS0
28+
IRQ 17 -> CPUs 0-15 -> Device ACPI:Ged
29+
IRQ 19 -> CPUs 0-15 -> Device ACPI:Ged
30+
IRQ 2 -> CPUs 0-15 -> Device
31+
IRQ 20 -> CPUs 0-15 -> Device ACPI:Ged
32+
IRQ 21 -> CPUs 0-15 -> Device ACPI:Ged
33+
...
34+
IRQ 26 -> CPUs 0-15 -> Device ACPI:Ged
35+
```
36+
{{% /notice %}}
37+
38+
Now, you may notice that the NIC IRQs are assigned to a duplicate CPU by default.
39+
40+
like this example:
41+
```
42+
IRQ 100 -> CPUs 2 -> Device ens34-Tx-Rx-1
43+
IRQ 101 -> CPUs 12 -> Device ens34-Tx-Rx-2
44+
IRQ 102 -> CPUs 14 -> Device ens34-Tx-Rx-3
45+
IRQ 103 -> CPUs 9 -> Device ens34-Tx-Rx-4
46+
IRQ 104 -> CPUs 12 -> Device ens34-Tx-Rx-5
47+
IRQ 105 -> CPUs 5 -> Device ens34-Tx-Rx-6
48+
IRQ 106 -> CPUs 10 -> Device ens34-Tx-Rx-7
49+
```
50+
This can potential hurt performance. Suggestions and patterns to expertiment with will be on the next step.
51+
52+
### reset
53+
54+
If performance reduces, you can return the IRQs back to default using the following commands.
55+
56+
```
57+
sudo systemctl unmask irqbalance
58+
sudo systemctl enable --now irqbalance
59+
```
60+
61+
or you can run the following
62+
63+
```
64+
DEF=$(cat /proc/irq/default_smp_affinity)
65+
for f in /proc/irq/*/smp_affinity; do
66+
echo "$DEF" | sudo tee "$f" >/dev/null || true
67+
done
68+
```
69+
70+
### Saving these changes
71+
72+
Any changes you make to IRQs will be reset at reboot. You will need to change your systems settings to make your changes permenant.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: conclusion
3+
weight: 4
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
While a single pattern does not work for all workloads. Our testing found that under heavy network workloads, different patterns performed better based on sizing.
10+
11+
### upto and under 16 vCPUs
12+
For best performance, reduce NIC IRQs to either one or two cores. Otherwise random or default performed second best.
13+
14+
*If the number of NIC IRQS are more then the number of vCPUs, concentrating them over less cores improved performance significantly.
15+
16+
### over 16 vCPUs
17+
No pattern showed significant improvement over default as long as all NIC IRQs were not on duplicate cores.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: patterns
3+
weight: 3
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
The following patterns were ran on multiple cloud and on a variety of sizes. A recommended IRQ pattern will be suggested at the end. Based on your workload, a different pattern may result in higher performance.
10+
11+
### Patterns
12+
1. Default: IRQ pattern provided at boot.
13+
2. Random: All IRQs are assigned a core and do not overlap with network IRQs.
14+
3. Housekeeping: All IRQs outside of network IRQs are assign to specific core(s).
15+
4. NIC IRQs are set to single or multiple ranges of cores and including pairs. EX. 1, 1-2, 0-3, 0-7, [0-1, 2-3..], etc.
16+
17+
18+
### Scripts to change IRQ
19+
20+
To change the NIC IRQs or IRQs in general you can use the following scripts.
21+
22+
Housekeeping pattern example, you will need to add more to account for other IRQs on your system
23+
24+
```
25+
HOUSEKEEP=#core range here
26+
27+
# ACPI:Ged
28+
for irq in $(awk '/ACPI:Ged/ {sub(":","",$1); print $1}' /proc/interrupts); do
29+
echo $HOUSEKEEP | sudo tee /proc/irq/$irq/smp_affinity_list >/dev/null
30+
done
31+
```
32+
33+
This is for pairs on a 16 vCPU machine, you will need the interface name.
34+
35+
```
36+
IFACE=#interface name
37+
38+
PAIRS=("0,1" "2,3" "4,5" "6,7" "8,9" "10,11" "12,13" "14,15")
39+
40+
# Match IRQs for the NIC
41+
mapfile -t irqs < <(grep "$IFACE-Tx-Rx" /proc/interrupts | awk '{gsub(":","",$1); print $1}')
42+
43+
i=0
44+
for irq in "${irqs[@]}"; do
45+
pair=${PAIRS[$((i % ${#PAIRS[@]}))]}
46+
echo "$pair" | sudo tee /proc/irq/$irq/smp_affinity_list >/dev/null
47+
echo "Set IRQ $irq -> CPUs $pair"
48+
((i++))
49+
done
50+
```
51+
52+
This will assign a specific core(s) to NIC IRQs only
53+
54+
```
55+
IFACE=#interface name
56+
57+
for irq in $(awk '/$IFACE/ {sub(":","",$1); print $1}' /proc/interrupts); do
58+
echo 0-15 | sudo tee /proc/irq/$irq/smp_affinity_list > /dev/null
59+
done
60+
```

0 commit comments

Comments
 (0)