Skip to contentSkip to conversation

build: change flag variable type to boolean

PATCH Superseded Bruce Richardson 2 participants 13 messages Jun 12, 2023 – Jun 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 build: change flag variable type to boolean

The has_libnuma flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

---
 config/arm/meson.build    | 2 +-
 config/meson.build        | 4 ++--
 lib/eal/linux/meson.build | 2 +-
 lib/vhost/meson.build     | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
config/arm/meson.build +1 -1
index 43f6a551a2..faba5e38cf 100644
@@ -592,7 +592,7 @@ if update_flags
         part_number = soc_config['part_number']
         soc_flags = soc_config.get('flags', [])
         if not soc_config.get('numa', true)
-            has_libnuma = 0
+            has_libnuma = false
         endif
 
         disable_drivers += ',' + soc_config.get('disable_drivers', '')
config/meson.build +2 -2
index 65087ce090..8aebccbbdc 100644
@@ -174,7 +174,7 @@ if link_lib != ''
 endif
 
 # check for libraries used in multiple places in DPDK
-has_libnuma = 0
+has_libnuma = false
 find_libnuma = true
 if meson.is_cross_build() and not meson.get_cross_property('numa', true)
     # don't look for libnuma if explicitly disabled in cross build
@@ -184,7 +184,7 @@ if find_libnuma
     numa_dep = cc.find_library('numa', required: false)
     if numa_dep.found() and cc.has_header('numaif.h')
         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
-        has_libnuma = 1
+        has_libnuma = true
         add_project_link_arguments('-lnuma', language: 'c')
         dpdk_extra_ldflags += '-lnuma'
     endif
lib/eal/linux/meson.build +1 -1
index 1b913acc06..e99ebed256 100644
@@ -20,6 +20,6 @@ sources += files(
 )
 
 deps += ['kvargs', 'telemetry']
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
 endif
lib/vhost/meson.build +1 -1
index 0d1abf6283..9e39d221a1 100644
@@ -5,7 +5,7 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
 endif
 if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 2/2 build: prevent accidentally building without NUMA support

When libnuma development package is missing on a system, DPDK can still be built but will be missing much-needed support for NUMA memory management. This may later cause issues at runtime if the resulting binary is run on a NUMA system.

We can reduce the incidence of such runtime error by ensuring that, for native builds*, libnuma is present - unless the user actually specifies via "max_numa_nodes" that they don't require NUMA support. Having this as an error condition is also in keeping with what is documented in the Linux GSG doc, where libnuma is listed as a requirement for building DPDK [1].

* NOTE: cross-compilation builds have a different logic set, with a separate "numa" value indicating if numa support is necessary.

[1] https://doc.dpdk.org/guides-23.03/linux_gsg/sys_reqs.html

---
 config/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)
config/meson.build +6 -0
index 8aebccbbdc..bffd3600c6 100644
@@ -381,6 +381,12 @@ endif
 if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
     error('Number of NUMA nodes not specified.')
 endif
+if not meson.is_cross_build() and dpdk_conf.get('RTE_MAX_NUMA_NODES') > 1 and not has_libnuma
+    error('''
+No NUMA library (development package) found, yet DPDK configured for multiple NUMA nodes.
+Please install libnuma, or set 'max_numa_nodes' option to '1' to build without NUMA support.
+''')
+endif
 
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
Signature · 1 line
2.39.2
#2 lore raw

PATCH v2 1/2 build: change flag variable type to boolean

In reply to Bruce Richardson

The has_libnuma flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

---
 config/arm/meson.build    | 2 +-
 config/meson.build        | 4 ++--
 lib/eal/linux/meson.build | 2 +-
 lib/vhost/meson.build     | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
config/arm/meson.build +1 -1
index 43f6a551a2..faba5e38cf 100644
@@ -592,7 +592,7 @@ if update_flags
         part_number = soc_config['part_number']
         soc_flags = soc_config.get('flags', [])
         if not soc_config.get('numa', true)
-            has_libnuma = 0
+            has_libnuma = false
         endif
 
         disable_drivers += ',' + soc_config.get('disable_drivers', '')
config/meson.build +2 -2
index 65087ce090..8aebccbbdc 100644
@@ -174,7 +174,7 @@ if link_lib != ''
 endif
 
 # check for libraries used in multiple places in DPDK
