Skip to content

Commit 23f57d8

Browse files
Support of PCI-slot-based queue naming (#214)
* Fixed(rss-docs): __eval return bindings to CPUs, not sockets. * Added(rss-ladder): support for setups with pci-slot-id instead device name * Added(rss-tests): data example for mlx5 setup with pci-slot-based queue naming * Incremented version Example: mlx5_comp0@pci:0000:01:00.0 mlx5_comp1@pci:0000:01:00.0 mlx5_comp2@pci:0000:01:00.0 mlx5_comp3@pci:0000:01:00.0
1 parent cfc1bf6 commit 23f57d8

File tree

7 files changed

+102
-13
lines changed

7 files changed

+102
-13
lines changed

netutils_linux_tuning/rss_ladder.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def parse(self):
5151
def eval(self):
5252
""" Top of all the logic, decide what to do and then apply new settings """
5353
interrupts = open(self.interrupts_file).readlines()
54-
for postfix in sorted(self.queue_postfixes_detect(interrupts)):
55-
self.apply(self.__eval(postfix, interrupts))
54+
extract_func = self.queue_suffix_extract if 'pci' in self.options.dev else self.queue_postfix_extract
55+
for queue_pattern in sorted(self.queue_pattern_detect(interrupts, extract_func)):
56+
self.apply(self.__eval(queue_pattern, interrupts))
5657

5758
def apply(self, decision):
5859
"""
@@ -76,14 +77,25 @@ def apply(self, decision):
7677
with open(filename, 'w') as irq_file:
7778
irq_file.write(str(socket_cpu))
7879

79-
def __eval(self, postfix, interrupts):
80+
def queue_name_regex(self, queue_pattern):
8081
"""
81-
:param postfix: '-TxRx-'
82-
:return: list of tuples(irq, queue_name, socket)
82+
:param queue_pattern: -TxRx- or mlx5_comp
83+
:return: regex to much entire queue name
84+
"""
85+
if 'pci' in self.options.dev:
86+
# mlx5_comp0@pci:0000:01:00.0
87+
return r'{1}[0-9]+@{0}'.format(self.options.dev, queue_pattern)
88+
# eth0-TxRx-[^ \n]+
89+
return r'{0}{1}[^ \n]+'.format(self.options.dev, queue_pattern)
90+
91+
def __eval(self, queue_pattern, interrupts):
92+
"""
93+
:param queue_pattern: '-TxRx-'
94+
:return: list of tuples(irq, queue_name, cpu)
8395
"""
8496
print_('- distribute interrupts of {0} ({1}) on socket {2}'.format(
85-
self.options.dev, postfix, self.options.socket))
86-
queue_regex = r'{0}{1}[^ \n]+'.format(self.options.dev, postfix)
97+
self.options.dev, queue_pattern, self.options.socket))
98+
queue_regex = self.queue_name_regex(queue_pattern)
8799
rss_cpus = self.rss_cpus_detect()
88100
for _ in xrange(self.options.offset):
89101
rss_cpus.pop()
@@ -106,6 +118,7 @@ def parse_cpus(self, lscpu_output):
106118

107119
def queue_postfix_extract(self, line):
108120
"""
121+
used for device based queue-naming
109122
:param line: '31312 0 0 0 blabla eth0-TxRx-0'
110123
:return: '-TxRx-'
111124
"""
@@ -114,12 +127,29 @@ def queue_postfix_extract(self, line):
114127
if queue_name:
115128
return re.sub(r'({0}|[0-9])'.format(self.options.dev), '', queue_name[0])
116129

117-
def queue_postfixes_detect(self, interrupts):
130+
def queue_suffix_extract(self, line):
118131
"""
119-
self.dev: eth0
120-
:return: '-TxRx-'
132+
used for pci-bus-id based queue-naming
133+
:param line: '33: 122736116 0 0 5465612 PCI-MSI-edge mlx5_comp3@pci:0000:01:00.0'
134+
:return: mlx5_comp
135+
"""
136+
queue_regex = r'[^ ]*{0}'.format(self.options.dev)
137+
queue_name = re.findall(queue_regex, line)
138+
if not queue_name:
139+
return
140+
if '@' in queue_name[0]:
141+
queue_name = queue_name[0].split('@') # ['mlx5_comp3', 'pci:0000:01:00.0']
142+
return re.sub(r'({0}|[0-9]+$)'.format(self.options.dev), '', queue_name[0])
143+
144+
@staticmethod
145+
def queue_pattern_detect(interrupts, extract_func):
146+
"""
147+
self.dev: eth0 or pci:0000:01:00.0
148+
:param interrupts: lines of /proc/interrupts
149+
:param extract_func: function to extract queue pattern from lines
150+
:return: set(['-TxRx-']) or set(['mlx5_comp'])
121151
"""
122-
return set([line for line in [self.queue_postfix_extract(line) for line in interrupts] if line])
152+
return set([line for line in [extract_func(line) for line in interrupts] if line])
123153

124154
def rss_cpus_detect(self):
125155
"""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def read(*paths):
1616

1717
setuptools.setup(
1818
name='netutils-linux',
19-
version='2.7.8',
19+
version='2.7.9',
2020
author='Oleg Strizhechenko',
2121
author_email='[email protected]',
2222
license='MIT',

tests/rss-ladder-test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ run_test() {
2929
}
3030

3131
retval=0
32-
for test in ixgbe.E5645 igb.E5606; do
32+
for test in ixgbe.E5645 igb.E5606 mlx5.Q6700; do
3333
run_test $test || retval=1
3434
done
3535
rm -f interrupts lscpu_output output
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- distribute interrupts of pci:0000:01:00.0 (mlx5_async_eq) on socket 0
2+
- distribute interrupts of pci:0000:01:00.0 (mlx5_cmd_eq) on socket 0
3+
- distribute interrupts of pci:0000:01:00.0 (mlx5_comp) on socket 0
4+
- pci:0000:01:00.0: queue mlx5_comp0@pci:0000:01:00.0 (irq 30) bound to CPU0
5+
- pci:0000:01:00.0: queue mlx5_comp1@pci:0000:01:00.0 (irq 31) bound to CPU1
6+
- pci:0000:01:00.0: queue mlx5_comp2@pci:0000:01:00.0 (irq 32) bound to CPU2
7+
- pci:0000:01:00.0: queue mlx5_comp3@pci:0000:01:00.0 (irq 33) bound to CPU3
8+
- distribute interrupts of pci:0000:01:00.0 (mlx5_pages_eq) on socket 0
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CPU0 CPU1 CPU2 CPU3
2+
0: 166 0 0 0 IO-APIC-edge timer
3+
1: 2 0 0 0 IO-APIC-edge i8042
4+
8: 1 0 0 0 IO-APIC-edge rtc0
5+
9: 0 0 0 0 IO-APIC-fasteoi acpi
6+
12: 4 0 0 0 IO-APIC-edge i8042
7+
14: 195 0 0 0 IO-APIC-edge ata_piix
8+
15: 0 0 0 0 IO-APIC-edge ata_piix
9+
16: 0 0 0 0 IO-APIC-fasteoi uhci_hcd:usb5
10+
17: 1087624 0 0 0 IO-APIC-fasteoi eth1
11+
18: 302 0 0 0 IO-APIC-fasteoi uhci_hcd:usb4, radeon
12+
19: 135245 0 0 0 IO-APIC-fasteoi uhci_hcd:usb3, ata_piix
13+
23: 0 0 0 0 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb2
14+
27: 1 0 0 0 PCI-MSI-edge mlx5_pages_eq@pci:0000:01:00.0
15+
28: 221496 0 0 0 PCI-MSI-edge mlx5_cmd_eq@pci:0000:01:00.0
16+
29: 0 0 0 0 PCI-MSI-edge mlx5_async_eq@pci:0000:01:00.0
17+
30: 127355089 0 0 0 PCI-MSI-edge mlx5_comp0@pci:0000:01:00.0
18+
31: 120112828 5482507 0 0 PCI-MSI-edge mlx5_comp1@pci:0000:01:00.0
19+
32: 121978940 0 5524729 0 PCI-MSI-edge mlx5_comp2@pci:0000:01:00.0
20+
33: 122736116 0 0 5465612 PCI-MSI-edge mlx5_comp3@pci:0000:01:00.0
21+
34: 1 0 0 0 PCI-MSI-edge mlx5_pages_eq@pci:0000:01:00.1
22+
35: 208713 0 0 0 PCI-MSI-edge mlx5_cmd_eq@pci:0000:01:00.1
23+
36: 0 0 0 0 PCI-MSI-edge mlx5_async_eq@pci:0000:01:00.1
24+
37: 1 0 0 0 PCI-MSI-edge mlx5_comp0@pci:0000:01:00.1
25+
38: 1 0 0 0 PCI-MSI-edge mlx5_comp1@pci:0000:01:00.1
26+
39: 1 0 0 0 PCI-MSI-edge mlx5_comp2@pci:0000:01:00.1
27+
40: 1 0 0 0 PCI-MSI-edge mlx5_comp3@pci:0000:01:00.1
28+
41: 15573731 0 0 0 PCI-MSI-edge eth0
29+
NMI: 13767 6976 2066 6238 Non-maskable interrupts
30+
LOC: 6714889 6309050 2414331 5652397 Local timer interrupts
31+
SPU: 0 0 0 0 Spurious interrupts
32+
PMI: 13767 6976 2066 6238 Performance monitoring interrupts
33+
IWI: 0 0 0 0 IRQ work interrupts
34+
RES: 216058 412432 563703 302262 Rescheduling interrupts
35+
CAL: 121 78869 169 207 Function call interrupts
36+
TLB: 30449 33578 52341 37224 TLB shootdowns
37+
TRM: 0 0 0 0 Thermal event interrupts
38+
THR: 0 0 0 0 Threshold APIC interrupts
39+
MCE: 0 0 0 0 Machine check exceptions
40+
MCP: 40 40 40 40 Machine check polls
41+
ERR: 0
42+
MIS: 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following is the parsable format, which can be fed to other
2+
# programs. Each different item in every column has an unique ID
3+
# starting from zero.
4+
# CPU,Core,Socket,Node,,L1d,L1i,L2
5+
0,0,0,0,,0,0,0
6+
1,1,0,0,,1,1,1
7+
2,2,0,0,,2,2,0
8+
3,3,0,0,,3,3,1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pci:0000:01:00.0

0 commit comments

Comments
 (0)