Skip to contentSkip to conversation

net/i40e: Eliminate weak symbols in i40e_rxtx.c

PATCH Superseded David Harton 4 participants 11 messages May 15, 2019 – Jun 6, 2019

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

PATCH 1/1 net/i40e: Eliminate weak symbols in i40e_rxtx.c

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---
 drivers/net/i40e/Makefile    |  1 +
 drivers/net/i40e/i40e_rxtx.c | 52 +++++++++++++++++++-----------------
 drivers/net/i40e/meson.build |  2 ++
 3 files changed, 31 insertions(+), 24 deletions(-)
drivers/net/i40e/Makefile +1 -0
index 3f869a8d6..cbcfce099 100644
@@ -106,6 +106,7 @@ endif
 
 ifeq ($(CC_AVX2_SUPPORT), 1)
 	SRCS-$(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR) += i40e_rxtx_vec_avx2.c
+	CFLAGS_i40e_rxtx.o += -DCC_AVX2_SUPPORT
 endif
 
 # install this header file
drivers/net/i40e/i40e_rxtx.c +28 -24

101 lines not on this page · raw message

drivers/net/i40e/meson.build +2 -0
index d783f3626..dcbca39bf 100644
@@ -35,8 +35,10 @@ if arch_subdir == 'x86'
 	# a. we have AVX supported in minimum instruction set baseline
 	# b. it's not minimum instruction set, but supported by compiler
 	if dpdk_conf.has('RTE_MACHINE_CPUFLAG_AVX2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		sources += files('i40e_rxtx_vec_avx2.c')
 	elif cc.has_argument('-mavx2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		i40e_avx2_lib = static_library('i40e_avx2_lib',
 				'i40e_rxtx_vec_avx2.c',
 				dependencies: [static_rte_ethdev,
Signature · 1 line
2.19.1
#2 lore raw

PATCH v2 1/1 net/i40e: Eliminate weak symbols in i40e_rxtx.c

In reply to David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

 drivers/net/i40e/Makefile    |  1 +
 drivers/net/i40e/i40e_rxtx.c | 60 +++++++++++++++++++-----------------
 drivers/net/i40e/meson.build |  2 ++
 3 files changed, 35 insertions(+), 28 deletions(-)
drivers/net/i40e/Makefile +1 -0
index 3f869a8d6..cbcfce099 100644
@@ -106,6 +106,7 @@ endif
 
 ifeq ($(CC_AVX2_SUPPORT), 1)
 	SRCS-$(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR) += i40e_rxtx_vec_avx2.c
+	CFLAGS_i40e_rxtx.o += -DCC_AVX2_SUPPORT
 endif
 
 # install this header file
drivers/net/i40e/i40e_rxtx.c +32 -28

133 lines not on this page · raw message

drivers/net/i40e/meson.build +2 -0
index d783f3626..dcbca39bf 100644
@@ -35,8 +35,10 @@ if arch_subdir == 'x86'
 	# a. we have AVX supported in minimum instruction set baseline
 	# b. it's not minimum instruction set, but supported by compiler
 	if dpdk_conf.has('RTE_MACHINE_CPUFLAG_AVX2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		sources += files('i40e_rxtx_vec_avx2.c')
 	elif cc.has_argument('-mavx2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		i40e_avx2_lib = static_library('i40e_avx2_lib',
 				'i40e_rxtx_vec_avx2.c',
 				dependencies: [static_rte_ethdev,
Signature · 1 line
2.19.1
Acked-by on v2 1/1
#3 lore raw
Quoted 9 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Testing a few compiles here, this breaks when vector mode is disabled, because it's possible that CC_AVX2_SUPPORT=1 when VECTOR=n. I'd suggest adding "ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y) ... endif" around the block in the makefile checking for AVX2 support, so that we never set AVX2 unless we have vector support.

With this change, you can include my ack in v3.

/Bruce

#4 lore raw
Quoted 8 lines · Bruce Richardson
Quoted 7 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

Quoted 7 lines
Quoted 2 lines

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Testing a few compiles here, this breaks when vector mode is disabled, because it's possible that CC_AVX2_SUPPORT=1 when VECTOR=n. I'd suggest adding "ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y) ... endif" around the block in the makefile checking for AVX2 support, so that we never set AVX2 unless we have vector support.

Concern is this is pushing vectorization support more to compile time configuration. Do we really have to select if to use vector PMD or not in compile time?

Can't we get rid of the 'CONFIG_RTE_LIBRTE_I40E_INC_VECTOR' config option completely? As done in the ICE driver now.

Isn't it better to compile vectorization support in as much as possible and do the vector or scalar path selection in runtime, this patch may prevent us to do that, weak functions enables us being more dynamic.

Quoted 7 lines

With this change, you can include my ack in v3.

/Bruce

#5 lore raw
Quoted 31 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, June 04, 2019 12:00 PM
To: Bruce Richardson <[email protected]>; David Harton (dharton) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: Eliminate weak symbols in i40e_rxtx.c

Quoted 8 lines · Bruce Richardson
Quoted 7 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

Quoted 7 lines
Quoted 2 lines

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Testing a few compiles here, this breaks when vector mode is disabled, because it's possible that CC_AVX2_SUPPORT=1 when VECTOR=n. I'd suggest adding "ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y) ... endif" around the block in the makefile checking for AVX2 support, so that we never set AVX2 unless we have vector support.

Concern is this is pushing vectorization support more to compile time configuration. Do we really have to select if to use vector PMD or not in compile time?

Quoted 6 lines

Can't we get rid of the 'CONFIG_RTE_LIBRTE_I40E_INC_VECTOR' config option completely? As done in the ICE driver now.

Isn't it better to compile vectorization support in as much as possible and do the vector or scalar path selection in runtime, this patch may prevent us to do that, weak functions enables us being more dynamic.

Choosing a vector dynamically can be done without the use of weak symbols.

IMHO, weak symbols should really be used for cross library support where a user wants to override a 3rd party function not within a lib. In fact the weak symbol usage may preclude supporting all the variants you might need/want to select.

Quoted 8 lines
Quoted 8 lines

With this change, you can include my ack in v3.

/Bruce

#6 lore raw
Quoted 31 lines · David Harton (dharton)
Quoted 31 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, June 04, 2019 12:00 PM
To: Bruce Richardson <[email protected]>; David Harton (dharton) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: Eliminate weak symbols in i40e_rxtx.c

Quoted 8 lines · Bruce Richardson
Quoted 7 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

Quoted 7 lines
Quoted 2 lines

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Testing a few compiles here, this breaks when vector mode is disabled, because it's possible that CC_AVX2_SUPPORT=1 when VECTOR=n. I'd suggest adding "ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y) ... endif" around the block in the makefile checking for AVX2 support, so that we never set AVX2 unless we have vector support.

Concern is this is pushing vectorization support more to compile time configuration. Do we really have to select if to use vector PMD or not in compile time?

Quoted 8 lines
Quoted 6 lines

Can't we get rid of the 'CONFIG_RTE_LIBRTE_I40E_INC_VECTOR' config option completely? As done in the ICE driver now.

Isn't it better to compile vectorization support in as much as possible and do the vector or scalar path selection in runtime, this patch may prevent us to do that, weak functions enables us being more dynamic.

Choosing a vector dynamically can be done without the use of weak symbols.

No objection then.

Quoted 12 lines

IMHO, weak symbols should really be used for cross library support where a user wants to override a 3rd party function not within a lib. In fact the weak symbol usage may preclude supporting all the variants you might need/want to select.

Quoted 8 lines
Quoted 8 lines

With this change, you can include my ack in v3.

/Bruce

#7 lore raw
In reply to Ferruh Yigit
Quoted 21 lines · Ferruh Yigit
Quoted 8 lines · Bruce Richardson
Quoted 7 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

Quoted 7 lines
Quoted 2 lines

v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Testing a few compiles here, this breaks when vector mode is disabled, because it's possible that CC_AVX2_SUPPORT=1 when VECTOR=n. I'd suggest adding "ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y) ... endif" around the block in the makefile checking for AVX2 support, so that we never set AVX2 unless we have vector support.

Concern is this is pushing vectorization support more to compile time configuration. Do we really have to select if to use vector PMD or not in compile time?

Quoted 7 lines

Can't we get rid of the 'CONFIG_RTE_LIBRTE_I40E_INC_VECTOR' config option completely? As done in the ICE driver now.

Isn't it better to compile vectorization support in as much as possible and do the vector or scalar path selection in runtime, this patch may prevent us to do that, weak functions enables us being more dynamic.

Weak functions are not needed to do the runtime selection - they are needed for compilation only. They have the downside of potentially causing runtime problems due to a mis-configured compile, which is only seen later by the end user. By using real functions rather than weak functions it means that any mischosen compile paths will flag a compile error rather than silently succeeding and then accidentally using an incorrect function at runtime.

#8 lore raw

PATCH v3 1/1 net/i40e: Eliminate weak symbols in i40e_rxtx.c

In reply to David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

v3 - added CONFIG_RTE_LIBRTE_I40E_INC_VECTOR to makefile v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

 drivers/net/i40e/Makefile    |  3 ++
 drivers/net/i40e/i40e_rxtx.c | 60 +++++++++++++++++++-----------------
 drivers/net/i40e/meson.build |  2 ++
 3 files changed, 37 insertions(+), 28 deletions(-)
drivers/net/i40e/Makefile +3 -0
index 3f869a8d6..1c3bbe329 100644
@@ -89,6 +89,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += rte_pmd_i40e.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_tm.c
 SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_vf_representor.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR),y)
 ifeq ($(findstring RTE_MACHINE_CPUFLAG_AVX2,$(CFLAGS)),RTE_MACHINE_CPUFLAG_AVX2)
 	CC_AVX2_SUPPORT=1
 else
@@ -103,9 +104,11 @@ else
 		endif
 	endif
 endif
+endif
 
 ifeq ($(CC_AVX2_SUPPORT), 1)
 	SRCS-$(CONFIG_RTE_LIBRTE_I40E_INC_VECTOR) += i40e_rxtx_vec_avx2.c
+	CFLAGS_i40e_rxtx.o += -DCC_AVX2_SUPPORT
 endif
 
 # install this header file
drivers/net/i40e/i40e_rxtx.c +32 -28

133 lines not on this page · raw message

drivers/net/i40e/meson.build +2 -0
index d783f3626..dcbca39bf 100644
@@ -35,8 +35,10 @@ if arch_subdir == 'x86'
 	# a. we have AVX supported in minimum instruction set baseline
 	# b. it's not minimum instruction set, but supported by compiler
 	if dpdk_conf.has('RTE_MACHINE_CPUFLAG_AVX2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		sources += files('i40e_rxtx_vec_avx2.c')
 	elif cc.has_argument('-mavx2')
+		cflags += ['-DCC_AVX2_SUPPORT']
 		i40e_avx2_lib = static_library('i40e_avx2_lib',
 				'i40e_rxtx_vec_avx2.c',
 				dependencies: [static_rte_ethdev,
Signature · 1 line
2.19.1
Acked-by on v3 1/1
#9 lore raw
Quoted 10 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

---

v3 - added CONFIG_RTE_LIBRTE_I40E_INC_VECTOR to makefile v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Applied
#10 lore raw
Quoted 15 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Friday, May 17, 2019 3:21 AM
To: David Harton <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: Re: [PATCH v3] net/i40e: Eliminate weak symbols in i40e_rxtx.c

Quoted 4 lines · David Harton

Use of weak symbols can hide makefile errors especially when custom makefiles are used. Removing the use of weak symbols to avoid a stub function being linked in production code.

Quoted 7 lines
Quoted 6 lines

---

v3 - added CONFIG_RTE_LIBRTE_I40E_INC_VECTOR to makefile v2 - added CC_AVX2_SUPPORT check to code enabling avx2 vectors

Applied to dpdk-next-net-intel.

Thanks
Qi