ticketlock: use new API to reduce contention on aarch64
authorGavin Hu <gavin.hu@arm.com>
Thu, 7 Nov 2019 21:35:26 +0000 (22:35 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 17 Jan 2020 11:02:21 +0000 (12:02 +0100)
While using ticket lock, cores repeatedly poll the lock variable.
This is replaced by rte_wait_until_equal API.

Running ticketlock_autotest on ThunderX2, Ampere eMAG80, and Arm N1SDP[1],
there were variances between runs, but no notable performance gain or
degradation were seen with and without this patch.

[1] https://community.arm.com/developer/tools-software/oss-platforms/w/\
docs/440/neoverse-n1-sdp

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Tested-by: Phil Yang <phil.yang@arm.com>
Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Jerin Jacob <jerinj@marvell.com>
lib/librte_eal/common/include/generic/rte_ticketlock.h

index d9bec87..c295ae7 100644 (file)
@@ -66,8 +66,7 @@ static inline 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_equal_16(&tl->s.current, me, __ATOMIC_ACQUIRE);
 }
 
 /**