From: Juraj Linkeš <juraj.linkes@pantheon.tech> To: thomas@monjalon.net, david.marchand@redhat.com, bruce.richardson@intel.com, Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com Cc: dev@dpdk.org, Juraj Linkeš <juraj.linkes@pantheon.tech> Subject: [dpdk-dev] [PATCH v3] build: optional NUMA and cpu counts detection Date: Mon, 19 Apr 2021 12:18:42 +0200 Message-ID: <1618827522-31828-1-git-send-email-juraj.linkes@pantheon.tech> (raw) In-Reply-To: <1617181602-18293-1-git-send-email-juraj.linkes@pantheon.tech> 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
next prev parent reply other threads:[~2021-04-19 10:18 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-20 12:55 [dpdk-dev] [PATCH v1 1/1] " 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 ` Juraj Linkeš [this message] 2021-04-28 19:33 ` [dpdk-dev] [PATCH v3] " 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1618827522-31828-1-git-send-email-juraj.linkes@pantheon.tech \ --to=juraj.linkes@pantheon.tech \ --cc=Honnappa.Nagarahalli@arm.com \ --cc=Ruifeng.Wang@arm.com \ --cc=bruce.richardson@intel.com \ --cc=david.marchand@redhat.com \ --cc=dev@dpdk.org \ --cc=thomas@monjalon.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git