From: Joyce Kong Date: Wed, 13 Oct 2021 18:54:05 +0000 (-0500) Subject: examples/vm_power: use compiler atomics for sync X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=14215f34e8a4126c9d1b1df37600787c6996098c;p=dpdk.git examples/vm_power: use compiler atomics for sync Convert rte_atomic32_cmpset to compiler atomic CAS operation for channel status sync. Signed-off-by: Joyce Kong Reviewed-by: Ruifeng Wang --- diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index f03102eb1b..d767423a40 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; }