[v9,5/5] distributor: use wait until scheme

Message ID 20211101060007.2632418-6-feifei.wang2@arm.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series add new helper for wait scheme |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Feifei Wang Nov. 1, 2021, 6 a.m. UTC
  Instead of polling for bufptr64 to be updated, use
wait until scheme for this case.

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
---
 lib/distributor/rte_distributor_single.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Comments

Pattan, Reshma Nov. 1, 2021, 4:05 p.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Feifei Wang
> ---
>  lib/distributor/rte_distributor_single.c | 10 ++++------

Hi ,

rte_distributor.c  file also has couple of places where similar change can be done, just wondering was that missed ?

Thanks,
Reshma
  
Feifei Wang Nov. 2, 2021, 2 a.m. UTC | #2
> -----邮件原件-----
> 发件人: dev <dev-bounces@dpdk.org> 代表 Pattan, Reshma
> 发送时间: Tuesday, November 2, 2021 12:05 AM
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; Hunt, David
> <david.hunt@intel.com>
> 抄送: dev@dpdk.org; nd <nd@arm.com>; jerinjacobk@gmail.com;
> stephen@networkplumber.org; thomas@monjalon.net;
> david.marchand@redhat.com; Ruifeng Wang <Ruifeng.Wang@arm.com>;
> jerinj@marvell.com
> 主题: Re: [dpdk-dev] [PATCH v9 5/5] distributor: use wait until scheme
> 
> 
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Feifei Wang
> > ---
> >  lib/distributor/rte_distributor_single.c | 10 ++++------
> 
> Hi ,
> 
> rte_distributor.c  file also has couple of places where similar change can be
> done, just wondering was that missed ?
Thanks for your reminding.
I just checked rte_distributor.c and there are 6 places which have rte_pause.

However, I think these places cannot apply the new helper due to that they need
to do other actions in the loop besides waiting. 
Our new helper can only wait for the change of this variable, not do other actions.

Best Regards
Feifei 
> 
> Thanks,
> Reshma
  

Patch

diff --git a/lib/distributor/rte_distributor_single.c b/lib/distributor/rte_distributor_single.c
index f4725b1d0b..b653620688 100644
--- a/lib/distributor/rte_distributor_single.c
+++ b/lib/distributor/rte_distributor_single.c
@@ -33,9 +33,8 @@  rte_distributor_request_pkt_single(struct rte_distributor_single *d,
 	union rte_distributor_buffer_single *buf = &d->bufs[worker_id];
 	int64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS)
 			| RTE_DISTRIB_GET_BUF;
-	while (unlikely(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED)
-			& RTE_DISTRIB_FLAGS_MASK))
-		rte_pause();
+	RTE_WAIT_UNTIL_MASKED(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
+		==, 0, __ATOMIC_RELAXED);
 
 	/* Sync with distributor on GET_BUF flag. */
 	__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);
@@ -74,9 +73,8 @@  rte_distributor_return_pkt_single(struct rte_distributor_single *d,
 	union rte_distributor_buffer_single *buf = &d->bufs[worker_id];
 	uint64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS)
 			| RTE_DISTRIB_RETURN_BUF;
-	while (unlikely(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED)
-			& RTE_DISTRIB_FLAGS_MASK))
-		rte_pause();
+	RTE_WAIT_UNTIL_MASKED(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
+		==, 0, __ATOMIC_RELAXED);
 
 	/* Sync with distributor on RETURN_BUF flag. */
 	__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);