From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C6B5FA0C55; Wed, 13 Oct 2021 20:55:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34DF64124B; Wed, 13 Oct 2021 20:54:29 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id E8216411FA for ; Wed, 13 Oct 2021 20:54:21 +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 56914152F; Wed, 13 Oct 2021 11:54:21 -0700 (PDT) Received: from 2p2660v4-1.austin.arm.com (2p2660v4-1.austin.arm.com [10.118.13.211]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 500493F70D; Wed, 13 Oct 2021 11:54:21 -0700 (PDT) From: Dharmik Thakkar To: David Hunt Cc: dev@dpdk.org, nd@arm.com, honnappa.nagarahalli@arm.com, ruifeng.wang@arm.com, joyce.kong@arm.com, dharmik.thakkar@arm.com Date: Wed, 13 Oct 2021 13:54:05 -0500 Message-Id: <20211013185407.2841183-7-dharmik.thakkar@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013185407.2841183-1-dharmik.thakkar@arm.com> References: <20210823054952.15001-1-joyce.kong@arm.com> <20211013185407.2841183-1-dharmik.thakkar@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 6/8] examples/vm_power_manager: use compiler atomics for sync X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Joyce Kong Convert rte_atomic32_cmpset to compiler atomic CAS operation for channel status sync. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- examples/vm_power_manager/channel_monitor.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index f03102eb1b93..d767423a401b 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #ifdef RTE_NET_I40E @@ -827,8 +826,9 @@ process_request(struct rte_power_channel_packet *pkt, if (chan_info == NULL) return -1; - if (rte_atomic32_cmpset(&(chan_info->status), CHANNEL_MGR_CHANNEL_CONNECTED, - CHANNEL_MGR_CHANNEL_PROCESSING) == 0) + uint32_t channel_connected = CHANNEL_MGR_CHANNEL_CONNECTED; + if (__atomic_compare_exchange_n(&(chan_info->status), &channel_connected, + CHANNEL_MGR_CHANNEL_PROCESSING, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED) == 0) return -1; if (pkt->command == RTE_POWER_CPU_POWER) { @@ -932,8 +932,9 @@ process_request(struct rte_power_channel_packet *pkt, * Return is not checked as channel status may have been set to DISABLED * from management thread */ - rte_atomic32_cmpset(&(chan_info->status), CHANNEL_MGR_CHANNEL_PROCESSING, - CHANNEL_MGR_CHANNEL_CONNECTED); + uint32_t channel_processing = CHANNEL_MGR_CHANNEL_PROCESSING; + __atomic_compare_exchange_n(&(chan_info->status), &channel_processing, + CHANNEL_MGR_CHANNEL_CONNECTED, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED); return 0; } -- 2.25.1