[PATCH v1] buildtools: ensure the NUMA nodes are counted correct
Chaoyong He
chaoyong.he at corigine.com
Tue Aug 2 09:54:15 CEST 2022
From: Peng Zhang <peng.zhang at corigine.com>
Sorting a list of strings with the format "node[0-9]+" in order to find the
largest integer by looking at the last item after the sort breaks. But if
there are more then 10 items as a string sort will sort "node10" before
"node2", it will get the error NUMA nodes.
Solve this by sorting the list based on the integer part of the string.
Fixes: 8ef09fdc506b ("build: add optional NUMA and CPU counts detection")
Cc: stable at dpdk.org
Signed-off-by: Peng Zhang <peng.zhang at corigine.com>
Signed-off-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at corigine.com>
---
buildtools/get-numa-count.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
index 1b7787787f..2f243886cd 100644
--- a/buildtools/get-numa-count.py
+++ b/buildtools/get-numa-count.py
@@ -6,11 +6,12 @@
import glob
import os
import subprocess
+import re
if os.name == 'posix':
if os.path.isdir('/sys/devices/system/node'):
numa_nodes = glob.glob('/sys/devices/system/node/node*')
- numa_nodes.sort()
+ numa_nodes.sort(key=lambda l: int(re.findall('\d+', l)[0]))
print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
else:
subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
--
2.27.0
More information about the stable
mailing list