DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1 1/1] build: optional NUMA and cpu counts detection
@ 2020-11-20 12:55 Juraj Linkeš
  2020-12-23 11:32 ` Juraj Linkeš
  2021-03-31  9:06 ` [dpdk-dev] [PATCH v2] " Juraj Linkeš
  0 siblings, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2020-11-20 12:55 UTC (permalink / raw)
  To: thomas, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 22 +++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 84 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index a720cf672..366b0cf58 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -100,6 +100,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/call-sphinx-build.py
 F: buildtools/gen-pmdinfo-cfile.sh
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 000000000..b269d557b
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 000000000..be73c5c3f
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2020 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        print(len(glob.glob('/sys/devices/system/node/node*')))
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
+    print(count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 04808dabc..4ab67de27 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -17,3 +17,5 @@ else
 endif
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
diff --git a/config/meson.build b/config/meson.build
index a29693b88..63d8c2747 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -232,8 +232,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -252,6 +250,51 @@ compile_time_cpuflags = []
 subdir(arch_subdir)
 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
 
+max_lcores = get_option('max_lcores')
+if max_lcores > 0
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores == -1
+	# Overwrite the default value with discovered values
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Discovery makes sense only for non-cross builds
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes > 0
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes == -1
+	# Overwrite the default value with discovered values
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Discovery makes sense only for non-cross builds
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 31bfa63b1..4989d47f3 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -57,3 +57,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 4)
diff --git a/meson_options.txt b/meson_options.txt
index e384e6dbb..8e08852cf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -24,10 +24,10 @@ option('machine', type: 'string', value: 'native',
 	description: 'set the target machine type')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128,
-	description: 'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 4,
-	description: 'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'integer', value: 0,
+	description: 'A positive integer sets the maximum number of cores/threads supported by EAL. The default is per-arch (or cross-compilation) default. Set to -1 to detect the number of cores on the build machine.')
+option('max_numa_nodes', type: 'integer', value: 0,
+	description: 'A positive integer sets maximum number of NUMA nodes supported by EAL. The default is per-arch (or cross-compilation) default. Set to -1 to detect the number of numa nodes on the build machine.')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/1] build: optional NUMA and cpu counts detection
  2020-11-20 12:55 [dpdk-dev] [PATCH v1 1/1] build: optional NUMA and cpu counts detection Juraj Linkeš
@ 2020-12-23 11:32 ` Juraj Linkeš
  2021-03-31  9:06 ` [dpdk-dev] [PATCH v2] " Juraj Linkeš
  1 sibling, 0 replies; 32+ messages in thread
From: Juraj Linkeš @ 2020-12-23 11:32 UTC (permalink / raw)
  To: thomas, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev

Hi Thomas and others,

Do you have any comments? I believe Bruce is okay with this patch.

