Skip to contentSkip to conversation

config/arm: avoid variable reuse

PATCH In review Dharmik Thakkar 5 participants 18 messages Aug 25, 2020 – Oct 14, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 config/arm: avoid variable reuse

Rename 'machine' to 'machine_properties' in config/arm/meson.build since 'machine' is previously being used in config/meson.build

---
 config/arm/meson.build | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
config/arm/meson.build +9 -9
index 8728051d5e38..e89ecdc4ccd2 100644
@@ -141,12 +141,12 @@ else
 	dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)
 	dpdk_conf.set('RTE_ARCH_ARM64', 1)
 
-	machine = []
+	machine_properties = []
 	cmd_generic = ['generic', '', '', 'default', '']
 	cmd_output = cmd_generic # Set generic by default
 	machine_args = [] # Clear previous machine args
 	if arm_force_default_march and not meson.is_cross_build()
-		machine = impl_generic
+		machine_properties = impl_generic
 		impl_pn = 'default'
 	elif not meson.is_cross_build()
 		# The script returns ['Implementer', 'Variant', 'Architecture',
@@ -158,9 +158,9 @@ else
 			cmd_output = cmd.stdout().to_lower().strip().split(' ')
 		endif
 		# Set to generic if variable is not found
-		machine = get_variable('impl_' + cmd_output[0], ['generic'])
-		if machine[0] == 'generic'
-			machine = impl_generic
+		machine_properties = get_variable('impl_' + cmd_output[0], ['generic'])
+		if machine_properties[0] == 'generic'
+			machine_properties = impl_generic
 			cmd_output = cmd_generic
 		endif
 		impl_pn = cmd_output[3]
@@ -170,7 +170,7 @@ else
 	else
 		impl_id = meson.get_cross_property('implementor_id', 'generic')
 		impl_pn = meson.get_cross_property('implementor_pn', 'default')
-		machine = get_variable('impl_' + impl_id)
+		machine_properties = get_variable('impl_' + impl_id)
 	endif
 
 	# Apply Common Defaults. These settings may be overwritten by machine
@@ -181,14 +181,14 @@ else
 		endif
 	endforeach
 
-	message('Implementer : ' + machine[0])
-	foreach flag: machine[1]
+	message('Implementer : ' + machine_properties[0])
+	foreach flag: machine_properties[1]
 		if flag.length() > 0
 			dpdk_conf.set(flag[0], flag[1])
 		endif
 	endforeach
 
-	foreach marg: machine[2]
+	foreach marg: machine_properties[2]
 		if marg[0] == impl_pn
 			foreach flag: marg[1]
 				if cc.has_argument(flag)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 build: find max lcore programmatically

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

---
 config/get_max_lcores.py | 13 +++++++++++++
 config/meson.build       | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100755 config/get_max_lcores.py
config/get_max_lcores.py new file +13 -0
new file mode 100755
index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build +12 -1
index 6996e5cbeaa5..80c05bc15d2f 100644
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory areas
 	dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
 endif
 
-
 compile_time_cpuflags = []
 subdir(arch_subdir)
 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
 
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+	# The script returns max lcores
+	params = files('get_max_lcores.py')
+	cmd_out = run_command(params)
+	if cmd_out.returncode() == 0
+		cmd_lcore = cmd_out.stdout().to_lower().strip().split(' ')
+	endif
+	max_lcore = cmd_lcore[0].to_int()
+	dpdk_conf.set('RTE_MAX_LCORE', max_lcore)
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 9 lines · Dharmik Thakkar

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

Quoted 59 lines
---
 config/get_max_lcores.py | 13 +++++++++++++
 config/meson.build       | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100755 config/get_max_lcores.py
config/get_max_lcores.py new file +13 -0
new file mode 100755
index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build +12 -2
index 6996e5cbeaa5..80c05bc15d2f 100644
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory areas
        dpdk_conf.set('RTE_MAX_MEM_MB', 2048)
 endif
 
-
 compile_time_cpuflags = []
 subdir(arch_subdir)
 dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))
 
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)
+       if cmd_out.returncode() == 0
+               cmd_lcore = cmd_out.stdout().to_lower().strip().split(' ')
+       endif
+       max_lcore = cmd_lcore[0].to_int()
+       dpdk_conf.set('RTE_MAX_LCORE', max_lcore)
+endif
+
 # set the install path for the drivers
 dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
 
