diff mbox series

[v6,3/4] eal: use wait event scheme for mcslock

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Feifei Wang Oct. 27, 2021, 8:10 a.m. UTC
Instead of polling for mcslock to be updated, use wait event scheme
for this case.

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/eal/include/generic/rte_mcslock.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Mattias Rönnblom Oct. 27, 2021, 11:16 a.m. UTC | #1
On 2021-10-27 10:10, Feifei Wang wrote:
> Instead of polling for mcslock to be updated, use wait event scheme
> for this case.
>
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>   lib/eal/include/generic/rte_mcslock.h | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/lib/eal/include/generic/rte_mcslock.h b/lib/eal/include/generic/rte_mcslock.h
> index 34f33c64a5..806a2b2c7e 100644
> --- a/lib/eal/include/generic/rte_mcslock.h
> +++ b/lib/eal/include/generic/rte_mcslock.h
> @@ -116,8 +116,13 @@ rte_mcslock_unlock(rte_mcslock_t **msl, rte_mcslock_t *me)
>   		/* More nodes added to the queue by other CPUs.
>   		 * Wait until the next pointer is set.
>   		 */
> -		while (__atomic_load_n(&me->next, __ATOMIC_RELAXED) == NULL)
> -			rte_pause();
> +#ifdef RTE_ARCH_32
> +		rte_wait_event((uint32_t *)&me->next, UINT32_MAX, ==, 0,
> +				__ATOMIC_RELAXED);
> +#else
> +		rte_wait_event((uint64_t *)&me->next, UINT64_MAX, ==, 0,
> +				__ATOMIC_RELAXED);
> +#endif
>   	}
>   
>   	/* Pass lock to next waiter. */

You could do something like

rte_wait_event((uintptr_t *)&me->next, UINTPTR_MAX, ==, 0, __ATOMIC_RELAXED);

and avoid the #ifdef.
Feifei Wang Oct. 28, 2021, 6:32 a.m. UTC | #2
> -----邮件原件-----
> 发件人: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> 发送时间: Wednesday, October 27, 2021 7:16 PM
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>
> 抄送: dev@dpdk.org; nd <nd@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>
> 主题: Re: [dpdk-dev] [PATCH v6 3/4] eal: use wait event scheme for mcslock
> 
> On 2021-10-27 10:10, Feifei Wang wrote:
> > Instead of polling for mcslock to be updated, use wait event scheme
> > for this case.
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> >   lib/eal/include/generic/rte_mcslock.h | 9 +++++++--
> >   1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/eal/include/generic/rte_mcslock.h
> > b/lib/eal/include/generic/rte_mcslock.h
> > index 34f33c64a5..806a2b2c7e 100644
> > --- a/lib/eal/include/generic/rte_mcslock.h
> > +++ b/lib/eal/include/generic/rte_mcslock.h
> > @@ -116,8 +116,13 @@ rte_mcslock_unlock(rte_mcslock_t **msl,
> rte_mcslock_t *me)
> >   		/* More nodes added to the queue by other CPUs.
> >   		 * Wait until the next pointer is set.
> >   		 */
> > -		while (__atomic_load_n(&me->next, __ATOMIC_RELAXED) ==
> NULL)
> > -			rte_pause();
> > +#ifdef RTE_ARCH_32
> > +		rte_wait_event((uint32_t *)&me->next, UINT32_MAX, ==, 0,
> > +				__ATOMIC_RELAXED);
> > +#else
> > +		rte_wait_event((uint64_t *)&me->next, UINT64_MAX, ==, 0,
> > +				__ATOMIC_RELAXED);
> > +#endif
> >   	}
> >
> >   	/* Pass lock to next waiter. */
> 
> You could do something like
> 
> rte_wait_event)&me->next, UINTPTR_MAX, ==, 0,
> __ATOMIC_RELAXED);
> 
> and avoid the #ifdef.
Good comments, it can fix the problem. Thanks for this comments.
diff mbox series

Patch

diff --git a/lib/eal/include/generic/rte_mcslock.h b/lib/eal/include/generic/rte_mcslock.h
index 34f33c64a5..806a2b2c7e 100644
--- a/lib/eal/include/generic/rte_mcslock.h
+++ b/lib/eal/include/generic/rte_mcslock.h
@@ -116,8 +116,13 @@  rte_mcslock_unlock(rte_mcslock_t **msl, rte_mcslock_t *me)
 		/* More nodes added to the queue by other CPUs.
 		 * Wait until the next pointer is set.
 		 */
-		while (__atomic_load_n(&me->next, __ATOMIC_RELAXED) == NULL)
-			rte_pause();
+#ifdef RTE_ARCH_32
+		rte_wait_event((uint32_t *)&me->next, UINT32_MAX, ==, 0,
+				__ATOMIC_RELAXED);
+#else
+		rte_wait_event((uint64_t *)&me->next, UINT64_MAX, ==, 0,
+				__ATOMIC_RELAXED);
+#endif
 	}
 
 	/* Pass lock to next waiter. */