From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 0ED40A0487
	for <public@inbox.dpdk.org>; Wed,  3 Jul 2019 10:59:12 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 8322F1BDFB;
	Wed,  3 Jul 2019 10:59:01 +0200 (CEST)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by dpdk.org (Postfix) with ESMTP id 8A90A1B964
 for <dev@dpdk.org>; Wed,  3 Jul 2019 10:58:56 +0200 (CEST)
Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])
 by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1DE6ECFC;
 Wed,  3 Jul 2019 01:58:56 -0700 (PDT)
Received: from net-arm-thunderx2.shanghai.arm.com
 (net-arm-thunderx2.shanghai.arm.com [10.169.40.40])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5A1E43F718;
 Wed,  3 Jul 2019 01:58:55 -0700 (PDT)
From: Gavin Hu <gavin.hu@arm.com>
To: dev@dpdk.org
Cc: nd@arm.com
Date: Wed,  3 Jul 2019 16:58:33 +0800
Message-Id: <1562144316-14687-3-git-send-email-gavin.hu@arm.com>
X-Mailer: git-send-email 2.7.4
In-Reply-To: <1562144316-14687-1-git-send-email-gavin.hu@arm.com>
References: <1562144316-14687-1-git-send-email-gavin.hu@arm.com>
In-Reply-To: <1561911676-37718-1-git-send-email-gavin.hu@arm.com>
References: <1561911676-37718-1-git-send-email-gavin.hu@arm.com>
Subject: [dpdk-dev] [RFC v2 2/5] ticketlock: use new API to reduce
	contention on aarch64
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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(-)

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