--

2.17.1

#3 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 15 lines · Jerin Jacob
Quoted 9 lines · Dharmik Thakkar

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 6 lines

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 60 lines
Quoted 60 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-)

create mode 100755 config/get_max_lcores.py

config/get_max_lcores.py new file +13 -0
new file mode 100755
index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020 Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build +0 -0
index 6996e5cbeaa5..80c05bc15d2f 100644
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory areas
       dpdk_conf.set('RTE_MAX_MEM_MB', 2048)

endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS', ','.join(compile_time_cpuflags))

config/meson.build +12 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)
+       if cmd_out.returncode() == 0
+               cmd_lcore = cmd_out.stdout().to_lower().strip().split(' ')
+       endif
+       max_lcore = cmd_lcore[0].to_int()
+       dpdk_conf.set('RTE_MAX_LCORE', max_lcore)
+endif
+
# set the install path for the drivers
dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)

--
2.17.1

#4 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 76 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 3 lines · Jerin Jacob

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 10 lines · <[email protected]> wrote:
Quoted 9 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 6 lines

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 25 lines
Quoted 25 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755

config/get_max_lcores.py

config/get_max_lcores.py new renamed from config/get_max_lcores.py +0 -0

file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +10 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
Quoted 8 lines

config/meson.build else # for 32-bit we need smaller reserved memory

Quoted 8 lines
config/get_max_lcores.py new file +3 -0
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory

areas

Quoted 8 lines
Quoted 8 lines
config/meson.build +0 -1
       dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif
 
-

compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 5 lines
Quoted 5 lines

config/meson.build else # for 32-bit we need smaller reserved memory areas · line 248

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
config/meson.build +6 -0
+       if cmd_out.returncode() == 0
+               cmd_lcore = cmd_out.stdout().to_lower().strip().split(' ')
+       endif
+       max_lcore = cmd_lcore[0].to_int()
+       dpdk_conf.set('RTE_MAX_LCORE', max_lcore) endif
+
# set the install path for the drivers
dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)

--
2.17.1

#5 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 74 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 74 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 3 lines · Jerin Jacob

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 10 lines · <[email protected]> wrote:
Quoted 9 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 6 lines

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 25 lines
Quoted 25 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755

config/get_max_lcores.py

config/get_max_lcores.py new renamed from config/get_max_lcores.py +0 -0

file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +10 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
Quoted 8 lines

config/meson.build else # for 32-bit we need smaller reserved memory

Quoted 8 lines
config/get_max_lcores.py new file +3 -0
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory  

areas

Quoted 8 lines
Quoted 8 lines
config/meson.build +0 -1
       dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif
 
-

compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build else # for 32-bit we need smaller reserved memory areas · line 248

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)  

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

#6 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 89 lines · Stephen Hemminger
Quoted 74 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 74 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 3 lines · Jerin Jacob

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 10 lines · <[email protected]> wrote:
Quoted 9 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 6 lines

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 25 lines
Quoted 25 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755

config/get_max_lcores.py

config/get_max_lcores.py new renamed from config/get_max_lcores.py +0 -0

file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +10 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
Quoted 8 lines

config/meson.build else # for 32-bit we need smaller reserved memory

Quoted 8 lines
config/get_max_lcores.py new file +3 -0
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory  

areas

Quoted 8 lines
Quoted 8 lines
config/meson.build +0 -1
      dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif
 
-

compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build else # for 32-bit we need smaller reserved memory areas · line 248

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)  

Have you considered running just a shell command, such as "nproc --all"?

Quoted 6 lines

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

#7 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 110 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 15 lines · <[email protected]> wrote:
Quoted 11 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Aug 25, 2020, at 11:47 PM, Jerin Jacob <[email protected]>

Quoted 79 lines · wrote:
Quoted 67 lines
Quoted 67 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 11 lines · <[email protected]> wrote:
Quoted 10 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 7 lines

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 26 lines
Quoted 26 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

config/get_max_lcores.py new file +11 -0
new file mode 100755 index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved

memory

areas

Quoted 8 lines
Quoted 8 lines
      dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build else # for 32-bit we need smaller reserved memory areas · line 248

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

Quoted 7 lines
Quoted 2 lines

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

