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 51E8241DB5; Thu, 2 Mar 2023 17:19:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AF59D42D1A; Thu, 2 Mar 2023 17:18:38 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 82F1140E2D for ; Thu, 2 Mar 2023 17:18:31 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4CD3420BC5E7; Thu, 2 Mar 2023 08:18:30 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4CD3420BC5E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677773910; bh=TucspOmkXdNi0rLwL2Hfx4kCg2NN5cwo1ue/IysF9Z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UQxG5QgFQTZmWnXo1xlub3CHkF4HNVKp85pa4JEMUyIy/DOvsq+ZInlqNnoB5KDKD OsPTJFNqU+LfOrOYTY+r41ie3ZU8r8ElVj5vmOk7VOHP/ePS9hgDFzXtq87MZQbTxH wiy18EIbFP2EaDzcd9ImaAQ0jBk2HkDI2uwdIUgI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, bruce.richardson@intel.com, mb@smartsharesystems.com, Ruifeng.Wang@arm.com, maxime.coquelin@redhat.com, Tyler Retzlaff Subject: [PATCH v2 07/17] examples/vhost: use previous value atomic fetch operations Date: Thu, 2 Mar 2023 08:18:12 -0800 Message-Id: <1677773902-5167-8-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677773902-5167-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> <1677773902-5167-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch when we have no interest in the result of the operation. Reduces unnecessary codegen that provided the result of the atomic operation that was not used. Change brings closer alignment with atomics available in C11 standard and will reduce review effort when they are integrated. Signed-off-by: Tyler Retzlaff Acked-by: Morten Brørup Reviewed-by: Maxime Coquelin --- examples/vhost/main.c | 12 ++++++------ examples/vhost/virtio_net.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 42e53a0..bfe466f 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1048,9 +1048,9 @@ static unsigned check_ports_num(unsigned nb_ports) } if (enable_stats) { - __atomic_add_fetch(&dst_vdev->stats.rx_total_atomic, 1, + __atomic_fetch_add(&dst_vdev->stats.rx_total_atomic, 1, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&dst_vdev->stats.rx_atomic, ret, + __atomic_fetch_add(&dst_vdev->stats.rx_atomic, ret, __ATOMIC_SEQ_CST); src_vdev->stats.tx_total++; src_vdev->stats.tx += ret; @@ -1068,9 +1068,9 @@ static unsigned check_ports_num(unsigned nb_ports) ret = vdev_queue_ops[vdev->vid].enqueue_pkt_burst(vdev, VIRTIO_RXQ, m, nr_xmit); if (enable_stats) { - __atomic_add_fetch(&vdev->stats.rx_total_atomic, nr_xmit, + __atomic_fetch_add(&vdev->stats.rx_total_atomic, nr_xmit, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&vdev->stats.rx_atomic, ret, + __atomic_fetch_add(&vdev->stats.rx_atomic, ret, __ATOMIC_SEQ_CST); } @@ -1400,9 +1400,9 @@ static void virtio_tx_offload(struct rte_mbuf *m) } if (enable_stats) { - __atomic_add_fetch(&vdev->stats.rx_total_atomic, rx_count, + __atomic_fetch_add(&vdev->stats.rx_total_atomic, rx_count, __ATOMIC_SEQ_CST); - __atomic_add_fetch(&vdev->stats.rx_atomic, enqueue_count, + __atomic_fetch_add(&vdev->stats.rx_atomic, enqueue_count, __ATOMIC_SEQ_CST); } diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c index 1d4737f..514c8e0 100644 --- a/examples/vhost/virtio_net.c +++ b/examples/vhost/virtio_net.c @@ -231,7 +231,7 @@ rte_prefetch0(&vr->desc[desc_indexes[i+1]]); } - __atomic_add_fetch(&vr->used->idx, count, __ATOMIC_RELEASE); + __atomic_fetch_add(&vr->used->idx, count, __ATOMIC_RELEASE); queue->last_used_idx += count; rte_vhost_vring_call(dev->vid, queue_id); @@ -442,7 +442,7 @@ queue->last_avail_idx += i; queue->last_used_idx += i; - __atomic_add_fetch(&vr->used->idx, i, __ATOMIC_ACQ_REL); + __atomic_fetch_add(&vr->used->idx, i, __ATOMIC_ACQ_REL); rte_vhost_vring_call(dev->vid, queue_id); -- 1.8.3.1