Thanks,
Juraj

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Friday, November 20, 2020 1:55 PM
> To: thomas@monjalon.net; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v1 1/1] build: optional NUMA and cpu counts detection
> 
> Add an option to automatically discover the host's numa and cpu counts and use
> those values for a non cross-build.
> Give users the option to override the per-arch default values or values from
> cross files by specifying them on the command line with -Dmax_lcores and -
> Dmax_numa_nodes.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> ---
>  MAINTAINERS                  |  2 ++
>  buildtools/get-cpu-count.py  |  7 ++++++  buildtools/get-numa-count.py | 22
> +++++++++++++++++
>  buildtools/meson.build       |  2 ++
>  config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
>  config/x86/meson.build       |  2 ++
>  meson_options.txt            |  8 +++---
>  7 files changed, 84 insertions(+), 6 deletions(-)  create mode 100644
> buildtools/get-cpu-count.py  create mode 100644 buildtools/get-numa-count.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a720cf672..366b0cf58 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -100,6 +100,8 @@ F: meson_options.txt
>  F: config/
>  F: buildtools/call-sphinx-build.py
>  F: buildtools/gen-pmdinfo-cfile.sh
> +F: buildtools/get-cpu-count.py
> +F: buildtools/get-numa-count.py
>  F: buildtools/list-dir-globs.py
>  F: buildtools/pkg-config/
>  F: buildtools/symlink-drivers-solibs.sh
> diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py new file
> mode 100644 index 000000000..b269d557b
> --- /dev/null
> +++ b/buildtools/get-cpu-count.py
> @@ -0,0 +1,7 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2020
> +PANTHEON.tech s.r.o.
> +
> +import os
> +
> +print(os.cpu_count())
> diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py new
> file mode 100644 index 000000000..be73c5c3f
> --- /dev/null
> +++ b/buildtools/get-numa-count.py
> @@ -0,0 +1,22 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2020
> +PANTHEON.tech s.r.o.
> +
> +import ctypes
> +import glob
> +import os
> +import subprocess
> +
> +if os.name == 'posix':
> +    if os.path.isdir('/sys/devices/system/node'):
> +        print(len(glob.glob('/sys/devices/system/node/node*')))
> +    else:
> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
> +
> +elif os.name == 'nt':
> +    libkernel32 = ctypes.windll.kernel32
> +
> +    count = ctypes.c_ulong()
> +
> +    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
> +    print(count.value + 1)
> diff --git a/buildtools/meson.build b/buildtools/meson.build index
> 04808dabc..4ab67de27 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -17,3 +17,5 @@ else
>  endif
>  map_to_win_cmd = py3 + files('map_to_win.py')  sphinx_wrapper = py3 +
> files('call-sphinx-build.py')
> +get_cpu_count_cmd = py3 + files('get-cpu-count.py') get_numa_count_cmd
> += py3 + files('get-numa-count.py')
> diff --git a/config/meson.build b/config/meson.build index
> a29693b88..63d8c2747 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -232,8 +232,6 @@ foreach arg: warning_flags  endforeach
> 
>  # set other values pulled from the build options -
> dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores')) -
> dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
> dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
> dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
> dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp')) @@ -
> 252,6 +250,51 @@ compile_time_cpuflags = []
>  subdir(arch_subdir)
>  dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
> ','.join(compile_time_cpuflags))
> 
> +max_lcores = get_option('max_lcores')
> +if max_lcores > 0
> +	# Overwrite the default value from arch_subdir with user input
> +	dpdk_conf.set('RTE_MAX_LCORE', max_lcores) elif max_lcores == -1
> +	# Overwrite the default value with discovered values
> +	if meson.is_cross_build()
> +		error('Discovery of max_lcores is not supported for cross-
> compilation.')
> +	endif
> +	# Discovery makes sense only for non-cross builds
> +	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
> +	min_lcores = 2
> +	# DPDK must be build for at least 2 cores
> +	if max_lcores < min_lcores
> +		message('Found less than @0@ cores, building for @0@
> cores'.format(min_lcores))
> +		max_lcores = min_lcores
> +	else
> +		message('Found @0@ cores'.format(max_lcores))
> +	endif
> +	dpdk_conf.set('RTE_MAX_LCORE', max_lcores) endif
> +
> +max_numa_nodes = get_option('max_numa_nodes') if max_numa_nodes > 0
> +	# Overwrite the default value from arch_subdir with user input
> +	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes) elif
> +max_numa_nodes == -1
> +	# Overwrite the default value with discovered values
> +	if meson.is_cross_build()
> +		error('Discovery of max_numa_nodes not supported for cross-
> compilation.')
> +	endif
> +	# Discovery makes sense only for non-cross builds
> +	max_numa_nodes =
> run_command(get_numa_count_cmd).stdout().to_int()
> +	message('Found @0@ numa nodes'.format(max_numa_nodes))
> +	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes) endif
> +
> +# check that cpu and numa count is set and error out if it's not set if
> +not dpdk_conf.has('RTE_MAX_LCORE')
> +	error('Number of cores not specified.') endif if not
> +dpdk_conf.has('RTE_MAX_NUMA_NODES')
> +	error('Number of numa nodes not specified.') endif
> +
>  # set the install path for the drivers
>  dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
> 
> diff --git a/config/x86/meson.build b/config/x86/meson.build index
> 31bfa63b1..4989d47f3 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -57,3 +57,5 @@ else
>  endif
> 
>  dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
> +dpdk_conf.set('RTE_MAX_LCORE', 128)
> +dpdk_conf.set('RTE_MAX_NUMA_NODES', 4)
> diff --git a/meson_options.txt b/meson_options.txt index
> e384e6dbb..8e08852cf 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -24,10 +24,10 @@ option('machine', type: 'string', value: 'native',
>  	description: 'set the target machine type')  option('max_ethports', type:
> 'integer', value: 32,
>  	description: 'maximum number of Ethernet devices') -
> option('max_lcores', type: 'integer', value: 128,
> -	description: 'maximum number of cores/threads supported by EAL')
> -option('max_numa_nodes', type: 'integer', value: 4,
> -	description: 'maximum number of NUMA nodes supported by EAL')
> +option('max_lcores', type: 'integer', value: 0,
> +	description: 'A positive integer sets the maximum number of
> +cores/threads supported by EAL. The default is per-arch (or cross-compilation)
> default. Set to -1 to detect the number of cores on the build machine.')
> option('max_numa_nodes', type: 'integer', value: 0,
> +	description: 'A positive integer sets maximum number of NUMA nodes
> +supported by EAL. The default is per-arch (or cross-compilation)
> +default. Set to -1 to detect the number of numa nodes on the build
> +machine.')
>  option('enable_trace_fp', type: 'boolean', value: false,
>  	description: 'enable fast path trace points.')  option('tests', type:
> 'boolean', value: true,
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [dpdk-dev] [PATCH v2] build: optional NUMA and cpu counts detection
  2020-11-20 12:55 [dpdk-dev] [PATCH v1 1/1] build: optional NUMA and cpu counts detection Juraj Linkeš
  2020-12-23 11:32 ` Juraj Linkeš
@ 2021-03-31  9:06 ` Juraj Linkeš
  2021-03-31 19:07   ` David Christensen
  2021-04-19 10:18   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  1 sibling, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-03-31  9:06 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli
  Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 22 +++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 84 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 0ec5588540..7270f33cf5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -99,6 +99,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/chkincs/
 F: buildtools/call-sphinx-build.py
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 0000000000..317b32088f
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 0000000000..77ef2b9f24
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        print(len(glob.glob('/sys/devices/system/node/node*')))
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
+    print(count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 9c9347457a..acbcec0cc9 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -16,6 +16,8 @@ else
 endif
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index 66a2edcc47..65fc1c1d38 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -243,8 +243,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -278,6 +276,51 @@ if meson.is_cross_build()
 	endif
 endif
 
+max_lcores = get_option('max_lcores')
+if max_lcores > 0
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores == -1
+	# Overwrite the default value with discovered values
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Discovery makes sense only for non-cross builds
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes > 0
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes == -1
+	# Overwrite the default value with discovered values
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Discovery makes sense only for non-cross builds
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 31bfa63b1c..c9f129a20e 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -57,3 +57,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
diff --git a/meson_options.txt b/meson_options.txt
index 3b8c5d316d..39f530924e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -24,10 +24,10 @@ option('machine', type: 'string', value: 'native',
 	description: 'set the target machine type')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128,
-	description: 'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 32,
-	description: 'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'integer', value: 0,
+	description: 'A positive integer sets the maximum number of cores/threads supported by EAL. The default is per-arch (or cross-compilation) default. Set to -1 to detect the number of cores on the build machine.')
+option('max_numa_nodes', type: 'integer', value: 0,
+	description: 'A positive integer sets maximum number of NUMA nodes supported by EAL. The default is per-arch (or cross-compilation) default. Set to -1 to detect the number of numa nodes on the build machine.')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v2] build: optional NUMA and cpu counts detection
  2021-03-31  9:06 ` [dpdk-dev] [PATCH v2] " Juraj Linkeš
@ 2021-03-31 19:07   ` David Christensen
  2021-04-16 12:43     ` Juraj Linkeš
  2021-04-19 10:18   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  1 sibling, 1 reply; 32+ messages in thread
From: David Christensen @ 2021-03-31 19:07 UTC (permalink / raw)
  To: dev

[-- Attachment #1: Type: text/plain, Size: 3502 bytes --]



On 3/31/21 2:06 AM, Juraj Linkeš wrote:
> Add an option to automatically discover the host's numa and cpu counts
> and use those values for a non cross-build.
> Give users the option to override the per-arch default values or values
> from cross files by specifying them on the command line with -Dmax_lcores
> and -Dmax_numa_nodes.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> ---
>   MAINTAINERS                  |  2 ++
>   buildtools/get-cpu-count.py  |  7 ++++++
>   buildtools/get-numa-count.py | 22 +++++++++++++++++
>   buildtools/meson.build       |  2 ++
>   config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
>   config/x86/meson.build       |  2 ++
>   meson_options.txt            |  8 +++---
>   7 files changed, 84 insertions(+), 6 deletions(-)
>   create mode 100644 buildtools/get-cpu-count.py
>   create mode 100644 buildtools/get-numa-count.py
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 0ec5588540..7270f33cf5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -99,6 +99,8 @@ F: meson_options.txt
>   F: config/
>   F: buildtools/chkincs/
>   F: buildtools/call-sphinx-build.py
> +F: buildtools/get-cpu-count.py
> +F: buildtools/get-numa-count.py
>   F: buildtools/list-dir-globs.py
>   F: buildtools/pkg-config/
>   F: buildtools/symlink-drivers-solibs.sh
> diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
> new file mode 100644
> index 0000000000..317b32088f
> --- /dev/null
> +++ b/buildtools/get-cpu-count.py
> @@ -0,0 +1,7 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (c) 2021 PANTHEON.tech s.r.o.
> +
> +import os
> +
> +print(os.cpu_count())

Returns the expected value on a P9 system.

> diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
> new file mode 100644
> index 0000000000..77ef2b9f24
> --- /dev/null
> +++ b/buildtools/get-numa-count.py
> @@ -0,0 +1,22 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (c) 2021 PANTHEON.tech s.r.o.
> +
> +import ctypes
> +import glob
> +import os
> +import subprocess
> +
> +if os.name == 'posix':
> +    if os.path.isdir('/sys/devices/system/node'):
> +        print(len(glob.glob('/sys/devices/system/node/node*')))
> +    else:
> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
> +
> +elif os.name == 'nt':
> +    libkernel32 = ctypes.windll.kernel32
> +
> +    count = ctypes.c_ulong()
> +
> +    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
> +    print(count.value + 1)

Does not return the expected value on my P9 system (NUMA nodes are not 
contiguous).  Got 6, expect to see at least 8 otherwise I can't use 
lcores on NUMA node 8.

$ python3 ./get-numa-count.py
6
$ lscpu
Architecture:        ppc64le
Byte Order:          Little Endian
CPU(s):              128
On-line CPU(s) list: 0-127
Thread(s) per core:  4
Core(s) per socket:  16
Socket(s):           2
NUMA node(s):        6
Model:               2.3 (pvr 004e 1203)
Model name:          POWER9, altivec supported
CPU max MHz:         3800.0000
CPU min MHz:         2300.0000
L1d cache:           32K
L1i cache:           32K
L2 cache:            512K
L3 cache:            10240K
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
NUMA node253 CPU(s):
NUMA node254 CPU(s):
NUMA node255 CPU(s):

See attached ls-node.txt.gz for full directory structure on a P9 system.

Dave

[-- Attachment #2: ls-node.txt.gz --]
[-- Type: application/x-gzip, Size: 7611 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v2] build: optional NUMA and cpu counts detection
  2021-03-31 19:07   ` David Christensen
@ 2021-04-16 12:43     ` Juraj Linkeš
  0 siblings, 0 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-04-16 12:43 UTC (permalink / raw)
  To: David Christensen, dev
  Cc: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli

I didn't notice this e-mail, since it was sent just to dev@dpdk.org and not to me explicitly, which left it unnoticed by my filters, unfortunately.

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Christensen
> Sent: Wednesday, March 31, 2021 9:07 PM
> To: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] build: optional NUMA and cpu counts
> detection
> 
> 
> 
> On 3/31/21 2:06 AM, Juraj Linkeš wrote:
> > Add an option to automatically discover the host's numa and cpu counts
> > and use those values for a non cross-build.
> > Give users the option to override the per-arch default values or
> > values from cross files by specifying them on the command line with
> > -Dmax_lcores and -Dmax_numa_nodes.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > ---
> >   MAINTAINERS                  |  2 ++
> >   buildtools/get-cpu-count.py  |  7 ++++++
> >   buildtools/get-numa-count.py | 22 +++++++++++++++++
> >   buildtools/meson.build       |  2 ++
> >   config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
> >   config/x86/meson.build       |  2 ++
> >   meson_options.txt            |  8 +++---
> >   7 files changed, 84 insertions(+), 6 deletions(-)
> >   create mode 100644 buildtools/get-cpu-count.py
> >   create mode 100644 buildtools/get-numa-count.py
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS index 0ec5588540..7270f33cf5
> > 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -99,6 +99,8 @@ F: meson_options.txt
> >   F: config/
> >   F: buildtools/chkincs/
> >   F: buildtools/call-sphinx-build.py
> > +F: buildtools/get-cpu-count.py
> > +F: buildtools/get-numa-count.py
> >   F: buildtools/list-dir-globs.py
> >   F: buildtools/pkg-config/
> >   F: buildtools/symlink-drivers-solibs.sh
> > diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
> > new file mode 100644 index 0000000000..317b32088f
> > --- /dev/null
> > +++ b/buildtools/get-cpu-count.py
> > @@ -0,0 +1,7 @@
> > +#!/usr/bin/env python3
> > +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2021
> > +PANTHEON.tech s.r.o.
> > +
> > +import os
> > +
> > +print(os.cpu_count())
> 
> Returns the expected value on a P9 system.
> 
> > diff --git a/buildtools/get-numa-count.py
> > b/buildtools/get-numa-count.py new file mode 100644 index
> > 0000000000..77ef2b9f24
> > --- /dev/null
> > +++ b/buildtools/get-numa-count.py
> > @@ -0,0 +1,22 @@
> > +#!/usr/bin/env python3
> > +# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2021
> > +PANTHEON.tech s.r.o.
> > +
> > +import ctypes
> > +import glob
> > +import os
> > +import subprocess
> > +
> > +if os.name == 'posix':
> > +    if os.path.isdir('/sys/devices/system/node'):
> > +        print(len(glob.glob('/sys/devices/system/node/node*')))
> > +    else:
> > +        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
> > +
> > +elif os.name == 'nt':
> > +    libkernel32 = ctypes.windll.kernel32
> > +
> > +    count = ctypes.c_ulong()
> > +
> > +    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
> > +    print(count.value + 1)
> 
> Does not return the expected value on my P9 system (NUMA nodes are not
> contiguous).  Got 6, expect to see at least 8 otherwise I can't use lcores on
> NUMA node 8.
> 

I guess the problem here is that we're not really setting the number of NUMA nodes that are usable, but the highest NUMA that is usable?

In that case, the proper config in should be 256 so that even node255 is usable, is that right?

> $ python3 ./get-numa-count.py
> 6
> $ lscpu
> Architecture:        ppc64le
> Byte Order:          Little Endian
> CPU(s):              128
> On-line CPU(s) list: 0-127
> Thread(s) per core:  4
> Core(s) per socket:  16
> Socket(s):           2
> NUMA node(s):        6
> Model:               2.3 (pvr 004e 1203)
> Model name:          POWER9, altivec supported
> CPU max MHz:         3800.0000
> CPU min MHz:         2300.0000
> L1d cache:           32K
> L1i cache:           32K
> L2 cache:            512K
> L3 cache:            10240K
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
> NUMA node252 CPU(s):
> NUMA node253 CPU(s):
> NUMA node254 CPU(s):
> NUMA node255 CPU(s):
> 
> See attached ls-node.txt.gz for full directory structure on a P9 system.
> 
> Dave

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [dpdk-dev] [PATCH v3] build: optional NUMA and cpu counts detection
  2021-03-31  9:06 ` [dpdk-dev] [PATCH v2] " Juraj Linkeš
  2021-03-31 19:07   ` David Christensen
@ 2021-04-19 10:18   ` Juraj Linkeš
  2021-04-28 19:33     ` David Christensen
  2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  1 sibling, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-04-19 10:18 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang
  Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 24 ++++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 2550d950de..bf295e35e2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -99,6 +99,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/chkincs/
 F: buildtools/call-sphinx-build.py
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 0000000000..317b32088f
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 0000000000..3b67564fd4
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        numa_nodes = glob.glob('/sys/devices/system/node/node*')
+        numa_nodes.sort()
+        print(os.path.basename(numa_nodes[-1])[4:])
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
+    print(count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 9c9347457a..acbcec0cc9 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -16,6 +16,8 @@ else
 endif
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index 6e6ef8c0e1..726c478874 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -248,8 +248,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -283,6 +281,51 @@ if meson.is_cross_build()
 	endif
 endif
 
+max_lcores = get_option('max_lcores')
+if max_lcores == 'auto'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores.to_int())
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes == 'auto'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes.to_int())
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 31bfa63b1c..c9f129a20e 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -57,3 +57,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
diff --git a/meson_options.txt b/meson_options.txt
index b78f3bd9d5..fe87863ebf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -30,10 +30,10 @@ option('machine', type: 'string', value: 'native',
 	description: 'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128,
-	description: 'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 32,
-	description: 'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'string', value: 'default',
+	description: 'Set maximum number of cores/threads supported by EAL. The default is different per-arch. Set to auto to detect the number of cores on the build machine.')
+option('max_numa_nodes', type: 'string', value: 'default',
+	description: 'Set highest NUMA node supported by EAL. The default is different per-arch. Set to auto to detect the highest numa node on the build machine.')
 option('platform', type: 'string', value: '',
 	description: 'use configuration for a particular platform (such as a SoC).')
 option('enable_trace_fp', type: 'boolean', value: false,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v3] build: optional NUMA and cpu counts detection
  2021-04-19 10:18   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
@ 2021-04-28 19:33     ` David Christensen
  2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  1 sibling, 0 replies; 32+ messages in thread
From: David Christensen @ 2021-04-28 19:33 UTC (permalink / raw)
  To: dev



On 4/19/21 3:18 AM, Juraj Linkeš wrote:
> Add an option to automatically discover the host's numa and cpu counts
> and use those values for a non cross-build.
> Give users the option to override the per-arch default values or values
> from cross files by specifying them on the command line with -Dmax_lcores
> and -Dmax_numa_nodes.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> ---
Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-04-19 10:18   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  2021-04-28 19:33     ` David Christensen
@ 2021-06-29 10:55     ` Juraj Linkeš
  2021-06-29 11:28       ` Bruce Richardson
                         ` (2 more replies)
  1 sibling, 3 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-06-29 10:55 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 24 ++++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 5877a16971..0ca3d4e9f5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -102,6 +102,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/chkincs/
 F: buildtools/call-sphinx-build.py
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 0000000000..317b32088f
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 0000000000..3b67564fd4
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        numa_nodes = glob.glob('/sys/devices/system/node/node*')
+        numa_nodes.sort()
+        print(os.path.basename(numa_nodes[-1])[4:])
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(count))
+    print(count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index 0f24b15297..887882e6a5 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -16,6 +16,8 @@ endif
 list_dir_globs = py3 + files('list-dir-globs.py')
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index 017bb2efbb..2d1db40127 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -247,8 +247,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -282,6 +280,51 @@ if meson.is_cross_build()
     endif
 endif
 
+max_lcores = get_option('max_lcores')
+if max_lcores == 'auto'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores.to_int())
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes == 'auto'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes.to_int())
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index b9348c44de..872dda9585 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -57,3 +57,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
diff --git a/meson_options.txt b/meson_options.txt
index 56bdfd0f0a..649a60abc9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -32,10 +32,10 @@ option('machine', type: 'string', value: 'native', description:
        'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
 option('max_ethports', type: 'integer', value: 32, description:
        'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128, description:
-       'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 32, description:
-       'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'string', value: 'default', description:
+       'Set maximum number of cores/threads supported by EAL. The default is different per-arch. Set to auto to detect the number of cores on the build machine.')
+option('max_numa_nodes', type: 'string', value: 'default', description:
+       'Set highest NUMA node supported by EAL. The default is different per-arch. Set to auto to detect the highest numa node on the build machine.')
 option('platform', type: 'string', value: '', description:
        'use configuration for a particular platform (such as a SoC).')
 option('enable_trace_fp', type: 'boolean', value: false, description:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
@ 2021-06-29 11:28       ` Bruce Richardson
  2021-07-06  8:56         ` Juraj Linkeš
  2021-06-29 18:00       ` Stephen Hemminger
  2021-07-21 13:04       ` [dpdk-dev] [PATCH v5] " Juraj Linkeš
  2 siblings, 1 reply; 32+ messages in thread
From: Bruce Richardson @ 2021-06-29 11:28 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev

On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
> Add an option to automatically discover the host's numa and cpu counts
> and use those values for a non cross-build.
> Give users the option to override the per-arch default values or values
> from cross files by specifying them on the command line with -Dmax_lcores
> and -Dmax_numa_nodes.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> ---
Two very minor suggestions inline below.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

>  
<snip>
> +max_lcores = get_option('max_lcores')
> +if max_lcores == 'auto'

Rather than "auto", would "detect" be a clearer name for this option value?

<snip>
> +option('max_lcores', type: 'string', value: 'default', description:
> +       'Set maximum number of cores/threads supported by EAL. The default is different per-arch. Set to auto to detect the number of cores on the build machine.')
> +option('max_numa_nodes', type: 'string', value: 'default', description:
> +       'Set highest NUMA node supported by EAL. The default is different per-arch. Set to auto to detect the highest numa node on the build machine.')

I'd put the explicit values of "default" and "auto"(or "detect") in
quotes "" to make clear they are literal values.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  2021-06-29 11:28       ` Bruce Richardson
@ 2021-06-29 18:00       ` Stephen Hemminger
  2021-07-21 13:04       ` [dpdk-dev] [PATCH v5] " Juraj Linkeš
  2 siblings, 0 replies; 32+ messages in thread
From: Stephen Hemminger @ 2021-06-29 18:00 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, dev

On Tue, 29 Jun 2021 12:55:05 +0200
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:

> diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
> new file mode 100644
> index 0000000000..3b67564fd4
> --- /dev/null
> +++ b/buildtools/get-numa-count.py
> @@ -0,0 +1,24 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright (c) 2021 PANTHEON.tech s.r.o.
> +
> +import ctypes
> +import glob
> +import os
> +import subprocess
> +
> +if os.name == 'posix':
> +    if os.path.isdir('/sys/devices/system/node'):
> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> +        numa_nodes.sort()
> +        print(os.path.basename(numa_nodes[-1])[4:])
> +    else:
> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'])
> +

python lint has warning here
buildtools/get-numa-count.py:16:8: W1510: Using subprocess.run without explicitly set `check` is not recommended. (subprocess-run-check)

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-06-29 11:28       ` Bruce Richardson
@ 2021-07-06  8:56         ` Juraj Linkeš
  2021-07-06  9:08           ` Bruce Richardson
  0 siblings, 1 reply; 32+ messages in thread
From: Juraj Linkeš @ 2021-07-06  8:56 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, June 29, 2021 1:29 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> Subject: Re: [PATCH v4] build: optional NUMA and cpu counts detection
> 
> On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
> > Add an option to automatically discover the host's numa and cpu counts
> > and use those values for a non cross-build.
> > Give users the option to override the per-arch default values or
> > values from cross files by specifying them on the command line with
> > -Dmax_lcores and -Dmax_numa_nodes.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > ---
> Two very minor suggestions inline below.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> >
> <snip>
> > +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
> 
> Rather than "auto", would "detect" be a clearer name for this option value?
> 
> <snip>
> > +option('max_lcores', type: 'string', value: 'default', description:
> > +       'Set maximum number of cores/threads supported by EAL. The
> > +default is different per-arch. Set to auto to detect the number of cores on the
> build machine.') option('max_numa_nodes', type: 'string', value: 'default',
> description:
> > +       'Set highest NUMA node supported by EAL. The default is
> > +different per-arch. Set to auto to detect the highest numa node on
> > +the build machine.')
> 
> I'd put the explicit values of "default" and "auto"(or "detect") in quotes "" to
> make clear they are literal values.
> 

Thanks, Bruce, I'll change it. I have one extra question now that I'm looking at the patch:
What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA node on the system (the highest number of all NUMA nodes)? I'm asking because of how NUMA works on P9:
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
NUMA node253 CPU(s):
NUMA node254 CPU(s):
NUMA node255 CPU(s):

Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and Windows should return the highest NUMA, not sure about FreeBSD. Or maybe we should return the highest NUMA on which there are actual CPUs?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-06  8:56         ` Juraj Linkeš
@ 2021-07-06  9:08           ` Bruce Richardson
  2021-07-06 18:10             ` David Christensen
  0 siblings, 1 reply; 32+ messages in thread
From: Bruce Richardson @ 2021-07-06  9:08 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev

On Tue, Jul 06, 2021 at 08:56:37AM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Tuesday, June 29, 2021 1:29 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: thomas@monjalon.net; david.marchand@redhat.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> > Subject: Re: [PATCH v4] build: optional NUMA and cpu counts detection
> > 
> > On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
> > > Add an option to automatically discover the host's numa and cpu counts
> > > and use those values for a non cross-build.
> > > Give users the option to override the per-arch default values or
> > > values from cross files by specifying them on the command line with
> > > -Dmax_lcores and -Dmax_numa_nodes.
> > >
> > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > > ---
> > Two very minor suggestions inline below.
> > 
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > >
> > <snip>
> > > +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
> > 
> > Rather than "auto", would "detect" be a clearer name for this option value?
> > 
> > <snip>
> > > +option('max_lcores', type: 'string', value: 'default', description:
> > > +       'Set maximum number of cores/threads supported by EAL. The
> > > +default is different per-arch. Set to auto to detect the number of cores on the
> > build machine.') option('max_numa_nodes', type: 'string', value: 'default',
> > description:
> > > +       'Set highest NUMA node supported by EAL. The default is
> > > +different per-arch. Set to auto to detect the highest numa node on
> > > +the build machine.')
> > 
> > I'd put the explicit values of "default" and "auto"(or "detect") in quotes "" to
> > make clear they are literal values.
> > 
> 
> Thanks, Bruce, I'll change it. I have one extra question now that I'm looking at the patch:
> What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA node on the system (the highest number of all NUMA nodes)? I'm asking because of how NUMA works on P9:
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
> NUMA node252 CPU(s):
> NUMA node253 CPU(s):
> NUMA node254 CPU(s):
> NUMA node255 CPU(s):
> 
> Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and Windows should return the highest NUMA, not sure about FreeBSD. Or maybe we should return the highest NUMA on which there are actual CPUs?

I'm not sure, and I think to be really sure we'd need it tested on a P9
system. The help text for the sysctl node says "Number of physical memory
domains available", which would imply 2 in the case above. [However, we also
would need to find out how BSD numbers the domains, too, as it's possible
an OS could just call them 0 and 1, rather than 0 and 8 if it wanted to.]

In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
config, and if so can the P9 maintainer perhaps help out with testing?

/Bruce

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-06  9:08           ` Bruce Richardson
@ 2021-07-06 18:10             ` David Christensen
  2021-07-16 13:53               ` Juraj Linkeš
  0 siblings, 1 reply; 32+ messages in thread
From: David Christensen @ 2021-07-06 18:10 UTC (permalink / raw)
  To: Bruce Richardson, Juraj Linkeš
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev



On 7/6/21 2:08 AM, Bruce Richardson wrote:
> On Tue, Jul 06, 2021 at 08:56:37AM +0000, Juraj Linkeš wrote:
>>
>>
>>> -----Original Message-----
>>> From: Bruce Richardson <bruce.richardson@intel.com>
>>> Sent: Tuesday, June 29, 2021 1:29 PM
>>> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
>>> Cc: thomas@monjalon.net; david.marchand@redhat.com;
>>> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
>>> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
>>> Subject: Re: [PATCH v4] build: optional NUMA and cpu counts detection
>>>
>>> On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
>>>> Add an option to automatically discover the host's numa and cpu counts
>>>> and use those values for a non cross-build.
>>>> Give users the option to override the per-arch default values or
>>>> values from cross files by specifying them on the command line with
>>>> -Dmax_lcores and -Dmax_numa_nodes.
>>>>
>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>>>> ---
>>> Two very minor suggestions inline below.
>>>
>>> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>>>
>>>>
>>> <snip>
>>>> +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
>>>
>>> Rather than "auto", would "detect" be a clearer name for this option value?
>>>
>>> <snip>
>>>> +option('max_lcores', type: 'string', value: 'default', description:
>>>> +       'Set maximum number of cores/threads supported by EAL. The
>>>> +default is different per-arch. Set to auto to detect the number of cores on the
>>> build machine.') option('max_numa_nodes', type: 'string', value: 'default',
>>> description:
>>>> +       'Set highest NUMA node supported by EAL. The default is
>>>> +different per-arch. Set to auto to detect the highest numa node on
>>>> +the build machine.')
>>>
>>> I'd put the explicit values of "default" and "auto"(or "detect") in quotes "" to
>>> make clear they are literal values.
>>>
>>
>> Thanks, Bruce, I'll change it. I have one extra question now that I'm looking at the patch:
>> What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA node on the system (the highest number of all NUMA nodes)? I'm asking because of how NUMA works on P9:
>> NUMA node0 CPU(s):   0-63
>> NUMA node8 CPU(s):   64-127
>> NUMA node252 CPU(s):
>> NUMA node253 CPU(s):
>> NUMA node254 CPU(s):
>> NUMA node255 CPU(s):
>>
>> Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and Windows should return the highest NUMA, not sure about FreeBSD. Or maybe we should return the highest NUMA on which there are actual CPUs?
> 
> I'm not sure, and I think to be really sure we'd need it tested on a P9
> system. The help text for the sysctl node says "Number of physical memory
> domains available", which would imply 2 in the case above. [However, we also
> would need to find out how BSD numbers the domains, too, as it's possible
> an OS could just call them 0 and 1, rather than 0 and 8 if it wanted to.]
> 
> In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
> config, and if so can the P9 maintainer perhaps help out with testing?

Results of the v4 patch on an IBM AC922 P9 system with Linux:

$ python3 get-cpu-count.py
128
$ python3 get-numa-count.py
8
$ lscpu
Architecture:        ppc64le
Byte Order:          Little Endian
CPU(s):              128
On-line CPU(s) list: 0-127
Thread(s) per core:  4
Core(s) per socket:  16
Socket(s):           2
NUMA node(s):        6
Model:               2.3 (pvr 004e 1203)
Model name:          POWER9, altivec supported
CPU max MHz:         3800.0000
CPU min MHz:         2300.0000
L1d cache:           32K
L1i cache:           32K
L2 cache:            512K
L3 cache:            10240K
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
NUMA node253 CPU(s):
NUMA node254 CPU(s):
NUMA node255 CPU(s):

OVS has a problem with requiring contiguous NUMA nodes that we've 
submitted patches to fix, so we need to ensure that's not a problem in DPDK.

I've been doing things like "--socket-mem=2048,0,0,0,0,0,0,0,2048" so 
far to manage the memory-to-NUMA mapping which has been working fine, so 
it depends on how vm.ndomains will be.

Dave

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-06 18:10             ` David Christensen
@ 2021-07-16 13:53               ` Juraj Linkeš
  2021-07-16 14:24                 ` Bruce Richardson
  2021-07-20 20:49                 ` David Christensen
  0 siblings, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-07-16 13:53 UTC (permalink / raw)
  To: David Christensen, Bruce Richardson
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev



> -----Original Message-----
> From: David Christensen <drc@linux.vnet.ibm.com>
> Sent: Tuesday, July 6, 2021 8:11 PM
> To: Bruce Richardson <bruce.richardson@intel.com>; Juraj Linkeš
> <juraj.linkes@pantheon.tech>
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts
> detection
> 
> 
> 
> On 7/6/21 2:08 AM, Bruce Richardson wrote:
> > On Tue, Jul 06, 2021 at 08:56:37AM +0000, Juraj Linkeš wrote:
> >>
> >>
> >>> -----Original Message-----
> >>> From: Bruce Richardson <bruce.richardson@intel.com>
> >>> Sent: Tuesday, June 29, 2021 1:29 PM
> >>> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> >>> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> >>> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> >>> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> >>> Subject: Re: [PATCH v4] build: optional NUMA and cpu counts
> >>> detection
> >>>
> >>> On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
> >>>> Add an option to automatically discover the host's numa and cpu
> >>>> counts and use those values for a non cross-build.
> >>>> Give users the option to override the per-arch default values or
> >>>> values from cross files by specifying them on the command line with
> >>>> -Dmax_lcores and -Dmax_numa_nodes.
> >>>>
> >>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> >>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >>>> ---
> >>> Two very minor suggestions inline below.
> >>>
> >>> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> >>>
> >>>>
> >>> <snip>
> >>>> +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
> >>>
> >>> Rather than "auto", would "detect" be a clearer name for this option value?
> >>>
> >>> <snip>
> >>>> +option('max_lcores', type: 'string', value: 'default', description:
> >>>> +       'Set maximum number of cores/threads supported by EAL. The
> >>>> +default is different per-arch. Set to auto to detect the number of
> >>>> +cores on the
> >>> build machine.') option('max_numa_nodes', type: 'string', value:
> >>> 'default',
> >>> description:
> >>>> +       'Set highest NUMA node supported by EAL. The default is
> >>>> +different per-arch. Set to auto to detect the highest numa node on
> >>>> +the build machine.')
> >>>
> >>> I'd put the explicit values of "default" and "auto"(or "detect") in
> >>> quotes "" to make clear they are literal values.
> >>>
> >>
> >> Thanks, Bruce, I'll change it. I have one extra question now that I'm looking
> at the patch:
> >> What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return
> exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA
> node on the system (the highest number of all NUMA nodes)? I'm asking
> because of how NUMA works on P9:
> >> NUMA node0 CPU(s):   0-63
> >> NUMA node8 CPU(s):   64-127
> >> NUMA node252 CPU(s):
> >> NUMA node253 CPU(s):
> >> NUMA node254 CPU(s):
> >> NUMA node255 CPU(s):
> >>
> >> Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and
> Windows should return the highest NUMA, not sure about FreeBSD. Or maybe
> we should return the highest NUMA on which there are actual CPUs?
> >
> > I'm not sure, and I think to be really sure we'd need it tested on a
> > P9 system. The help text for the sysctl node says "Number of physical
> > memory domains available", which would imply 2 in the case above.
> > [However, we also would need to find out how BSD numbers the domains,
> > too, as it's possible an OS could just call them 0 and 1, rather than
> > 0 and 8 if it wanted to.]
> >
> > In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
> > config, and if so can the P9 maintainer perhaps help out with testing?
> 
> Results of the v4 patch on an IBM AC922 P9 system with Linux:
> 

Can you get results from FreeBSD as well?

> $ python3 get-numa-count.py
> 8
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
<snip>
Is this the right number for your case, i.e. are you able to use both numa nodes when RTE_MAX_NUMA_NODES=8?

Or maybe this is a question for Bruce or Thomas - what do we need to set in RTE_MAX_NUMA_NODES to be able to use all numa nodes on the system? The highest numa node number or that + 1? In linux, with 4 numa nodes, there will be node0-node3 under /sys/devices/system/node - do we need to set RTE_MAX_NUMA_NODES to 3 or 4?

> OVS has a problem with requiring contiguous NUMA nodes that we've submitted
> patches to fix, so we need to ensure that's not a problem in DPDK.
> 
> I've been doing things like "--socket-mem=2048,0,0,0,0,0,0,0,2048" so far to
> manage the memory-to-NUMA mapping which has been working fine, so it
> depends on how vm.ndomains will be.
> 
> Dave


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-16 13:53               ` Juraj Linkeš
@ 2021-07-16 14:24                 ` Bruce Richardson
  2021-07-20 20:49                 ` David Christensen
  1 sibling, 0 replies; 32+ messages in thread
From: Bruce Richardson @ 2021-07-16 14:24 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: David Christensen, thomas, david.marchand, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, dev

On Fri, Jul 16, 2021 at 01:53:18PM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: David Christensen <drc@linux.vnet.ibm.com>
> > Sent: Tuesday, July 6, 2021 8:11 PM
> > To: Bruce Richardson <bruce.richardson@intel.com>; Juraj Linkeš
> > <juraj.linkes@pantheon.tech>
> > Cc: thomas@monjalon.net; david.marchand@redhat.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts
> > detection
> > 
> > 
> > 
> > On 7/6/21 2:08 AM, Bruce Richardson wrote:
> > > On Tue, Jul 06, 2021 at 08:56:37AM +0000, Juraj Linkeš wrote:
> > >>
> > >>
> > >>> -----Original Message-----
> > >>> From: Bruce Richardson <bruce.richardson@intel.com>
> > >>> Sent: Tuesday, June 29, 2021 1:29 PM
> > >>> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > >>> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> > >>> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > >>> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
> > >>> Subject: Re: [PATCH v4] build: optional NUMA and cpu counts
> > >>> detection
> > >>>
> > >>> On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
> > >>>> Add an option to automatically discover the host's numa and cpu
> > >>>> counts and use those values for a non cross-build.
> > >>>> Give users the option to override the per-arch default values or
> > >>>> values from cross files by specifying them on the command line with
> > >>>> -Dmax_lcores and -Dmax_numa_nodes.
> > >>>>
> > >>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > >>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > >>>> ---
> > >>> Two very minor suggestions inline below.
> > >>>
> > >>> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > >>>
> > >>>>
> > >>> <snip>
> > >>>> +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
> > >>>
> > >>> Rather than "auto", would "detect" be a clearer name for this option value?
> > >>>
> > >>> <snip>
> > >>>> +option('max_lcores', type: 'string', value: 'default', description:
> > >>>> +       'Set maximum number of cores/threads supported by EAL. The
> > >>>> +default is different per-arch. Set to auto to detect the number of
> > >>>> +cores on the
> > >>> build machine.') option('max_numa_nodes', type: 'string', value:
> > >>> 'default',
> > >>> description:
> > >>>> +       'Set highest NUMA node supported by EAL. The default is
> > >>>> +different per-arch. Set to auto to detect the highest numa node on
> > >>>> +the build machine.')
> > >>>
> > >>> I'd put the explicit values of "default" and "auto"(or "detect") in
> > >>> quotes "" to make clear they are literal values.
> > >>>
> > >>
> > >> Thanks, Bruce, I'll change it. I have one extra question now that I'm looking
> > at the patch:
> > >> What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return
> > exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA
> > node on the system (the highest number of all NUMA nodes)? I'm asking
> > because of how NUMA works on P9:
> > >> NUMA node0 CPU(s):   0-63
> > >> NUMA node8 CPU(s):   64-127
> > >> NUMA node252 CPU(s):
> > >> NUMA node253 CPU(s):
> > >> NUMA node254 CPU(s):
> > >> NUMA node255 CPU(s):
> > >>
> > >> Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and
> > Windows should return the highest NUMA, not sure about FreeBSD. Or maybe
> > we should return the highest NUMA on which there are actual CPUs?
> > >
> > > I'm not sure, and I think to be really sure we'd need it tested on a
> > > P9 system. The help text for the sysctl node says "Number of physical
> > > memory domains available", which would imply 2 in the case above.
> > > [However, we also would need to find out how BSD numbers the domains,
> > > too, as it's possible an OS could just call them 0 and 1, rather than
> > > 0 and 8 if it wanted to.]
> > >
> > > In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
> > > config, and if so can the P9 maintainer perhaps help out with testing?
> > 
> > Results of the v4 patch on an IBM AC922 P9 system with Linux:
> > 
> 
> Can you get results from FreeBSD as well?
> 
> > $ python3 get-numa-count.py
> > 8
> > NUMA node0 CPU(s):   0-63
> > NUMA node8 CPU(s):   64-127
> <snip>
> Is this the right number for your case, i.e. are you able to use both numa nodes when RTE_MAX_NUMA_NODES=8?
> 
> Or maybe this is a question for Bruce or Thomas - what do we need to set in RTE_MAX_NUMA_NODES to be able to use all numa nodes on the system? The highest numa node number or that + 1? In linux, with 4 numa nodes, there will be node0-node3 under /sys/devices/system/node - do we need to set RTE_MAX_NUMA_NODES to 3 or 4?
>

4, I believe.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-16 13:53               ` Juraj Linkeš
  2021-07-16 14:24                 ` Bruce Richardson
@ 2021-07-20 20:49                 ` David Christensen
  2021-07-21 12:41                   ` Juraj Linkeš
  1 sibling, 1 reply; 32+ messages in thread
From: David Christensen @ 2021-07-20 20:49 UTC (permalink / raw)
  To: Juraj Linkeš, Bruce Richardson
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev



On 7/16/21 6:53 AM, Juraj Linkeš wrote:
> 
> 
>> -----Original Message-----
>> From: David Christensen <drc@linux.vnet.ibm.com>
>> Sent: Tuesday, July 6, 2021 8:11 PM
>> To: Bruce Richardson <bruce.richardson@intel.com>; Juraj Linkeš
>> <juraj.linkes@pantheon.tech>
>> Cc: thomas@monjalon.net; david.marchand@redhat.com;
>> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
>> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts
>> detection
>>
>>
>>
>> On 7/6/21 2:08 AM, Bruce Richardson wrote:
>>> On Tue, Jul 06, 2021 at 08:56:37AM +0000, Juraj Linkeš wrote:
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Bruce Richardson <bruce.richardson@intel.com>
>>>>> Sent: Tuesday, June 29, 2021 1:29 PM
>>>>> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
>>>>> Cc: thomas@monjalon.net; david.marchand@redhat.com;
>>>>> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
>>>>> ferruh.yigit@intel.com; jerinjacobk@gmail.com; dev@dpdk.org
>>>>> Subject: Re: [PATCH v4] build: optional NUMA and cpu counts
>>>>> detection
>>>>>
>>>>> On Tue, Jun 29, 2021 at 12:55:05PM +0200, Juraj Linkeš wrote:
>>>>>> Add an option to automatically discover the host's numa and cpu
>>>>>> counts and use those values for a non cross-build.
>>>>>> Give users the option to override the per-arch default values or
>>>>>> values from cross files by specifying them on the command line with
>>>>>> -Dmax_lcores and -Dmax_numa_nodes.
>>>>>>
>>>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>>>>>> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>>>>>> ---
>>>>> Two very minor suggestions inline below.
>>>>>
>>>>> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>>>>>
>>>>>>
>>>>> <snip>
>>>>>> +max_lcores = get_option('max_lcores') if max_lcores == 'auto'
>>>>>
>>>>> Rather than "auto", would "detect" be a clearer name for this option value?
>>>>>
>>>>> <snip>
>>>>>> +option('max_lcores', type: 'string', value: 'default', description:
>>>>>> +       'Set maximum number of cores/threads supported by EAL. The
>>>>>> +default is different per-arch. Set to auto to detect the number of
>>>>>> +cores on the
>>>>> build machine.') option('max_numa_nodes', type: 'string', value:
>>>>> 'default',
>>>>> description:
>>>>>> +       'Set highest NUMA node supported by EAL. The default is
>>>>>> +different per-arch. Set to auto to detect the highest numa node on
>>>>>> +the build machine.')
>>>>>
>>>>> I'd put the explicit values of "default" and "auto"(or "detect") in
>>>>> quotes "" to make clear they are literal values.
>>>>>
>>>>
>>>> Thanks, Bruce, I'll change it. I have one extra question now that I'm looking
>> at the patch:
>>>> What does subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False) return
>> exactly? Is the the number of NUMA nodes (looks like it) or the highest NUMA
>> node on the system (the highest number of all NUMA nodes)? I'm asking
>> because of how NUMA works on P9:
>>>> NUMA node0 CPU(s):   0-63
>>>> NUMA node8 CPU(s):   64-127
>>>> NUMA node252 CPU(s):
>>>> NUMA node253 CPU(s):
>>>> NUMA node254 CPU(s):
>>>> NUMA node255 CPU(s):
>>>>
>>>> Here we need not just two NUMA nodes, but at least 9 (0-8). Linux and
>> Windows should return the highest NUMA, not sure about FreeBSD. Or maybe
>> we should return the highest NUMA on which there are actual CPUs?
>>>
>>> I'm not sure, and I think to be really sure we'd need it tested on a
>>> P9 system. The help text for the sysctl node says "Number of physical
>>> memory domains available", which would imply 2 in the case above.
>>> [However, we also would need to find out how BSD numbers the domains,
>>> too, as it's possible an OS could just call them 0 and 1, rather than
>>> 0 and 8 if it wanted to.]
>>>
>>> In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
>>> config, and if so can the P9 maintainer perhaps help out with testing?
>>
>> Results of the v4 patch on an IBM AC922 P9 system with Linux:
>>
> 
> Can you get results from FreeBSD as well?

I can't help with FreeBSD here, I only have Linux on systems within IBM.

> 
>> $ python3 get-numa-count.py
>> 8
>> NUMA node0 CPU(s):   0-63
>> NUMA node8 CPU(s):   64-127
> <snip>
> Is this the right number for your case, i.e. are you able to use both numa nodes when RTE_MAX_NUMA_NODES=8?

node8 above is the ninth NUMA node so I'd need to use 
RTE_MAX_NUMA_NODES=9 as a minimum so that any arrays using that value 
are adequately sized.

Dave

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: optional NUMA and cpu counts detection
  2021-07-20 20:49                 ` David Christensen
@ 2021-07-21 12:41                   ` Juraj Linkeš
  0 siblings, 0 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-07-21 12:41 UTC (permalink / raw)
  To: David Christensen, Bruce Richardson
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev

> >>> [However, we also would need to find out how BSD numbers the
> >>> domains, too, as it's possible an OS could just call them 0 and 1,
> >>> rather than
> >>> 0 and 8 if it wanted to.]
> >>>
> >>> In short, we'd need to test to be sure. Is FreeBSD on P9 a supported
> >>> config, and if so can the P9 maintainer perhaps help out with testing?
> >>
> >> Results of the v4 patch on an IBM AC922 P9 system with Linux:
> >>
> >
> > Can you get results from FreeBSD as well?
> 
> I can't help with FreeBSD here, I only have Linux on systems within IBM.
> 

This is an open question still then. I guess we'll have to go with sysctl -n vm.ndomains.

> >
> >> $ python3 get-numa-count.py
> >> 8
> >> NUMA node0 CPU(s):   0-63
> >> NUMA node8 CPU(s):   64-127
> > <snip>
> > Is this the right number for your case, i.e. are you able to use both numa nodes
> when RTE_MAX_NUMA_NODES=8?
> 
> node8 above is the ninth NUMA node so I'd need to use
> RTE_MAX_NUMA_NODES=9 as a minimum so that any arrays using that value
> are adequately sized.
> 
> Dave

Ok, the proper value to return is highest numa node + 1 then.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  2021-06-29 11:28       ` Bruce Richardson
  2021-06-29 18:00       ` Stephen Hemminger
@ 2021-07-21 13:04       ` Juraj Linkeš
  2021-08-02 12:44         ` Juraj Linkeš
  2021-08-17 10:45         ` [dpdk-dev] [PATCH v6] " Juraj Linkeš
  2 siblings, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-07-21 13:04 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, drc, stephen
  Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 24 ++++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index af2a91d7c4..f0e82598aa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -102,6 +102,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/chkincs/
 F: buildtools/call-sphinx-build.py
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 0000000000..317b32088f
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 0000000000..1b7787787f
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        numa_nodes = glob.glob('/sys/devices/system/node/node*')
+        numa_nodes.sort()
+        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    numa_count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(numa_count))
+    print(numa_count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index bd460e3e00..f776316da1 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -16,6 +16,8 @@ echo = py3 + ['-c', 'import sys; print(*sys.argv[1:])']
 list_dir_globs = py3 + files('list-dir-globs.py')
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index e80421003b..364788c32d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -286,8 +286,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -321,6 +319,51 @@ if meson.is_cross_build()
     endif
 endif
 
+max_lcores = get_option('max_lcores')
+if max_lcores == 'detect'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores.to_int())
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes == 'detect'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes.to_int())
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index b9348c44de..872dda9585 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -57,3 +57,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
diff --git a/meson_options.txt b/meson_options.txt
index 0e92734c49..b56e3b83c7 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,10 +34,10 @@ option('machine', type: 'string', value: 'auto', description:
        'Alias of cpu_instruction_set.')
 option('max_ethports', type: 'integer', value: 32, description:
        'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128, description:
-       'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 32, description:
-       'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'string', value: 'default', description:
+       'Set maximum number of cores/threads supported by EAL; "default" is different per-arch, "detect" detects the number of cores on the build machine.')
+option('max_numa_nodes', type: 'string', value: 'default', description:
+       'Set the highest NUMA node supported by EAL; "default" is different per-arch, "detect" detects the highest numa node on the build machine.')
 option('platform', type: 'string', value: 'native', description:
        'Platform to build, either "native", "generic" or a SoC. Please refer to the Linux build guide for more information.')
 option('enable_trace_fp', type: 'boolean', value: false, description:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-07-21 13:04       ` [dpdk-dev] [PATCH v5] " Juraj Linkeš
@ 2021-08-02 12:44         ` Juraj Linkeš
  2021-08-02 23:29           ` David Christensen
  2021-08-17 10:45         ` [dpdk-dev] [PATCH v6] " Juraj Linkeš
  1 sibling, 1 reply; 32+ messages in thread
From: Juraj Linkeš @ 2021-08-02 12:44 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, drc, stephen
  Cc: dev

> +if os.name == 'posix':
> +    if os.path.isdir('/sys/devices/system/node'):
> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> +        numa_nodes.sort()
> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
> +    else:
> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
> +

Bruce, David, Thomas,

Is DPDK actually supported on Power9 FreeBSD? Is anyone using this combination? How can we address the open question of what exactly does sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or should we just leave it as is? Or maybe add 1 to the output (as we do in other cases)?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-02 12:44         ` Juraj Linkeš
@ 2021-08-02 23:29           ` David Christensen
  2021-08-03 10:21             ` Juraj Linkeš
  0 siblings, 1 reply; 32+ messages in thread
From: David Christensen @ 2021-08-02 23:29 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, stephen,
	Piotr Kubaj
  Cc: dev



On 8/2/21 5:44 AM, Juraj Linkeš wrote:
>> +if os.name == 'posix':
>> +    if os.path.isdir('/sys/devices/system/node'):
>> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
>> +        numa_nodes.sort()
>> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
>> +    else:
>> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
>> +
> 
> Bruce, David, Thomas,
> 
> Is DPDK actually supported on Power9 FreeBSD? Is anyone using this combination? How can we address the open question of what exactly does sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or should we just leave it as is? Or maybe add 1 to the output (as we do in other cases)?

Not supported within IBM, but you can buy OpenPOWER boxes from 3rd 
parties such as Raptor Computing Systems so there may be customers using 
DPDK on POWER with FreeBSD that I don't track.  Adding Piotr Kubaj who 
has commented on POWER/FreeBSD issues in this past.

Dave

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-02 23:29           ` David Christensen
@ 2021-08-03 10:21             ` Juraj Linkeš
  2021-08-31  0:54               ` Piotr Kubaj
  0 siblings, 1 reply; 32+ messages in thread
From: Juraj Linkeš @ 2021-08-03 10:21 UTC (permalink / raw)
  To: David Christensen, thomas, david.marchand, bruce.richardson,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, Piotr Kubaj
  Cc: dev



> -----Original Message-----
> From: David Christensen <drc@linux.vnet.ibm.com>
> Sent: Tuesday, August 3, 2021 1:29 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> david.marchand@redhat.com; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> stephen@networkplumber.org; Piotr Kubaj <pkubaj@FreeBSD.org>
> Cc: dev@dpdk.org
> Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> 
> 
> 
> On 8/2/21 5:44 AM, Juraj Linkeš wrote:
> >> +if os.name == 'posix':
> >> +    if os.path.isdir('/sys/devices/system/node'):
> >> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> >> +        numa_nodes.sort()
> >> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
> >> +    else:
> >> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
> >> +
> >
> > Bruce, David, Thomas,
> >
> > Is DPDK actually supported on Power9 FreeBSD? Is anyone using this
> combination? How can we address the open question of what exactly does
> sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or should we just
> leave it as is? Or maybe add 1 to the output (as we do in other cases)?
> 
> Not supported within IBM, but you can buy OpenPOWER boxes from 3rd parties
> such as Raptor Computing Systems so there may be customers using DPDK on
> POWER with FreeBSD that I don't track.  Adding Piotr Kubaj who has commented
> on POWER/FreeBSD issues in this past.
> 
> Dave

Thanks, David.

Piotr, to provide more context, we're trying to figure out what the highest NUMA node on a system is.
On P9 systems, here's how NUMA nodes look like in Linux:
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
NUMA node253 CPU(s):
NUMA node254 CPU(s):
NUMA node255 CPU(s):
The highest NUMA with CPUs is node8.

We're trying to get the highest NUMA with CPUs on P9 FreeBSD systems, but we don't know whether FreeBSD NUMA layout looks the same (does FreeBSD report non-contiguous NUMA nodes as Linxu above, or does it renumerate) a what does "systemctl -n vm.ndomains" return. Could you check these for us?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [dpdk-dev] [PATCH v6] build: optional NUMA and cpu counts detection
  2021-07-21 13:04       ` [dpdk-dev] [PATCH v5] " Juraj Linkeš
  2021-08-02 12:44         ` Juraj Linkeš
@ 2021-08-17 10:45         ` Juraj Linkeš
  2021-09-16  7:46           ` Thomas Monjalon
  1 sibling, 1 reply; 32+ messages in thread
From: Juraj Linkeš @ 2021-08-17 10:45 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, drc, stephen
  Cc: dev, Juraj Linkeš

Add an option to automatically discover the host's numa and cpu counts
and use those values for a non cross-build.
Give users the option to override the per-arch default values or values
from cross files by specifying them on the command line with -Dmax_lcores
and -Dmax_numa_nodes.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
v6: rebase
---
 MAINTAINERS                  |  2 ++
 buildtools/get-cpu-count.py  |  7 ++++++
 buildtools/get-numa-count.py | 24 ++++++++++++++++++
 buildtools/meson.build       |  2 ++
 config/meson.build           | 47 ++++++++++++++++++++++++++++++++++--
 config/x86/meson.build       |  2 ++
 meson_options.txt            |  8 +++---
 7 files changed, 86 insertions(+), 6 deletions(-)
 create mode 100644 buildtools/get-cpu-count.py
 create mode 100644 buildtools/get-numa-count.py

diff --git a/MAINTAINERS b/MAINTAINERS
index 266f5ac1da..629d5c40cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -102,6 +102,8 @@ F: meson_options.txt
 F: config/
 F: buildtools/chkincs/
 F: buildtools/call-sphinx-build.py
+F: buildtools/get-cpu-count.py
+F: buildtools/get-numa-count.py
 F: buildtools/list-dir-globs.py
 F: buildtools/pkg-config/
 F: buildtools/symlink-drivers-solibs.sh
diff --git a/buildtools/get-cpu-count.py b/buildtools/get-cpu-count.py
new file mode 100644
index 0000000000..317b32088f
--- /dev/null
+++ b/buildtools/get-cpu-count.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import os
+
+print(os.cpu_count())
diff --git a/buildtools/get-numa-count.py b/buildtools/get-numa-count.py
new file mode 100644
index 0000000000..1b7787787f
--- /dev/null
+++ b/buildtools/get-numa-count.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (c) 2021 PANTHEON.tech s.r.o.
+
+import ctypes
+import glob
+import os
+import subprocess
+
+if os.name == 'posix':
+    if os.path.isdir('/sys/devices/system/node'):
+        numa_nodes = glob.glob('/sys/devices/system/node/node*')
+        numa_nodes.sort()
+        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
+    else:
+        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
+
+elif os.name == 'nt':
+    libkernel32 = ctypes.windll.kernel32
+
+    numa_count = ctypes.c_ulong()
+
+    libkernel32.GetNumaHighestNodeNumber(ctypes.pointer(numa_count))
+    print(numa_count.value + 1)
diff --git a/buildtools/meson.build b/buildtools/meson.build
index bd460e3e00..f776316da1 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -16,6 +16,8 @@ echo = py3 + ['-c', 'import sys; print(*sys.argv[1:])']
 list_dir_globs = py3 + files('list-dir-globs.py')
 map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
+get_cpu_count_cmd = py3 + files('get-cpu-count.py')
+get_numa_count_cmd = py3 + files('get-numa-count.py')
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index e80421003b..364788c32d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -286,8 +286,6 @@ foreach arg: warning_flags
 endforeach
 
 # set other values pulled from the build options
-dpdk_conf.set('RTE_MAX_LCORE', get_option('max_lcores'))
-dpdk_conf.set('RTE_MAX_NUMA_NODES', get_option('max_numa_nodes'))
 dpdk_conf.set('RTE_MAX_ETHPORTS', get_option('max_ethports'))
 dpdk_conf.set('RTE_LIBEAL_USE_HPET', get_option('use_hpet'))
 dpdk_conf.set('RTE_ENABLE_TRACE_FP', get_option('enable_trace_fp'))
@@ -321,6 +319,51 @@ if meson.is_cross_build()
     endif
 endif
 
+max_lcores = get_option('max_lcores')
+if max_lcores == 'detect'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_lcores is not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_lcores = run_command(get_cpu_count_cmd).stdout().to_int()
+	min_lcores = 2
+	# DPDK must be build for at least 2 cores
+	if max_lcores < min_lcores
+		message('Found less than @0@ cores, building for @0@ cores'.format(min_lcores))
+		max_lcores = min_lcores
+	else
+		message('Found @0@ cores'.format(max_lcores))
+	endif
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores)
+elif max_lcores != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcores.to_int())
+endif
+
+max_numa_nodes = get_option('max_numa_nodes')
+if max_numa_nodes == 'detect'
+	# Discovery makes sense only for non-cross builds
+	if meson.is_cross_build()
+		error('Discovery of max_numa_nodes not supported for cross-compilation.')
+	endif
+	# Overwrite the default value with discovered values
+	max_numa_nodes = run_command(get_numa_count_cmd).stdout().to_int()
+	message('Found @0@ numa nodes'.format(max_numa_nodes))
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes)
+elif max_numa_nodes != 'default'
+	# Overwrite the default value from arch_subdir with user input
+	dpdk_conf.set('RTE_MAX_NUMA_NODES', max_numa_nodes.to_int())
+endif
+
+# check that cpu and numa count is set and error out if it's not set
+if not dpdk_conf.has('RTE_MAX_LCORE')
+	error('Number of cores not specified.')
+endif
+if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
+	error('Number of numa nodes not specified.')
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 704ba3db56..29f3dea181 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -70,3 +70,5 @@ else
 endif
 
 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 64)
+dpdk_conf.set('RTE_MAX_LCORE', 128)
+dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
diff --git a/meson_options.txt b/meson_options.txt
index 0e92734c49..b56e3b83c7 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,10 +34,10 @@ option('machine', type: 'string', value: 'auto', description:
        'Alias of cpu_instruction_set.')
 option('max_ethports', type: 'integer', value: 32, description:
        'maximum number of Ethernet devices')
-option('max_lcores', type: 'integer', value: 128, description:
-       'maximum number of cores/threads supported by EAL')
-option('max_numa_nodes', type: 'integer', value: 32, description:
-       'maximum number of NUMA nodes supported by EAL')
+option('max_lcores', type: 'string', value: 'default', description:
+       'Set maximum number of cores/threads supported by EAL; "default" is different per-arch, "detect" detects the number of cores on the build machine.')
+option('max_numa_nodes', type: 'string', value: 'default', description:
+       'Set the highest NUMA node supported by EAL; "default" is different per-arch, "detect" detects the highest numa node on the build machine.')
 option('platform', type: 'string', value: 'native', description:
        'Platform to build, either "native", "generic" or a SoC. Please refer to the Linux build guide for more information.')
 option('enable_trace_fp', type: 'boolean', value: false, description:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-03 10:21             ` Juraj Linkeš
@ 2021-08-31  0:54               ` Piotr Kubaj
  2021-08-31  7:54                 ` Juraj Linkeš
  0 siblings, 1 reply; 32+ messages in thread
From: Piotr Kubaj @ 2021-08-31  0:54 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: David Christensen, thomas, david.marchand, bruce.richardson,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev

[-- Attachment #1: Type: text/plain, Size: 2541 bytes --]

Hi,

sorry for the late answer.

I suppose you mean sysctl command, not systemctl.

On dual CPU systems, it returns 2. On single CPU ones, 1.

On 21-08-03 10:21:50, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: David Christensen <drc@linux.vnet.ibm.com>
> > Sent: Tuesday, August 3, 2021 1:29 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> > david.marchand@redhat.com; bruce.richardson@intel.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > stephen@networkplumber.org; Piotr Kubaj <pkubaj@FreeBSD.org>
> > Cc: dev@dpdk.org
> > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> > 
> > 
> > 
> > On 8/2/21 5:44 AM, Juraj Linkeš wrote:
> > >> +if os.name == 'posix':
> > >> +    if os.path.isdir('/sys/devices/system/node'):
> > >> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> > >> +        numa_nodes.sort()
> > >> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
> > >> +    else:
> > >> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'], check=False)
> > >> +
> > >
> > > Bruce, David, Thomas,
> > >
> > > Is DPDK actually supported on Power9 FreeBSD? Is anyone using this
> > combination? How can we address the open question of what exactly does
> > sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or should we just
> > leave it as is? Or maybe add 1 to the output (as we do in other cases)?
> > 
> > Not supported within IBM, but you can buy OpenPOWER boxes from 3rd parties
> > such as Raptor Computing Systems so there may be customers using DPDK on
> > POWER with FreeBSD that I don't track.  Adding Piotr Kubaj who has commented
> > on POWER/FreeBSD issues in this past.
> > 
> > Dave
> 
> Thanks, David.
> 
> Piotr, to provide more context, we're trying to figure out what the highest NUMA node on a system is.
> On P9 systems, here's how NUMA nodes look like in Linux:
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
> NUMA node252 CPU(s):
> NUMA node253 CPU(s):
> NUMA node254 CPU(s):
> NUMA node255 CPU(s):
> The highest NUMA with CPUs is node8.
> 
> We're trying to get the highest NUMA with CPUs on P9 FreeBSD systems, but we don't know whether FreeBSD NUMA layout looks the same (does FreeBSD report non-contiguous NUMA nodes as Linxu above, or does it renumerate) a what does "systemctl -n vm.ndomains" return. Could you check these for us?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-31  0:54               ` Piotr Kubaj
@ 2021-08-31  7:54                 ` Juraj Linkeš
  2021-08-31  8:02                   ` Bruce Richardson
  2021-08-31 12:32                   ` Piotr Kubaj
  0 siblings, 2 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-08-31  7:54 UTC (permalink / raw)
  To: Piotr Kubaj
  Cc: David Christensen, thomas, david.marchand, bruce.richardson,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev



> -----Original Message-----
> From: Piotr Kubaj <pkubaj@anongoth.pl>
> Sent: Tuesday, August 31, 2021 2:55 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> david.marchand@redhat.com; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> stephen@networkplumber.org; dev@dpdk.org
> Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> 
> Hi,
> 
> sorry for the late answer.

Thanks for the answer anyway, better late than never.

> 
> I suppose you mean sysctl command, not systemctl.
> 

That's right. What does lscpu say? Are the NUMA nodes non-contiguous like this?:
NUMA node0 CPU(s):   0-63
NUMA node8 CPU(s):   64-127
NUMA node252 CPU(s):
NUMA node253 CPU(s):
NUMA node254 CPU(s):
NUMA node255 CPU(s):

> On dual CPU systems, it returns 2. On single CPU ones, 1.

I asked the previous question so that we know the actual numa node number of the second CPU. If it's 8, then sysctl does some renumeration and we can't use it.

Bruce, maybe we should just parse lscpu output? That introduces a dependency, but that may not be such a big deal as lscpu is pretty common.

> 
> On 21-08-03 10:21:50, Juraj Linkeš wrote:
> >
> >
> > > -----Original Message-----
> > > From: David Christensen <drc@linux.vnet.ibm.com>
> > > Sent: Tuesday, August 3, 2021 1:29 AM
> > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> > > david.marchand@redhat.com; bruce.richardson@intel.com;
> > > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > > stephen@networkplumber.org; Piotr Kubaj <pkubaj@FreeBSD.org>
> > > Cc: dev@dpdk.org
> > > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts
> > > detection
> > >
> > >
> > >
> > > On 8/2/21 5:44 AM, Juraj Linkeš wrote:
> > > >> +if os.name == 'posix':
> > > >> +    if os.path.isdir('/sys/devices/system/node'):
> > > >> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> > > >> +        numa_nodes.sort()
> > > >> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
> > > >> +    else:
> > > >> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'],
> > > >> +check=False)
> > > >> +
> > > >
> > > > Bruce, David, Thomas,
> > > >
> > > > Is DPDK actually supported on Power9 FreeBSD? Is anyone using this
> > > combination? How can we address the open question of what exactly
> > > does sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or
> > > should we just leave it as is? Or maybe add 1 to the output (as we do in other
> cases)?
> > >
> > > Not supported within IBM, but you can buy OpenPOWER boxes from 3rd
> > > parties such as Raptor Computing Systems so there may be customers
> > > using DPDK on POWER with FreeBSD that I don't track.  Adding Piotr
> > > Kubaj who has commented on POWER/FreeBSD issues in this past.
> > >
> > > Dave
> >
> > Thanks, David.
> >
> > Piotr, to provide more context, we're trying to figure out what the highest
> NUMA node on a system is.
> > On P9 systems, here's how NUMA nodes look like in Linux:
> > NUMA node0 CPU(s):   0-63
> > NUMA node8 CPU(s):   64-127
> > NUMA node252 CPU(s):
> > NUMA node253 CPU(s):
> > NUMA node254 CPU(s):
> > NUMA node255 CPU(s):
> > The highest NUMA with CPUs is node8.
> >
> > We're trying to get the highest NUMA with CPUs on P9 FreeBSD systems, but
> we don't know whether FreeBSD NUMA layout looks the same (does FreeBSD
> report non-contiguous NUMA nodes as Linxu above, or does it renumerate) a
> what does "systemctl -n vm.ndomains" return. Could you check these for us?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-31  7:54                 ` Juraj Linkeš
@ 2021-08-31  8:02                   ` Bruce Richardson
  2021-09-09  7:20                     ` Juraj Linkeš
  2021-08-31 12:32                   ` Piotr Kubaj
  1 sibling, 1 reply; 32+ messages in thread
From: Bruce Richardson @ 2021-08-31  8:02 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Piotr Kubaj, David Christensen, thomas, david.marchand,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev

On Tue, Aug 31, 2021 at 07:54:16AM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Piotr Kubaj <pkubaj@anongoth.pl>
> > Sent: Tuesday, August 31, 2021 2:55 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > david.marchand@redhat.com; bruce.richardson@intel.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > stephen@networkplumber.org; dev@dpdk.org
> > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> > 
> > Hi,
> > 
> > sorry for the late answer.
> 
> Thanks for the answer anyway, better late than never.
> 
> > 
> > I suppose you mean sysctl command, not systemctl.
> > 
> 
> That's right. What does lscpu say? Are the NUMA nodes non-contiguous like this?:
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
> NUMA node252 CPU(s):
> NUMA node253 CPU(s):
> NUMA node254 CPU(s):
> NUMA node255 CPU(s):
> 
> > On dual CPU systems, it returns 2. On single CPU ones, 1.
> 
> I asked the previous question so that we know the actual numa node number of the second CPU. If it's 8, then sysctl does some renumeration and we can't use it.
> 
> Bruce, maybe we should just parse lscpu output? That introduces a dependency, but that may not be such a big deal as lscpu is pretty common.
> 
Until we are sure that we need it, can we just keep things simple? Perhaps
we can use lscpu if present, and fallback to sysctl output if not.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-31  7:54                 ` Juraj Linkeš
  2021-08-31  8:02                   ` Bruce Richardson
@ 2021-08-31 12:32                   ` Piotr Kubaj
  1 sibling, 0 replies; 32+ messages in thread
From: Piotr Kubaj @ 2021-08-31 12:32 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: David Christensen, thomas, david.marchand, bruce.richardson,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev

[-- Attachment #1: Type: text/plain, Size: 4247 bytes --]

On 21-08-31 07:54:16, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Piotr Kubaj <pkubaj@anongoth.pl>
> > Sent: Tuesday, August 31, 2021 2:55 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > david.marchand@redhat.com; bruce.richardson@intel.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > stephen@networkplumber.org; dev@dpdk.org
> > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> > 
> > Hi,
> > 
> > sorry for the late answer.
> 
> Thanks for the answer anyway, better late than never.
> 
> > 
> > I suppose you mean sysctl command, not systemctl.
> > 
> 
> That's right. What does lscpu say? Are the NUMA nodes non-contiguous like this?:
> NUMA node0 CPU(s):   0-63
> NUMA node8 CPU(s):   64-127
> NUMA node252 CPU(s):
> NUMA node253 CPU(s):
> NUMA node254 CPU(s):
> NUMA node255 CPU(s):
> 
> > On dual CPU systems, it returns 2. On single CPU ones, 1.
> 
> I asked the previous question so that we know the actual numa node number of the second CPU. If it's 8, then sysctl does some renumeration and we can't use it.
> 
> Bruce, maybe we should just parse lscpu output? That introduces a dependency, but that may not be such a big deal as lscpu is pretty common.
There's no lscpu on FreeBSD in the base system. There is one in packages, but it's written only for amd64 / i386 since it uses CPUID. https://github.com/NanXiao/lscpu


> 
> > 
> > On 21-08-03 10:21:50, Juraj Linkeš wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: David Christensen <drc@linux.vnet.ibm.com>
> > > > Sent: Tuesday, August 3, 2021 1:29 AM
> > > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> > > > david.marchand@redhat.com; bruce.richardson@intel.com;
> > > > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > > > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > > > stephen@networkplumber.org; Piotr Kubaj <pkubaj@FreeBSD.org>
> > > > Cc: dev@dpdk.org
> > > > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts
> > > > detection
> > > >
> > > >
> > > >
> > > > On 8/2/21 5:44 AM, Juraj Linkeš wrote:
> > > > >> +if os.name == 'posix':
> > > > >> +    if os.path.isdir('/sys/devices/system/node'):
> > > > >> +        numa_nodes = glob.glob('/sys/devices/system/node/node*')
> > > > >> +        numa_nodes.sort()
> > > > >> +        print(int(os.path.basename(numa_nodes[-1])[4:]) + 1)
> > > > >> +    else:
> > > > >> +        subprocess.run(['sysctl', '-n', 'vm.ndomains'],
> > > > >> +check=False)
> > > > >> +
> > > > >
> > > > > Bruce, David, Thomas,
> > > > >
> > > > > Is DPDK actually supported on Power9 FreeBSD? Is anyone using this
> > > > combination? How can we address the open question of what exactly
> > > > does sysctl -n vm.ndomains return on a Power9 FreeBSD system? Or
> > > > should we just leave it as is? Or maybe add 1 to the output (as we do in other
> > cases)?
> > > >
> > > > Not supported within IBM, but you can buy OpenPOWER boxes from 3rd
> > > > parties such as Raptor Computing Systems so there may be customers
> > > > using DPDK on POWER with FreeBSD that I don't track.  Adding Piotr
> > > > Kubaj who has commented on POWER/FreeBSD issues in this past.
> > > >
> > > > Dave
> > >
> > > Thanks, David.
> > >
> > > Piotr, to provide more context, we're trying to figure out what the highest
> > NUMA node on a system is.
> > > On P9 systems, here's how NUMA nodes look like in Linux:
> > > NUMA node0 CPU(s):   0-63
> > > NUMA node8 CPU(s):   64-127
> > > NUMA node252 CPU(s):
> > > NUMA node253 CPU(s):
> > > NUMA node254 CPU(s):
> > > NUMA node255 CPU(s):
> > > The highest NUMA with CPUs is node8.
> > >
> > > We're trying to get the highest NUMA with CPUs on P9 FreeBSD systems, but
> > we don't know whether FreeBSD NUMA layout looks the same (does FreeBSD
> > report non-contiguous NUMA nodes as Linxu above, or does it renumerate) a
> > what does "systemctl -n vm.ndomains" return. Could you check these for us?

-- 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-08-31  8:02                   ` Bruce Richardson
@ 2021-09-09  7:20                     ` Juraj Linkeš
  2021-09-09  8:01                       ` Bruce Richardson
  0 siblings, 1 reply; 32+ messages in thread
From: Juraj Linkeš @ 2021-09-09  7:20 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: Piotr Kubaj, David Christensen, thomas, david.marchand,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, August 31, 2021 10:03 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: Piotr Kubaj <pkubaj@anongoth.pl>; David Christensen
> <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> david.marchand@redhat.com; Honnappa.Nagarahalli@arm.com;
> Ruifeng.Wang@arm.com; ferruh.yigit@intel.com; jerinjacobk@gmail.com;
> jerinj@marvell.com; stephen@networkplumber.org; dev@dpdk.org
> Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> 
> On Tue, Aug 31, 2021 at 07:54:16AM +0000, Juraj Linkeš wrote:
> >
> >
> > > -----Original Message-----
> > > From: Piotr Kubaj <pkubaj@anongoth.pl>
> > > Sent: Tuesday, August 31, 2021 2:55 AM
> > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > > david.marchand@redhat.com; bruce.richardson@intel.com;
> > > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > > stephen@networkplumber.org; dev@dpdk.org
> > > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts
> > > detection
> > >
> > > Hi,
> > >
> > > sorry for the late answer.
> >
> > Thanks for the answer anyway, better late than never.
> >
> > >
> > > I suppose you mean sysctl command, not systemctl.
> > >
> >
> > That's right. What does lscpu say? Are the NUMA nodes non-contiguous like
> this?:
> > NUMA node0 CPU(s):   0-63
> > NUMA node8 CPU(s):   64-127
> > NUMA node252 CPU(s):
> > NUMA node253 CPU(s):
> > NUMA node254 CPU(s):
> > NUMA node255 CPU(s):
> >
> > > On dual CPU systems, it returns 2. On single CPU ones, 1.
> >
> > I asked the previous question so that we know the actual numa node number
> of the second CPU. If it's 8, then sysctl does some renumeration and we can't
> use it.
> >
> > Bruce, maybe we should just parse lscpu output? That introduces a
> dependency, but that may not be such a big deal as lscpu is pretty common.
> >
> Until we are sure that we need it, can we just keep things simple? Perhaps we
> can use lscpu if present, and fallback to sysctl output if not.

Piotr says lscpu isn't available on ppc FreeBSD. I think this leaves us with two options:
1. either use sysctl with the risk that it may not return an accurate value
2. not support PPC for numa detection

What do you think?

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-09-09  7:20                     ` Juraj Linkeš
@ 2021-09-09  8:01                       ` Bruce Richardson
  2021-09-09  8:08                         ` Thomas Monjalon
  2021-09-09 16:44                         ` David Christensen
  0 siblings, 2 replies; 32+ messages in thread
From: Bruce Richardson @ 2021-09-09  8:01 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: Piotr Kubaj, David Christensen, thomas, david.marchand,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev

On Thu, Sep 09, 2021 at 07:20:27AM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Tuesday, August 31, 2021 10:03 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: Piotr Kubaj <pkubaj@anongoth.pl>; David Christensen
> > <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > david.marchand@redhat.com; Honnappa.Nagarahalli@arm.com;
> > Ruifeng.Wang@arm.com; ferruh.yigit@intel.com; jerinjacobk@gmail.com;
> > jerinj@marvell.com; stephen@networkplumber.org; dev@dpdk.org
> > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> > 
> > On Tue, Aug 31, 2021 at 07:54:16AM +0000, Juraj Linkeš wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Piotr Kubaj <pkubaj@anongoth.pl>
> > > > Sent: Tuesday, August 31, 2021 2:55 AM
> > > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > > > david.marchand@redhat.com; bruce.richardson@intel.com;
> > > > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> > > > ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> > > > stephen@networkplumber.org; dev@dpdk.org
> > > > Subject: Re: [PATCH v5] build: optional NUMA and cpu counts
> > > > detection
> > > >
> > > > Hi,
> > > >
> > > > sorry for the late answer.
> > >
> > > Thanks for the answer anyway, better late than never.
> > >
> > > >
> > > > I suppose you mean sysctl command, not systemctl.
> > > >
> > >
> > > That's right. What does lscpu say? Are the NUMA nodes non-contiguous like
> > this?:
> > > NUMA node0 CPU(s):   0-63
> > > NUMA node8 CPU(s):   64-127
> > > NUMA node252 CPU(s):
> > > NUMA node253 CPU(s):
> > > NUMA node254 CPU(s):
> > > NUMA node255 CPU(s):
> > >
> > > > On dual CPU systems, it returns 2. On single CPU ones, 1.
> > >
> > > I asked the previous question so that we know the actual numa node number
> > of the second CPU. If it's 8, then sysctl does some renumeration and we can't
> > use it.
> > >
> > > Bruce, maybe we should just parse lscpu output? That introduces a
> > dependency, but that may not be such a big deal as lscpu is pretty common.
> > >
> > Until we are sure that we need it, can we just keep things simple? Perhaps we
> > can use lscpu if present, and fallback to sysctl output if not.
> 
> Piotr says lscpu isn't available on ppc FreeBSD. I think this leaves us with two options:
> 1. either use sysctl with the risk that it may not return an accurate value
> 2. not support PPC for numa detection
> 
> What do you think?

I think point #2 is more not supporting FreeBSD on PPC for numa detection
rather than not supporting PPC generally, right? Personally, I am just in
favour of #1 for the sake of moving forward and giving us best support with
simplest code. If or when someone does hit this (FreeBSD+PPC) as a problem,
then we can work with them to find best solution for fixing it. Right now
we don't have anyone with the PPC+FreeBSD setup, so I'd rather ignore it
than implement more complicated solutions that we can't test "just in
case".

/Bruce

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-09-09  8:01                       ` Bruce Richardson
@ 2021-09-09  8:08                         ` Thomas Monjalon
  2021-09-09  8:42                           ` Juraj Linkeš
  2021-09-09 16:44                         ` David Christensen
  1 sibling, 1 reply; 32+ messages in thread
From: Thomas Monjalon @ 2021-09-09  8:08 UTC (permalink / raw)
  To: Juraj Linkeš, Bruce Richardson
  Cc: Piotr Kubaj, David Christensen, david.marchand,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev

09/09/2021 10:01, Bruce Richardson:
> On Thu, Sep 09, 2021 at 07:20:27AM +0000, Juraj Linkeš wrote:
> > Piotr says lscpu isn't available on ppc FreeBSD. I think this leaves us with two options:
> > 1. either use sysctl with the risk that it may not return an accurate value
> > 2. not support PPC for numa detection
> > 
> > What do you think?
> 
> I think point #2 is more not supporting FreeBSD on PPC for numa detection
> rather than not supporting PPC generally, right? Personally, I am just in
> favour of #1 for the sake of moving forward and giving us best support with
> simplest code. If or when someone does hit this (FreeBSD+PPC) as a problem,
> then we can work with them to find best solution for fixing it. Right now
> we don't have anyone with the PPC+FreeBSD setup, so I'd rather ignore it
> than implement more complicated solutions that we can't test "just in
> case".

+1, FreeBSD + PPC is not worth the complication



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-09-09  8:08                         ` Thomas Monjalon
@ 2021-09-09  8:42                           ` Juraj Linkeš
  0 siblings, 0 replies; 32+ messages in thread
From: Juraj Linkeš @ 2021-09-09  8:42 UTC (permalink / raw)
  To: Thomas Monjalon, Bruce Richardson
  Cc: Piotr Kubaj, David Christensen, david.marchand,
	Honnappa.Nagarahalli, Ruifeng.Wang, ferruh.yigit, jerinjacobk,
	jerinj, stephen, dev



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, September 9, 2021 10:09 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> <bruce.richardson@intel.com>
> Cc: Piotr Kubaj <pkubaj@anongoth.pl>; David Christensen
> <drc@linux.vnet.ibm.com>; david.marchand@redhat.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com; jerinj@marvell.com;
> stephen@networkplumber.org; dev@dpdk.org
> Subject: Re: [PATCH v5] build: optional NUMA and cpu counts detection
> 
> 09/09/2021 10:01, Bruce Richardson:
> > On Thu, Sep 09, 2021 at 07:20:27AM +0000, Juraj Linkeš wrote:
> > > Piotr says lscpu isn't available on ppc FreeBSD. I think this leaves us with two
> options:
> > > 1. either use sysctl with the risk that it may not return an
> > > accurate value 2. not support PPC for numa detection
> > >
> > > What do you think?
> >
> > I think point #2 is more not supporting FreeBSD on PPC for numa
> > detection rather than not supporting PPC generally, right? Personally,
> > I am just in favour of #1 for the sake of moving forward and giving us
> > best support with simplest code. If or when someone does hit this
> > (FreeBSD+PPC) as a problem, then we can work with them to find best
> > solution for fixing it. Right now we don't have anyone with the
> > PPC+FreeBSD setup, so I'd rather ignore it than implement more
> > complicated solutions that we can't test "just in case".
> 
> +1, FreeBSD + PPC is not worth the complication
> 
> 

Thanks for the feedback, makes sense to me. I think v6 has all the features we want then - linux, windows and freebsd using sysctl.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: optional NUMA and cpu counts detection
  2021-09-09  8:01                       ` Bruce Richardson
  2021-09-09  8:08                         ` Thomas Monjalon
@ 2021-09-09 16:44                         ` David Christensen
  1 sibling, 0 replies; 32+ messages in thread
From: David Christensen @ 2021-09-09 16:44 UTC (permalink / raw)
  To: Bruce Richardson, Juraj Linkeš
  Cc: Piotr Kubaj, thomas, david.marchand, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, stephen, dev


>> Piotr says lscpu isn't available on ppc FreeBSD. I think this leaves us with two options:
>> 1. either use sysctl with the risk that it may not return an accurate value
>> 2. not support PPC for numa detection
>>
>> What do you think?
> 
> I think point #2 is more not supporting FreeBSD on PPC for numa detection
> rather than not supporting PPC generally, right? Personally, I am just in
> favour of #1 for the sake of moving forward and giving us best support with
> simplest code. If or when someone does hit this (FreeBSD+PPC) as a problem,
> then we can work with them to find best solution for fixing it. Right now
> we don't have anyone with the PPC+FreeBSD setup, so I'd rather ignore it
> than implement more complicated solutions that we can't test "just in
> case".

Fully agree here.  Can't expect a user app to completely resolve all 
limitations in the underlying OS.

Dave

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [dpdk-dev] [PATCH v6] build: optional NUMA and cpu counts detection
  2021-08-17 10:45         ` [dpdk-dev] [PATCH v6] " Juraj Linkeš
@ 2021-09-16  7:46           ` Thomas Monjalon
  0 siblings, 0 replies; 32+ messages in thread
From: Thomas Monjalon @ 2021-09-16  7:46 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk, jerinj, drc, stephen,
	dev

17/08/2021 12:45, Juraj Linkeš:
> Add an option to automatically discover the host's numa and cpu counts
> and use those values for a non cross-build.
> Give users the option to override the per-arch default values or values
> from cross files by specifying them on the command line with -Dmax_lcores
> and -Dmax_numa_nodes.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> v6: rebase

Fixed few occurrences of lowercase acronyms.

Applied, thanks.





^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-09-16  7:46 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 12:55 [dpdk-dev] [PATCH v1 1/1] build: optional NUMA and cpu counts detection Juraj Linkeš
2020-12-23 11:32 ` Juraj Linkeš
2021-03-31  9:06 ` [dpdk-dev] [PATCH v2] " Juraj Linkeš
2021-03-31 19:07   ` David Christensen
2021-04-16 12:43     ` Juraj Linkeš
2021-04-19 10:18   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
2021-04-28 19:33     ` David Christensen
2021-06-29 10:55     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
2021-06-29 11:28       ` Bruce Richardson
2021-07-06  8:56         ` Juraj Linkeš
2021-07-06  9:08           ` Bruce Richardson
2021-07-06 18:10             ` David Christensen
2021-07-16 13:53               ` Juraj Linkeš
2021-07-16 14:24                 ` Bruce Richardson
2021-07-20 20:49                 ` David Christensen
2021-07-21 12:41                   ` Juraj Linkeš
2021-06-29 18:00       ` Stephen Hemminger
2021-07-21 13:04       ` [dpdk-dev] [PATCH v5] " Juraj Linkeš
2021-08-02 12:44         ` Juraj Linkeš
2021-08-02 23:29           ` David Christensen
2021-08-03 10:21             ` Juraj Linkeš
2021-08-31  0:54               ` Piotr Kubaj
2021-08-31  7:54                 ` Juraj Linkeš
2021-08-31  8:02                   ` Bruce Richardson
2021-09-09  7:20                     ` Juraj Linkeš
2021-09-09  8:01                       ` Bruce Richardson
2021-09-09  8:08                         ` Thomas Monjalon
2021-09-09  8:42                           ` Juraj Linkeš
2021-09-09 16:44                         ` David Christensen
2021-08-31 12:32                   ` Piotr Kubaj
2021-08-17 10:45         ` [dpdk-dev] [PATCH v6] " Juraj Linkeš
2021-09-16  7:46           ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).