[RFC,v2,2/5] ticketlock: use new API to reduce contention on aarch64

Message ID 1562144316-14687-3-git-send-email-gavin.hu@arm.com (mailing list archive)
State Superseded, archived
Headers
Series use WFE for locks and ring on aarch64 |

Checks

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

Commit Message

Gavin Hu July 3, 2019, 8:58 a.m. UTC
  While using ticket lock, cores repeatedly poll the lock variable.
This is replaced by rte_wait_until_equal API.

Running ticketlock_autotest on ThunderX2, with different numbers of cores
and depths of rings, 3%~8% performance gains were measured.

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 lib/librte_eal/common/include/generic/rte_ticketlock.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Pavan Nikhilesh Bhagavatula July 20, 2019, 6:57 a.m. UTC | #1
>-----Original Message-----
>From: dev <dev-bounces@dpdk.org> On Behalf Of Gavin Hu
>Sent: Wednesday, July 3, 2019 2:29 PM
>To: dev@dpdk.org
>Cc: nd@arm.com
>Subject: [dpdk-dev] [RFC v2 2/5] ticketlock: use new API to reduce
>contention on aarch64
>
>While using ticket lock, cores repeatedly poll the lock variable.
>This is replaced by rte_wait_until_equal API.
>
>Running ticketlock_autotest on ThunderX2, with different numbers of
>cores
>and depths of rings, 3%~8% performance gains were measured.

Tested on octeontx2 board.

>
>Signed-off-by: Gavin Hu <gavin.hu@arm.com>
>Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>---
> lib/librte_eal/common/include/generic/rte_ticketlock.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/lib/librte_eal/common/include/generic/rte_ticketlock.h
>b/lib/librte_eal/common/include/generic/rte_ticketlock.h
>index 191146f..8fa1f62 100644
>--- a/lib/librte_eal/common/include/generic/rte_ticketlock.h
>+++ b/lib/librte_eal/common/include/generic/rte_ticketlock.h
>@@ -64,8 +64,7 @@ static inline __rte_experimental void
> rte_ticketlock_lock(rte_ticketlock_t *tl)
> {
> 	uint16_t me = __atomic_fetch_add(&tl->s.next, 1,
>__ATOMIC_RELAXED);
>-	while (__atomic_load_n(&tl->s.current, __ATOMIC_ACQUIRE)
>!= me)
>-		rte_pause();
>+	rte_wait_until_equal16(&tl->s.current, me,
>__ATOMIC_ACQUIRE);
> }
>
> /**
>--
>2.7.4
  

Patch

diff --git a/lib/librte_eal/common/include/generic/rte_ticketlock.h b/lib/librte_eal/common/include/generic/rte_ticketlock.h
index 191146f..8fa1f62 100644
--- a/lib/librte_eal/common/include/generic/rte_ticketlock.h
+++ b/lib/librte_eal/common/include/generic/rte_ticketlock.h
@@ -64,8 +64,7 @@  static inline __rte_experimental void
 rte_ticketlock_lock(rte_ticketlock_t *tl)
 {
 	uint16_t me = __atomic_fetch_add(&tl->s.next, 1, __ATOMIC_RELAXED);
-	while (__atomic_load_n(&tl->s.current, __ATOMIC_ACQUIRE) != me)
-		rte_pause();
+	rte_wait_until_equal16(&tl->s.current, me, __ATOMIC_ACQUIRE);
 }
 
 /**