One way to do this automatic core count is when max_lcores=0 (0 would have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do you think?

Currently the -Dmax_lcores option doesn't work for arm builds (the value of RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Juraj

#8 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 117 lines · Juraj Linkeš
Quoted 114 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 15 lines · <[email protected]> wrote:
Quoted 11 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Aug 25, 2020, at 11:47 PM, Jerin Jacob <[email protected]>

Quoted 81 lines · wrote:
Quoted 67 lines
Quoted 67 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 11 lines · <[email protected]> wrote:
Quoted 10 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 7 lines

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 26 lines
Quoted 26 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

config/get_max_lcores.py new file +11 -0
new file mode 100755 index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved

memory

areas

Quoted 8 lines
Quoted 8 lines
     dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 7 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

The MIDR value-based probing doesn’t quite work well for Arm IP (currently being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 2 lines

One way to do this automatic core count is when max_lcores=0 (0 would have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do you think?

Yes, agreed.

Quoted 3 lines

Currently the -Dmax_lcores option doesn't work for arm builds (the value of RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Juraj

#9 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Please, what is the conclusion here?

18/09/2020 07:47, Dharmik Thakkar:

Quoted 134 lines
Quoted 116 lines · Juraj Linkeš
Quoted 114 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 15 lines · <[email protected]> wrote:
Quoted 11 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Aug 25, 2020, at 11:47 PM, Jerin Jacob <[email protected]>

Quoted 81 lines · wrote:
Quoted 67 lines
Quoted 67 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 11 lines · <[email protected]> wrote:
Quoted 10 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 7 lines

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 26 lines
Quoted 26 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

config/get_max_lcores.py new file +11 -0
new file mode 100755 index 000000000000..ebf1c7efdadd
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved

memory

areas

Quoted 8 lines
Quoted 8 lines
     dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 7 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

The MIDR value-based probing doesn’t quite work well for Arm IP (currently being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 2 lines

One way to do this automatic core count is when max_lcores=0 (0 would have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do you think?

Yes, agreed.

Quoted 3 lines

Currently the -Dmax_lcores option doesn't work for arm builds (the value of RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Juraj

#10 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

I believe we're going to drop this patch series in favor of http://patches.dpdk.org/project/dpdk/list/?series=12923.

Quoted 164 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 4:32 PM
To: Dharmik Thakkar <[email protected]>
Cc: Juraj Linkeš <[email protected]>; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Please, what is the conclusion here?

18/09/2020 07:47, Dharmik Thakkar:

Quoted 2 lines
Quoted 2 lines

On Sep 17, 2020, at 4:56 AM, Juraj Linkeš <[email protected]>

Quoted 34 lines · wrote:
Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 17 lines · <[email protected]> wrote:
Quoted 13 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 2 lines

On Aug 25, 2020, at 11:47 PM, Jerin Jacob
<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same

Implemener

Quoted 77 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 62 lines
Quoted 62 lines
Quoted 8 lines
Quoted 7 lines

and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 7 lines

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 27 lines
Quoted 27 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

(quoted diff) +0 -0

b/config/get_max_lcores.py new file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +11 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020
+Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller

reserved memory

areas

Quoted 8 lines
Quoted 8 lines
     dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the

current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

Quoted 3 lines
Quoted 1 line

The MIDR value-based probing doesn’t quite work well for Arm IP (currently

being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 2 lines
Quoted 2 lines

One way to do this automatic core count is when max_lcores=0 (0 would

have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do you think?

Quoted 5 lines
Quoted 1 line

Yes, agreed.

Quoted 1 line

Currently the -Dmax_lcores option doesn't work for arm builds (the value of

RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Quoted 2 lines
Quoted 2 lines

Juraj

#11 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Hi Juraj,

Quoted 3 lines · Juraj Linkeš

I believe we're going to drop this patch series in favor of http://patches.dpdk.org/project/dpdk/list/?series=12923.

I can see you have included this feature in your series. Thank you!
What are your thoughts on the other patch [1]? Do you plan on including that as well in your series?

[1] [1/2] config/arm: avoid variable reuse
https://patches.dpdk.org/patch/75946/

Quoted 166 lines
Quoted 165 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 4:32 PM
To: Dharmik Thakkar <[email protected]>
Cc: Juraj Linkeš <[email protected]>; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Please, what is the conclusion here?

18/09/2020 07:47, Dharmik Thakkar:

Quoted 2 lines
Quoted 2 lines

On Sep 17, 2020, at 4:56 AM, Juraj Linkeš <[email protected]>

Quoted 34 lines · wrote:
Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 17 lines · <[email protected]> wrote:
Quoted 13 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 2 lines

On Aug 25, 2020, at 11:47 PM, Jerin Jacob
<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same

Implemener

Quoted 77 lines
Quoted 77 lines
Quoted 77 lines
Quoted 76 lines
Quoted 62 lines
Quoted 62 lines
Quoted 8 lines
Quoted 7 lines

and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 7 lines

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 27 lines
Quoted 27 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

(quoted diff) +0 -0

b/config/get_max_lcores.py new file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +11 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020
+Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller

reserved memory

areas

Quoted 8 lines
Quoted 8 lines
    dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the

current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

Quoted 3 lines
Quoted 1 line

The MIDR value-based probing doesn’t quite work well for Arm IP (currently

being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 2 lines
Quoted 2 lines

One way to do this automatic core count is when max_lcores=0 (0 would

have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do you think?

Quoted 5 lines
Quoted 1 line

Yes, agreed.

Quoted 1 line

Currently the -Dmax_lcores option doesn't work for arm builds (the value of

RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Quoted 2 lines
Quoted 2 lines

Juraj

#12 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Hi Dharmik,

Quoted 14 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Tuesday, October 13, 2020 5:15 PM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Hi Juraj,

Quoted 3 lines · Juraj Linkeš

I believe we're going to drop this patch series in favor of

Quoted 9 lines

http://patches.dpdk.org/project/dpdk/list/?series=12923.

I can see you have included this feature in your series. Thank you! What are your thoughts on the other patch [1]? Do you plan on including that as well in your series?

[1] [1/2] config/arm: avoid variable reuse
https://patches.dpdk.org/patch/75946/

I believe the general idea of your patch is alredy part of my patch series in this patch: http://patches.dpdk.org/patch/80572/

Quoted 175 lines
Quoted 77 lines
Quoted 77 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 4:32 PM
To: Dharmik Thakkar <[email protected]>
Cc: Juraj Linkeš <[email protected]>; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Please, what is the conclusion here?

18/09/2020 07:47, Dharmik Thakkar:

Quoted 3 lines
Quoted 3 lines

On Sep 17, 2020, at 4:56 AM, Juraj Linkeš
<[email protected]>

Quoted 34 lines · wrote:
Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 17 lines · <[email protected]> wrote:
Quoted 13 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 2 lines

On Aug 25, 2020, at 11:47 PM, Jerin Jacob
<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same

Implemener

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines

and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

This patch does *not* affect ‘default’ build type and cross-

compilation.

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 28 lines
Quoted 28 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

(quoted diff) +0 -0

b/config/get_max_lcores.py new file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +11 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020
+Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller

reserved memory

areas

Quoted 8 lines
Quoted 8 lines
    dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --

all"?

Quoted 22 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the

current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

Quoted 4 lines
Quoted 1 line

The MIDR value-based probing doesn’t quite work well for Arm IP (currently

Quoted 7 lines
Quoted 7 lines

being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 3 lines
Quoted 3 lines

One way to do this automatic core count is when max_lcores=0 (0 would

have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do

you think?

Quoted 13 lines
Quoted 12 lines
Quoted 6 lines
Quoted 1 line

Yes, agreed.

Quoted 2 lines

Currently the -Dmax_lcores option doesn't work for arm builds (the value of

RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Quoted 2 lines
Quoted 2 lines

Juraj

#13 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 26 lines · Juraj Linkeš

Hi Dharmik,

Quoted 20 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Tuesday, October 13, 2020 5:15 PM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Hi Juraj,

Quoted 3 lines · Juraj Linkeš

I believe we're going to drop this patch series in favor of

http://patches.dpdk.org/project/dpdk/list/?series=12923.

I can see you have included this feature in your series. Thank you! What are your thoughts on the other patch [1]? Do you plan on including that as well in your series?

Quoted 5 lines
Quoted 3 lines

[1] [1/2] config/arm: avoid variable reuse
https://patches.dpdk.org/patch/75946/

I believe the general idea of your patch is alredy part of my patch series in this patch: http://patches.dpdk.org/patch/80572/

Great, thank you! I will drop these patches.

Quoted 173 lines
Quoted 173 lines
Quoted 78 lines
Quoted 78 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, October 13, 2020 4:32 PM
To: Dharmik Thakkar <[email protected]>
Cc: Juraj Linkeš <[email protected]>; [email protected]; Stephen Hemminger <[email protected]>; Jerin Jacob <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Please, what is the conclusion here?

18/09/2020 07:47, Dharmik Thakkar:

Quoted 3 lines
Quoted 3 lines

On Sep 17, 2020, at 4:56 AM, Juraj Linkeš
<[email protected]>

Quoted 34 lines · wrote:
Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 4, 2020 7:44 AM
To: Stephen Hemminger <[email protected]>
Cc: Juraj Linkeš <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 1 line

On Sep 3, 2020, at 5:52 PM, Stephen Hemminger

Quoted 17 lines · <[email protected]> wrote:
Quoted 13 lines · On Thu, 3 Sep 2020 06:20:17 +0000 Juraj Linkeš <[email protected]>…
Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 2 lines

On Aug 25, 2020, at 11:47 PM, Jerin Jacob
<[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same

Implemener

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines

and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in
meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

We may need to build on the native arm64 machine and use it on another
arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

This patch does *not* affect ‘default’ build type and cross-

compilation.

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 28 lines
Quoted 28 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode

100755 config/get_max_lcores.py

(quoted diff) +0 -0

b/config/get_max_lcores.py new file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +11 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020
+Arm Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
Quoted 8 lines
Quoted 8 lines
config/get_max_lcores.py new file +2 -0
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller

reserved memory

areas

Quoted 8 lines
Quoted 8 lines
   dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif

-
compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --

all"?

Quoted 22 lines
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Is this really a good idea?
For real distributions and NFV products, the build and runtime environment will usually be different even if on same CPU architecture.

In many cases there maybe a huge build machine (128 CPU) or in a container (reported as single cpu) even if not doing cross build.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

That’s a great point, Stephen. IMO, this patch is useful when building and running natively.
For all other purposes (like the ones you mentioned), do you think it is a good idea to set RTE_MAX_LCORE using -Dmax_lcores?

We should only use this native builds, as that would be consistent with the

current meson build philosophy of "meson figuring as much as possible on its own". Any build other than native implies the user wants to deviate from the build machine.

Quoted 4 lines
Quoted 1 line

The MIDR value-based probing doesn’t quite work well for Arm IP (currently

Quoted 7 lines
Quoted 7 lines

being discussed on this patch: https://patches.dpdk.org/patch/76981/).

Quoted 3 lines
Quoted 3 lines

One way to do this automatic core count is when max_lcores=0 (0 would

have the special meaning of "figure core count automatically"). We can set that as default in meson_option.txt and then users will have the ability to set it to whatever they want, even for native builds. What do

you think?

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 1 line

Yes, agreed.

Quoted 2 lines

Currently the -Dmax_lcores option doesn't work for arm builds (the value of

RTE_MAX_LCORE is overwritten in config/arm/meson.build). I believe the patch tries to address this, but still, we need to be mindful of that.

Quoted 2 lines
Quoted 2 lines

Juraj

#14 lore raw

Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

In reply to Juraj Linkeš
Quoted 80 lines · Juraj Linkeš
Quoted 77 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Wednesday, August 26, 2020 6:56 AM
To: Jerin Jacob <[email protected]>
Cc: [email protected]; dpdk-dev <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] build: find max lcore programmatically

Quoted 3 lines · Jerin Jacob

On Wed, Aug 26, 2020 at 2:44 AM Dharmik Thakkar

Quoted 10 lines · <[email protected]> wrote:
Quoted 9 lines

For Arm, RTE_MAX_LCORE is hard-coded into the config. It leads to incorrect RTE_MAX_LCORE when machines have same Implemener and part number but different number of CPUs.
For x86, RTE_MAX_LCORE is always set to 128 (using the value set in meson_options.txt)

Use python script to find max lcore when using native build to correctly set RTE_MAX_LCORE.

Quoted 6 lines

We may need to build on the native arm64 machine and use it on another arm64 machine(Just like x86).
So I think, at least for default config(which will be used by distribution) to support max
lcores as fixed. I am not sure this patch changes those aspects or not? Please check.

This patch does *not* affect ‘default’ build type and cross-compilation.

Quoted 25 lines
Quoted 25 lines

---
config/get_max_lcores.py | 13 +++++++++++++
config/meson.build | 13 ++++++++++++-

2 files changed, 25 insertions(+), 1 deletion(-) create mode 100755

config/get_max_lcores.py

config/get_max_lcores.py new renamed from config/get_max_lcores.py +0 -0

file mode 100755 index 000000000000..ebf1c7efdadd

config/get_max_lcores.py new file +10 -0
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2020 Arm
+Limited
+
+import os
+
+max_lcores = []
+
+nCPU = os.cpu_count()
+
Quoted 8 lines

config/meson.build else # for 32-bit we need smaller reserved memory

Quoted 8 lines
config/get_max_lcores.py new file +3 -0
+max_lcores.append(str(nCPU & 0xFFF))             # Number of CPUs
+
+print(' '.join(max_lcores))
config/meson.build index renamed from config/meson.build +0 -0

6996e5cbeaa5..80c05bc15d2f 100644

config/meson.build +0 -0
@@ -237,11 +237,22 @@ else # for 32-bit we need smaller reserved memory

areas

Quoted 8 lines
Quoted 8 lines
config/meson.build +0 -1
      dpdk_conf.set('RTE_MAX_MEM_MB', 2048) endif
 
-

compile_time_cpuflags = []
subdir(arch_subdir)
dpdk_conf.set('RTE_COMPILE_TIME_CPUFLAGS',
','.join(compile_time_cpuflags))

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

config/meson.build else # for 32-bit we need smaller reserved memory areas · line 248

Quoted 5 lines
config/meson.build +5 -0
+# set max lcores
+if machine != 'default' and not meson.is_cross_build()
+       # The script returns max lcores
+       params = files('get_max_lcores.py')
+       cmd_out = run_command(params)

Have you considered running just a shell command, such as "nproc --all"?

Shell command based solution such as “nproc —all” is not OS-agnostic, it doesn’t work on Windows.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
config/meson.build +6 -0
+       if cmd_out.returncode() == 0
+               cmd_lcore = cmd_out.stdout().to_lower().strip().split(' ')
+       endif
+       max_lcore = cmd_lcore[0].to_int()
+       dpdk_conf.set('RTE_MAX_LCORE', max_lcore) endif
+
# set the install path for the drivers
dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)

--
2.17.1

#15 lore raw
In reply to Dharmik Thakkar
Quoted 10 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Tuesday, August 25, 2020 11:13 PM
To: Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; Dharmik Thakkar <[email protected]>
Subject: [dpdk-dev] [PATCH 1/2] config/arm: avoid variable reuse

Quoted 3 lines

Rename 'machine' to 'machine_properties' in config/arm/meson.build since 'machine' is previously being used in config/meson.build

Wasn't the same variable name used by design? That is update the variable according to what's in config/arm/meson.build so that the new updated variable would be used in config/meson.build after that?

Quoted 71 lines
---
 config/arm/meson.build | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
config/arm/meson.build index renamed from config/arm/meson.build +0 -0

8728051d5e38..e89ecdc4ccd2 100644

config/arm/meson.build +3 -6
@@ -141,12 +141,12 @@ else
 	dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)
 	dpdk_conf.set('RTE_ARCH_ARM64', 1)
 
-	machine = []
+	machine_properties = []
 	cmd_generic = ['generic', '', '', 'default', '']
 	cmd_output = cmd_generic # Set generic by default
 	machine_args = [] # Clear previous machine args
 	if arm_force_default_march and not meson.is_cross_build()
-		machine = impl_generic
+		machine_properties = impl_generic
 		impl_pn = 'default'
 	elif not meson.is_cross_build()
 		# The script returns ['Implementer', 'Variant', 'Architecture', @@
-158,9 +158,9 @@ else
 			cmd_output = cmd.stdout().to_lower().strip().split(' ')
 		endif
 		# Set to generic if variable is not found
-		machine = get_variable('impl_' + cmd_output[0], ['generic'])
-		if machine[0] == 'generic'
-			machine = impl_generic
+		machine_properties = get_variable('impl_' + cmd_output[0],

['generic'])

config/arm/meson.build +3 -1
+		if machine_properties[0] == 'generic'
+			machine_properties = impl_generic
 			cmd_output = cmd_generic
 		endif
 		impl_pn = cmd_output[3]
@@ -170,7 +170,7 @@ else
 	else
 		impl_id = meson.get_cross_property('implementor_id',
 'generic')
 		impl_pn = meson.get_cross_property('implementor_pn',
 'default')
-		machine = get_variable('impl_' + impl_id)
+		machine_properties = get_variable('impl_' + impl_id)
 	endif

# Apply Common Defaults. These settings may be overwritten by
machine @@ -181,14 +181,14 @@ else

config/arm/meson.build +3 -4
 		endif
 	endforeach
 
-	message('Implementer : ' + machine[0])
-	foreach flag: machine[1]
+	message('Implementer : ' + machine_properties[0])
+	foreach flag: machine_properties[1]
 		if flag.length() > 0
 			dpdk_conf.set(flag[0], flag[1])
 		endif
 	endforeach
 
-	foreach marg: machine[2]
+	foreach marg: machine_properties[2]
 		if marg[0] == impl_pn
 			foreach flag: marg[1]
 				if cc.has_argument(flag)
--

2.17.1

#16 lore raw
Quoted 14 lines · Juraj Linkeš
Quoted 11 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Tuesday, August 25, 2020 11:13 PM
To: Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; Dharmik Thakkar <[email protected]>
Subject: [dpdk-dev] [PATCH 1/2] config/arm: avoid variable reuse

Quoted 6 lines
Quoted 3 lines

Rename 'machine' to 'machine_properties' in config/arm/meson.build since 'machine' is previously being used in config/meson.build

Wasn't the same variable name used by design? That is update the variable according to what's in config/arm/meson.build so that the new updated variable would be used in config/meson.build after that?

The variable ‘machine’ within config/arm/meson.build is essentially machine + properties, so I think it makes sense to use a different variable name. Also, since, ‘machine’ is a configuration option, IMO it is incorrect to update it.

Quoted 73 lines
Quoted 71 lines

---
config/arm/meson.build | 18 +++++++++---------

1 file changed, 9 insertions(+), 9 deletions(-)
config/arm/meson.build index renamed from config/arm/meson.build +0 -0

8728051d5e38..e89ecdc4ccd2 100644

config/arm/meson.build +2 -3
@@ -141,12 +141,12 @@ else
 	dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)
 	dpdk_conf.set('RTE_ARCH_ARM64', 1)
 
-	machine = []
+	machine_properties = []
 	cmd_generic = ['generic', '', '', 'default', '']
 	cmd_output = cmd_generic # Set generic by default
 	machine_args = [] # Clear previous machine args
 	if arm_force_default_march and not meson.is_cross_build()
-		machine = impl_generic
+		machine_properties = impl_generic
 		impl_pn = 'default'
 	elif not meson.is_cross_build()
 		# The script returns ['Implementer', 'Variant', 'Architecture', @@
-158,9 +158,9 @@ else
			cmd_output = cmd.stdout().to_lower().strip().split(' ')
		endif
		# Set to generic if variable is not found
config/arm/meson.build +1 -3
-		machine = get_variable('impl_' + cmd_output[0], ['generic'])
-		if machine[0] == 'generic'
-			machine = impl_generic
+		machine_properties = get_variable('impl_' + cmd_output[0],

['generic'])

config/arm/meson.build +2 -0
+		if machine_properties[0] == 'generic'
+			machine_properties = impl_generic
			cmd_output = cmd_generic
		endif
		impl_pn = cmd_output[3]
config/arm/meson.build +1 -1
@@ -170,7 +170,7 @@ else
 	else
 		impl_id = meson.get_cross_property('implementor_id',
 'generic')
 		impl_pn = meson.get_cross_property('implementor_pn',
 'default')
-		machine = get_variable('impl_' + impl_id)
+		machine_properties = get_variable('impl_' + impl_id)
 	endif

# Apply Common Defaults. These settings may be overwritten by
machine @@ -181,14 +181,14 @@ else
endif
endforeach

config/arm/meson.build +2 -2
-	message('Implementer : ' + machine[0])
-	foreach flag: machine[1]
+	message('Implementer : ' + machine_properties[0])
+	foreach flag: machine_properties[1]
		if flag.length() > 0
			dpdk_conf.set(flag[0], flag[1])
		endif
	endforeach
config/arm/meson.build +1 -1
-	foreach marg: machine[2]
+	foreach marg: machine_properties[2]
		if marg[0] == impl_pn
			foreach flag: marg[1]
				if cc.has_argument(flag)

--
2.17.1

Reviewed-by
#17 lore raw
Quoted 27 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, September 18, 2020 7:27 AM
To: Juraj Linkeš <[email protected]>
Cc: [email protected]; [email protected]; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 1/2] config/arm: avoid variable reuse

Quoted 16 lines · Juraj Linkeš
Quoted 14 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Dharmik Thakkar
Sent: Tuesday, August 25, 2020 11:13 PM
To: Thomas Monjalon <[email protected]>
Cc: [email protected]; [email protected]; Dharmik Thakkar <[email protected]>
Subject: [dpdk-dev] [PATCH 1/2] config/arm: avoid variable reuse

Rename 'machine' to 'machine_properties' in config/arm/meson.build since 'machine' is previously being used in config/meson.build

Quoted 9 lines
Quoted 1 line

Wasn't the same variable name used by design? That is update the variable

according to what's in config/arm/meson.build so that the new updated variable would be used in config/meson.build after that?

Quoted 1 line

The variable ‘machine’ within config/arm/meson.build is essentially machine + properties, so I think it makes sense to use a different variable name. Also, since, ‘machine’ is a configuration option, IMO it is incorrect to update it.

It is a configuration option defined by us and only used in the config folder, so I guess the original author didn't think much of overwriting. It is actually used in the same manner in both config/meson.build and config/arm/meson.build and that is to set RTE_MACHINE, so I'd say it makes sense to use the same variable name from this point of view.

Also, I see that it's being overwritten in the code (although only for a special case):
if machine == 'default'
if host_machine.cpu_family().startswith('x86')
# matches the old pre-meson build systems default
machine = 'corei7'

But it is only being overwritten in this special case and I think there is value in preserving the original configuration value. That leads me to the conclusion that using the same name was not a deliberate design choice (which was my original question). So, +1 from me.

Quoted 63 lines
Quoted 63 lines
Quoted 63 lines

---
config/arm/meson.build | 18 +++++++++---------

1 file changed, 9 insertions(+), 9 deletions(-)
config/arm/meson.build index renamed from config/arm/meson.build +0 -0

8728051d5e38..e89ecdc4ccd2 100644

config/arm/meson.build +2 -3
@@ -141,12 +141,12 @@ else
 	dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)
 	dpdk_conf.set('RTE_ARCH_ARM64', 1)
 
-	machine = []
+	machine_properties = []
 	cmd_generic = ['generic', '', '', 'default', '']
 	cmd_output = cmd_generic # Set generic by default
 	machine_args = [] # Clear previous machine args
 	if arm_force_default_march and not meson.is_cross_build()
-		machine = impl_generic
+		machine_properties = impl_generic
 		impl_pn = 'default'
 	elif not meson.is_cross_build()
 		# The script returns ['Implementer', 'Variant', 'Architecture', @@
-158,9 +158,9 @@ else
			cmd_output = cmd.stdout().to_lower().strip().split(' ')
		endif
		# Set to generic if variable is not found
config/arm/meson.build +1 -3
-		machine = get_variable('impl_' + cmd_output[0], ['generic'])
-		if machine[0] == 'generic'
-			machine = impl_generic
+		machine_properties = get_variable('impl_' + cmd_output[0],

['generic'])

config/arm/meson.build +2 -0
+		if machine_properties[0] == 'generic'
+			machine_properties = impl_generic
			cmd_output = cmd_generic
		endif
		impl_pn = cmd_output[3]
config/arm/meson.build +1 -1
@@ -170,7 +170,7 @@ else
 	else
 		impl_id = meson.get_cross_property('implementor_id',
 'generic')
 		impl_pn = meson.get_cross_property('implementor_pn',
 'default')
-		machine = get_variable('impl_' + impl_id)
+		machine_properties = get_variable('impl_' + impl_id)
 	endif

# Apply Common Defaults. These settings may be overwritten by
machine @@ -181,14 +181,14 @@ else
endif
endforeach

config/arm/meson.build +2 -2
-	message('Implementer : ' + machine[0])
-	foreach flag: machine[1]
+	message('Implementer : ' + machine_properties[0])
+	foreach flag: machine_properties[1]
		if flag.length() > 0
			dpdk_conf.set(flag[0], flag[1])
		endif
	endforeach
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
config/arm/meson.build +1 -1
-	foreach marg: machine[2]
+	foreach marg: machine_properties[2]
		if marg[0] == impl_pn
			foreach flag: marg[1]
				if cc.has_argument(flag)

--
2.17.1