Skip to content

Commit 95f4396

Browse files
Pavel SiskaSiskaPavel
authored andcommitted
ipfixprobed: fix DPDK parser
fix queue size and workers affinity
1 parent 24ce677 commit 95f4396

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

init/config2args.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import json
88
import re
99
from pathlib import Path
10+
from typing import List
1011

1112
def load_config(file_path):
1213
try:
@@ -54,7 +55,7 @@ def process_input_plugin(config):
5455

5556
return " ".join(params)
5657

57-
def get_cpus_for_pci_device(pci_address: str) -> list[int]:
58+
def get_cpus_for_pci_device(pci_address: str) -> List[int]:
5859
"""
5960
Gets the list of CPU IDs associated with the NUMA node corresponding to the given PCI address.
6061
@@ -63,15 +64,14 @@ def get_cpus_for_pci_device(pci_address: str) -> list[int]:
6364
"""
6465
# Get the NUMA node
6566
numa_path = Path(f"/sys/bus/pci/devices/{pci_address}/numa_node")
66-
if not numa_path.exists():
67-
raise FileNotFoundError(f"NUMA node info for PCI address {pci_address} does not exist.")
68-
69-
numa_node = numa_path.read_text().strip()
70-
if numa_node == "-1":
71-
raise ValueError(f"Device {pci_address} is not assigned to any NUMA node.")
67+
numa_node = 0
68+
if numa_path.exists():
69+
numa_node = numa_path.read_text().strip()
70+
if numa_node == "-1":
71+
numa_node = 0
7272

7373
# Run lscpu to get CPU information
74-
result = subprocess.run(["lscpu"], capture_output=True, text=True, check=True)
74+
result = subprocess.run(["lscpu"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, check=True)
7575
lines = result.stdout.splitlines()
7676

7777
# Find the line corresponding to the NUMA node
@@ -84,7 +84,7 @@ def get_cpus_for_pci_device(pci_address: str) -> list[int]:
8484

8585
raise RuntimeError(f"Could not find CPU list for NUMA node {numa_node}.")
8686

87-
def parse_cpu_list(cpu_list_str: str) -> list[int]:
87+
def parse_cpu_list(cpu_list_str: str) -> List[int]:
8888
"""
8989
Converts a CPU range string like "1,3,5-7" to a list of individual CPU numbers [1, 3, 5, 6, 7].
9090
@@ -138,11 +138,18 @@ def process_input_dpdk_plugin(settings):
138138
workers_cpu_list = cpu_list[:rx_queues]
139139

140140
# Main parameter for DPDK with $eal_opts
141-
primary_param = f"-i \"dpdk;p={','.join(str(i) for i in range(nic_count))};"
141+
first_cpu = workers_cpu_list[0]
142+
if first_cpu is not None:
143+
primary_param = f"-i \"dpdk@{first_cpu};p={','.join(str(i) for i in range(nic_count))};"
144+
else:
145+
primary_param = f"-i \"dpdk;p={','.join(str(i) for i in range(nic_count))};"
146+
142147
burst_size = settings.get("burst_size", 64)
143148
if burst_size is not None:
144149
primary_param += f"b={burst_size};"
145150

151+
primary_param += f"q={rx_queues};"
152+
146153
mempool_size = settings.get("mempool_size", 8192)
147154
if mempool_size is not None:
148155
primary_param += f"m={mempool_size};"
@@ -153,11 +160,7 @@ def process_input_dpdk_plugin(settings):
153160
primary_param += f"eal={eal}\""
154161

155162
params = []
156-
first_cpu = workers_cpu_list[0]
157-
if first_cpu is not None:
158-
params.append(f"{primary_param}@{first_cpu}")
159-
else:
160-
params.append(primary_param)
163+
params.append(primary_param)
161164

162165
for i in range(1, rx_queues):
163166
cpu = workers_cpu_list[i]

0 commit comments

Comments
 (0)