doc: announce behavior change in bus probing
[dpdk.git] / buildtools / get-numa-count.py
1 #!/usr/bin/env python3
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright (c) 2021 PANTHEON.tech s.r.o.
4
5 import ctypes
6 import glob
7 import os
8 import subprocess
9
10 if os.name == 'posix':
11     if os.path.isdir('/sys/devices/system/node'):
12         numa_nodes = glob.glob('/sys/devices/system/node/node*')
13         numa_nodes.sort()
14         print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
15     else:
16         subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
17
18 elif os.name == 'nt':
19     libkernel32 = ctypes.windll.kernel32
20
21     numa_count = ctypes.c_ulong()
22
23     libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(numa_count))
24     print(numa_count.value + 1)