From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C6DE6A0032;
	Fri, 29 Oct 2021 10:20:51 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 6026941144;
	Fri, 29 Oct 2021 10:20:44 +0200 (CEST)
Received: from foss.arm.com (foss.arm.com [217.140.110.172])
 by mails.dpdk.org (Postfix) with ESMTP id 5D6E241143
 for <dev@dpdk.org>; Fri, 29 Oct 2021 10:20:43 +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 E56A6ED1;
 Fri, 29 Oct 2021 01:20:42 -0700 (PDT)
Received: from net-x86-dell-8268.shanghai.arm.com
 (net-x86-dell-8268.shanghai.arm.com [10.169.210.102])
 by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8125A3F5A1;
 Fri, 29 Oct 2021 01:20:39 -0700 (PDT)
From: Feifei Wang <feifei.wang2@arm.com>
To: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Cc: dev@dpdk.org, nd@arm.com, jerinjacobk@gmail.com,
 stephen@networkplumber.org, david.marchand@redhat.com, thomas@monjalon.net,
 mattias.ronnblom@ericsson.com, konstantin.ananyev@intel.com,
 Feifei Wang <feifei.wang2@arm.com>, Ruifeng Wang <ruifeng.wang@arm.com>
Date: Fri, 29 Oct 2021 16:20:19 +0800
Message-Id: <20211029082021.945586-4-feifei.wang2@arm.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20211029082021.945586-1-feifei.wang2@arm.com>
References: <20210902053253.3017858-1-feifei.wang2@arm.com>
 <20211029082021.945586-1-feifei.wang2@arm.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v8 3/5] eal: use wait event scheme for mcslock
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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>

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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/eal/include/generic/rte_mcslock.h b/lib/eal/include/generic/rte_mcslock.h
index 34f33c64a5..b4e07648ff 100644
--- a/lib/eal/include/generic/rte_mcslock.h
+++ b/lib/eal/include/generic/rte_mcslock.h
@@ -116,8 +116,9 @@ 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();
+		uintptr_t *next;
+		next = (uintptr_t *)&me->next;
+		rte_wait_event(next, UINTPTR_MAX, ==, 0, __ATOMIC_RELAXED);
 	}
 
 	/* Pass lock to next waiter. */
-- 
2.25.1