[dpdk-dev] mk: using initial-exec model for thread local variable

Message ID 1524909247-6581-1-git-send-email-yong.liu@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Marvin Liu April 28, 2018, 9:54 a.m. UTC
  When building share library, thread-local storage model will be changed
to global-dynamic. It will cost additional protect for read thread local
variable. By now only lcore id is this kind of varaible and not need to
dynamic share with other threads. So make TLS model back to initial-exec
like static library for better performance.

Signed-off-by: Marvin Liu <yong.liu@intel.com>
  

Comments

Yang, Zhiyong April 28, 2018, 4:39 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marvin Liu
> Sent: Saturday, April 28, 2018 5:54 PM
> To: dev@dpdk.org
> Cc: Liu, Yong <yong.liu@intel.com>
> Subject: [dpdk-dev] [PATCH] mk: using initial-exec model for thread local
> variable
> 
> When building share library, thread-local storage model will be changed to
> global-dynamic. It will cost additional protect for read thread local variable. By
> now only lcore id is this kind of varaible and not need to dynamic share with
> other threads. So make TLS model back to initial-exec like static library for
> better performance.
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> 

For vhost-user, 
If no this pach, vhost user in shared lib perf drops 14.3% than working in static.
after applying the patch , vhost-user in shared lib can achieve the similar perf as  in static lib.

Tested-by:  Zhiyong Yang <zhiyong.yang@intel.com>
  
Thomas Monjalon May 18, 2018, 9:46 a.m. UTC | #2
28/04/2018 06:39, Yang, Zhiyong:
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marvin Liu
> Sent: Saturday, April 28, 2018 5:54 PM
> > 
> > When building share library, thread-local storage model will be changed to
> > global-dynamic. It will cost additional protect for read thread local variable. By
> > now only lcore id is this kind of varaible and not need to dynamic share with
> > other threads. So make TLS model back to initial-exec like static library for
> > better performance.
> > 
> > Signed-off-by: Marvin Liu <yong.liu@intel.com>
> > 
> 
> For vhost-user, 
> If no this pach, vhost user in shared lib perf drops 14.3% than working in static.
> after applying the patch , vhost-user in shared lib can achieve the similar perf as  in static lib.
> 
> Tested-by:  Zhiyong Yang <zhiyong.yang@intel.com>

For the record, I have decided to not try this optimization
in the last weeks of the 18.05 release.
However we could try it in 18.08 by applying the patch early in the cycle.
Is there anyone against this patch?
  

Patch

diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index 7e4531b..7b5e71c 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -43,6 +43,10 @@  ifeq (,$(findstring -O0,$(EXTRA_CFLAGS)))
 endif
 endif
 
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+TOOLCHAIN_CFLAGS += -ftls-model=initial-exec
+endif
+
 WERROR_FLAGS := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
 WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith
 WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual