[v8,5/5] lib/distributor: use wait event scheme

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

Checks

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

Commit Message

Feifei Wang Oct. 29, 2021, 8:20 a.m. UTC
  Instead of polling for bufptr64 to be updated, use
wait event for this case.

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

Comments

Jerin Jacob Oct. 29, 2021, 1:58 p.m. UTC | #1
On Fri, Oct 29, 2021 at 1:50 PM Feifei Wang <feifei.wang2@arm.com> wrote:
>
> Instead of polling for bufptr64 to be updated, use
> wait event for this case.
>
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>


With the change in the subject as distributor: ...
Probably can be fixed in merge time.

Acked-by: Jerin Jacob <jerinj@marvell.com>

> ---
>  lib/distributor/rte_distributor_single.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/lib/distributor/rte_distributor_single.c b/lib/distributor/rte_distributor_single.c
> index f4725b1d0b..d52b24a453 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_event(&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_event(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
> +                       !=, 0, __ATOMIC_RELAXED);
>
>         /* Sync with distributor on RETURN_BUF flag. */
>         __atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);
> --
> 2.25.1
>
  
David Marchand Oct. 31, 2021, 8:38 a.m. UTC | #2
On Fri, Oct 29, 2021 at 3:58 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Fri, Oct 29, 2021 at 1:50 PM Feifei Wang <feifei.wang2@arm.com> wrote:
> >
> > Instead of polling for bufptr64 to be updated, use
> > wait event for this case.
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
>
>
> With the change in the subject as distributor: ...

Yes.
  
Hunt, David Nov. 1, 2021, 12:44 p.m. UTC | #3
On 29/10/2021 2:58 PM, Jerin Jacob wrote:
> On Fri, Oct 29, 2021 at 1:50 PM Feifei Wang <feifei.wang2@arm.com> wrote:
>> Instead of polling for bufptr64 to be updated, use
>> wait event for this case.
>>
>> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
>> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
>
> With the change in the subject as distributor: ...
> Probably can be fixed in merge time.
>
> Acked-by: Jerin Jacob <jerinj@marvell.com>


Acked-by David Hunt <david.hunt@intel.com>


>> ---
>>   lib/distributor/rte_distributor_single.c | 10 ++++------
>>   1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/distributor/rte_distributor_single.c b/lib/distributor/rte_distributor_single.c
>> index f4725b1d0b..d52b24a453 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_event(&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_event(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
>> +                       !=, 0, __ATOMIC_RELAXED);
>>
>>          /* Sync with distributor on RETURN_BUF flag. */
>>          __atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);
>> --
>> 2.25.1
>>
  

Patch

diff --git a/lib/distributor/rte_distributor_single.c b/lib/distributor/rte_distributor_single.c
index f4725b1d0b..d52b24a453 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_event(&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_event(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
+			!=, 0, __ATOMIC_RELAXED);
 
 	/* Sync with distributor on RETURN_BUF flag. */
 	__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);