-has_libnuma = 0
+has_libnuma = false
 find_libnuma = true
 if meson.is_cross_build() and not meson.get_cross_property('numa', true)
     # don't look for libnuma if explicitly disabled in cross build
@@ -184,7 +184,7 @@ if find_libnuma
     numa_dep = cc.find_library('numa', required: false)
     if numa_dep.found() and cc.has_header('numaif.h')
         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
-        has_libnuma = 1
+        has_libnuma = true
         add_project_link_arguments('-lnuma', language: 'c')
         dpdk_extra_ldflags += '-lnuma'
     endif
lib/eal/linux/meson.build +1 -1
index 1b913acc06..e99ebed256 100644
@@ -20,6 +20,6 @@ sources += files(
 )
 
 deps += ['kvargs', 'telemetry']
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
 endif
lib/vhost/meson.build +1 -1
index 0d1abf6283..9e39d221a1 100644
@@ -5,7 +5,7 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
 endif
 if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
Signature · 1 line
2.39.2
#3 lore raw

PATCH v2 2/2 build: prevent accidentally building without NUMA support

When libnuma development package is missing on a system, DPDK can still be built but will be missing much-needed support for NUMA memory management. This may later cause issues at runtime if the resulting binary is run on a NUMA system.

We can reduce the incidence of such runtime error by ensuring that, for native builds*, libnuma is present - unless the user actually specifies via "max_numa_nodes" that they don't require NUMA support. Having this as an error condition is also in keeping with what is documented in the Linux GSG doc, where libnuma is listed as a requirement for building DPDK [1].

* NOTE: cross-compilation builds have a different logic set, with a separate "numa" value indicating if numa support is necessary.

[1] https://doc.dpdk.org/guides-23.03/linux_gsg/sys_reqs.html

---
V2: Limit check to linux only

---
 config/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)
config/meson.build +9 -0
index 8aebccbbdc..00812976ba 100644
@@ -381,6 +381,15 @@ endif
 if not dpdk_conf.has('RTE_MAX_NUMA_NODES')
     error('Number of NUMA nodes not specified.')
 endif
+if (is_linux and
+        dpdk_conf.get('RTE_MAX_NUMA_NODES') > 1 and
+        not meson.is_cross_build() and
+        not has_libnuma)
+    error('''
+No NUMA library (development package) found, yet DPDK configured for multiple NUMA nodes.
+Please install libnuma, or set 'max_numa_nodes' option to '1' to build without NUMA support.
+''')
+endif
 
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH v2 2/2] build: prevent accidentally building without NUMA support

Quoted 17 lines · Bruce Richardson

When libnuma development package is missing on a system, DPDK can still be built but will be missing much-needed support for NUMA memory management. This may later cause issues at runtime if the resulting binary is run on a NUMA system.

We can reduce the incidence of such runtime error by ensuring that, for native builds*, libnuma is present - unless the user actually specifies via "max_numa_nodes" that they don't require NUMA support. Having this as an error condition is also in keeping with what is documented in the Linux GSG doc, where libnuma is listed as a requirement for building DPDK [1].

* NOTE: cross-compilation builds have a different logic set, with a separate "numa" value indicating if numa support is necessary.

[1] https://doc.dpdk.org/guides-23.03/linux_gsg/sys_reqs.html

Quoted 8 lines

---
V2: Limit check to linux only

---
 config/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)

I see this patch has failures reported in the CI, due to some of the systems not having libnuma installed. I'd view that as a false positive, since libnuma is effectively a mandatory requirement for building DPDK to run on most systems. [And this patch still provides a way to build without it - that way just has to be selected deliberately, rather than it being chosen by default, without the user being aware of the omission.]

Regards,
/Bruce

#5 lore raw

Re: [PATCH v2 2/2] build: prevent accidentally building without NUMA support

Quoted 27 lines · Bruce Richardson
Quoted 17 lines · Bruce Richardson

When libnuma development package is missing on a system, DPDK can still be built but will be missing much-needed support for NUMA memory management. This may later cause issues at runtime if the resulting binary is run on a NUMA system.

We can reduce the incidence of such runtime error by ensuring that, for native builds*, libnuma is present - unless the user actually specifies via "max_numa_nodes" that they don't require NUMA support. Having this as an error condition is also in keeping with what is documented in the Linux GSG doc, where libnuma is listed as a requirement for building DPDK [1].

