packet_ordering: replace sync builtins with atomic builtins

Message ID 1546508946-12552-1-git-send-email-phil.yang@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series packet_ordering: replace sync builtins with atomic builtins |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Phil Yang Jan. 3, 2019, 9:49 a.m. UTC
  '__sync' builtins are deprecated, use '__atomic' builtins instead for
packet_ordering.

Fixes: 850f373 ("examples/packet_ordering: new sample app")

Signed-off-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>

---
 examples/packet_ordering/main.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
  

Comments

Thomas Monjalon March 28, 2019, 6:42 p.m. UTC | #1
03/01/2019 10:49, Phil Yang:
> '__sync' builtins are deprecated, use '__atomic' builtins instead for
> packet_ordering.
> 
> Fixes: 850f373 ("examples/packet_ordering: new sample app")
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>

Am I right there will be a new version of this patch?
  
Phil Yang March 29, 2019, 1:34 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, March 29, 2019 2:43 AM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>
> Cc: dev@dpdk.org; nd <nd@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>
> Subject: Re: [dpdk-dev] [PATCH] packet_ordering: replace sync builtins with
> atomic builtins
> 
> 03/01/2019 10:49, Phil Yang:
> > '__sync' builtins are deprecated, use '__atomic' builtins instead for
> > packet_ordering.
> >
> > Fixes: 850f373 ("examples/packet_ordering: new sample app")
> >
> > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> 
> Am I right there will be a new version of this patch?

Hi Thomas,

Yes, there will be a new version of this patch. It is under our internal discussion.
I will upstream it out ASAP.

Thanks,
Phil

> 
>
  

Patch

diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index 149bfdd..61740a9 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -448,7 +448,16 @@  worker_thread(void *args_ptr)
 		if (unlikely(burst_size == 0))
 			continue;
 
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION < 70100)
+		/*
+		 * '__sync' builtins are deprecated, but '__atomic' ones
+		 * are sub-optimized in older GCC versions.
+		 */
 		__sync_fetch_and_add(&app_stats.wkr.dequeue_pkts, burst_size);
+#else
+		__atomic_fetch_add(&app_stats.wkr.dequeue_pkts, burst_size,
+				__ATOMIC_RELAXED);
+#endif
 
 		/* just do some operation on mbuf */
 		for (i = 0; i < burst_size;)
@@ -457,11 +466,29 @@  worker_thread(void *args_ptr)
 		/* enqueue the modified mbufs to workers_to_tx ring */
 		ret = rte_ring_enqueue_burst(ring_out, (void *)burst_buffer,
 				burst_size, NULL);
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION < 70100)
+		/*
+		 * '__sync' builtins are deprecated, but '__atomic' ones
+		 * are sub-optimized in older GCC versions.
+		 */
 		__sync_fetch_and_add(&app_stats.wkr.enqueue_pkts, ret);
+#else
+		__atomic_fetch_add(&app_stats.wkr.enqueue_pkts, ret,
+				__ATOMIC_RELAXED);
+#endif
 		if (unlikely(ret < burst_size)) {
 			/* Return the mbufs to their respective pool, dropping packets */
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION < 70100)
+			/*
+			 * '__sync' builtins are deprecated, but '__atomic' ones
+			 * are sub-optimized in older GCC versions.
+			 */
 			__sync_fetch_and_add(&app_stats.wkr.enqueue_failed_pkts,
 					(int)burst_size - ret);
+#else
+			__atomic_fetch_add(&app_stats.wkr.enqueue_failed_pkts,
+				(int)burst_size - ret, __ATOMIC_RELAXED);
+#endif
 			pktmbuf_free_bulk(&burst_buffer[ret], burst_size - ret);
 		}
 	}