* NOTE: cross-compilation builds have a different logic set, with a separate "numa" value indicating if numa support is necessary.

[1] https://doc.dpdk.org/guides-23.03/linux_gsg/sys_reqs.html

Quoted 8 lines

---
V2: Limit check to linux only

---
 config/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 6 lines

I see this patch has failures reported in the CI, due to some of the systems not having libnuma installed. I'd view that as a false positive, since libnuma is effectively a mandatory requirement for building DPDK to run on most systems. [And this patch still provides a way to build without it - that way just has to be selected deliberately, rather than it being chosen by default, without the user being aware of the omission.]

The Intel CI lab job failing seems to be an issue in their RHEL 8.7 environment. Can you ping them to figure it out?

For the i386 job in GHA.. either we install a 32bits numa library, or we can silence this by setting max_numa_nodes to 1.

Signature · 1 line
David Marchand
Reviewed-by on v2 1/2
#6 lore raw
In reply to Bruce Richardson
Quoted 5 lines · Bruce Richardson

The has_libnuma flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

This patch lgtm (with or without the suggestion on config/arm below).

[snip]

config/arm/meson.build if update_flags · line 596

Quoted 11 lines
config/arm/meson.build +1 -1
index 43f6a551a2..faba5e38cf 100644
@@ -592,7 +592,7 @@ if update_flags
         part_number = soc_config['part_number']
         soc_flags = soc_config.get('flags', [])
         if not soc_config.get('numa', true)
-            has_libnuma = 0
+            has_libnuma = false
         endif

Maybe has_libnuma = soc_config.get('numa', true) ?

config/arm/meson.build if update_flags · line 598

Quoted 2 lines
config/arm/meson.build +0 -0
         disable_drivers += ',' + soc_config.get('disable_drivers', '')

The same cleanup could be done to has_libfdt. Additionnally, I wonder if we could remove those "== true" or "== false" checks here and there in meson.build files.

Signature · 1 line
David Marchand
#7 lore raw
Quoted 29 lines · David Marchand
Quoted 5 lines · Bruce Richardson

The has_libnuma flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

This patch lgtm (with or without the suggestion on config/arm below).

[snip]

config/arm/meson.build if update_flags · line 596

Quoted 11 lines
config/arm/meson.build +1 -1
index 43f6a551a2..faba5e38cf 100644
@@ -592,7 +592,7 @@ if update_flags
         part_number = soc_config['part_number']
         soc_flags = soc_config.get('flags', [])
         if not soc_config.get('numa', true)
-            has_libnuma = 0
+            has_libnuma = false
         endif

Maybe has_libnuma = soc_config.get('numa', true) ?

Quoted 1 line
Quoted 8 lines
Quoted 1 line
         disable_drivers += ',' + soc_config.get('disable_drivers', '')

The same cleanup could be done to has_libfdt. Additionnally, I wonder if we could remove those "== true" or "== false" checks here and there in meson.build files.

I will take a look, and I think I'll also split this patch off from the patch 2, to add an error for libnuma, since the two aren't really linked, and this patch should probably be the simpler merge. I'll see about doing a set for just int to boolean cleanups if I get the chance.

/Bruce

#8 lore raw

v3 cover replace int flags with booleans

In reply to Bruce Richardson

in meson.build files, some flags were being treated as integers rather than using the more logical option of booleans. Fix this.

V3: drop the patch requiring libnuma from this set, to make this only
a simple set changing the types of the flag. The other patch will be submitted separately for better tracking.

Bruce Richardson (2):
build: change NUMA flag variable type to boolean
build: change libfdt flag variable type to boolean

 config/arm/meson.build         | 2 +-
 config/meson.build             | 8 ++++----
 drivers/net/ipn3ke/meson.build | 2 +-
 drivers/raw/ifpga/meson.build  | 2 +-
 lib/eal/linux/meson.build      | 2 +-
 lib/vhost/meson.build          | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

--
2.39.2

#9 lore raw

PATCH v3 1/2 build: change NUMA flag variable type to boolean

The has_libnuma flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

---
 config/arm/meson.build    | 2 +-
 config/meson.build        | 4 ++--
 lib/eal/linux/meson.build | 2 +-
 lib/vhost/meson.build     | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
config/arm/meson.build +1 -1
index 43f6a551a2..faba5e38cf 100644
@@ -592,7 +592,7 @@ if update_flags
         part_number = soc_config['part_number']
         soc_flags = soc_config.get('flags', [])
         if not soc_config.get('numa', true)
-            has_libnuma = 0
+            has_libnuma = false
         endif
 
         disable_drivers += ',' + soc_config.get('disable_drivers', '')
config/meson.build +2 -2
index 65087ce090..8aebccbbdc 100644
@@ -174,7 +174,7 @@ if link_lib != ''
 endif
 
 # check for libraries used in multiple places in DPDK
-has_libnuma = 0
+has_libnuma = false
 find_libnuma = true
 if meson.is_cross_build() and not meson.get_cross_property('numa', true)
     # don't look for libnuma if explicitly disabled in cross build
@@ -184,7 +184,7 @@ if find_libnuma
     numa_dep = cc.find_library('numa', required: false)
     if numa_dep.found() and cc.has_header('numaif.h')
         dpdk_conf.set10('RTE_HAS_LIBNUMA', true)
-        has_libnuma = 1
+        has_libnuma = true
         add_project_link_arguments('-lnuma', language: 'c')
         dpdk_extra_ldflags += '-lnuma'
     endif
lib/eal/linux/meson.build +1 -1
index 1b913acc06..e99ebed256 100644
@@ -20,6 +20,6 @@ sources += files(
 )
 
 deps += ['kvargs', 'telemetry']
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
 endif
lib/vhost/meson.build +1 -1
index 0d1abf6283..9e39d221a1 100644
@@ -5,7 +5,7 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
-if has_libnuma == 1
+if has_libnuma
     dpdk_conf.set10('RTE_LIBRTE_VHOST_NUMA', true)
 endif
 if (toolchain == 'gcc' and cc.version().version_compare('>=8.3.0'))
Signature · 1 line
2.39.2
#10 lore raw

PATCH v3 2/2 build: change libfdt flag variable type to boolean

In reply to Bruce Richardson

The has_libfdt flag was using 0 and 1 integer values, instead of the more appropriate boolean type. Change to use true/false instead.

---
 config/meson.build             | 4 ++--
 drivers/net/ipn3ke/meson.build | 2 +-
 drivers/raw/ifpga/meson.build  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
config/meson.build +2 -2
index 8aebccbbdc..22d7d908b7 100644
@@ -190,11 +190,11 @@ if find_libnuma
     endif
 endif
 
-has_libfdt = 0
+has_libfdt = false
 fdt_dep = cc.find_library('fdt', required: false)
 if fdt_dep.found() and cc.has_header('fdt.h')
     dpdk_conf.set10('RTE_HAS_LIBFDT', true)
-    has_libfdt = 1
+    has_libfdt = true
     add_project_link_arguments('-lfdt', language: 'c')
     dpdk_extra_ldflags += '-lfdt'
 endif
drivers/net/ipn3ke/meson.build +1 -1
index 104d2f58e5..464bdbd8b6 100644
@@ -15,7 +15,7 @@ endif
 #  rte_eth_switch_domain_free()
 #
 
-if has_libfdt == 0
+if not has_libfdt
     build = false
     reason = 'missing dependency, "libfdt"'
     subdir_done()
drivers/raw/ifpga/meson.build +1 -1
index cc30dc8be7..20dea23206 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Intel Corporation
 
-if has_libfdt == 0
+if not has_libfdt
     build = false
     reason = 'missing dependency, "libfdt"'
     subdir_done()
Signature · 1 line
2.39.2
#12 lore raw

Re: [PATCH v3 0/2] replace int flags with booleans

In reply to Bruce Richardson
Quoted 11 lines · Bruce Richardson

in meson.build files, some flags were being treated as integers rather than using the more logical option of booleans. Fix this.

V3: drop the patch requiring libnuma from this set, to make this only
a simple set changing the types of the flag. The other patch will be submitted separately for better tracking.

Bruce Richardson (2):
build: change NUMA flag variable type to boolean
build: change libfdt flag variable type to boolean

Series applied, thanks Bruce.

Signature · 1 line
David Marchand