From patchwork Thu Mar 2 00:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 124620 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E278641DAF; Thu, 2 Mar 2023 01:48:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17CB34282D; Thu, 2 Mar 2023 01:48:04 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 9B8C24021F for ; Thu, 2 Mar 2023 01:48:02 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id EAEE1209FE0C; Wed, 1 Mar 2023 16:48:01 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EAEE1209FE0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1677718081; bh=Go/gyhX55ybw6sMZBbocLMoEkOP0sfqdzvee+SF4pYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7DxfcvDj/+nwlZH4yC9mNxYTJqCHZ7h73zkOPY1nfZAh9IoVZOGetxCXz1EJpG2s pmvcYDB5PGjRRxSBe0TsZEdg4E3Ab7oZB2EiBCJbYn3iyPM2WlQx3ISospTA1IJOfP Ut8UD8EYsxbhsITBkOR/h3QBwErL7PPwV/HbIo8c= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 01/17] vhost: use previous value atomic fetch operations Date: Wed, 1 Mar 2023 16:47:32 -0800 Message-Id: <1677718068-2412-2-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> References: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> 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 Reviewed-by: Maxime Coquelin --- lib/vhost/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 51dc3c9..dc49a54 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -298,7 +298,7 @@ vhost_log_cache_sync(dev, vq); - __atomic_add_fetch(&vq->used->idx, vq->shadow_used_idx, + __atomic_fetch_add(&vq->used->idx, vq->shadow_used_idx, __ATOMIC_RELEASE); vq->shadow_used_idx = 0; vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx), @@ -2311,7 +2311,7 @@ vhost_vring_call_packed(dev, vq); } else { write_back_completed_descs_split(vq, n_descs); - __atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE); + __atomic_fetch_add(&vq->used->idx, n_descs, __ATOMIC_RELEASE); vhost_vring_call_split(dev, vq); } } else { @@ -3683,7 +3683,7 @@ vhost_vring_call_packed(dev, vq); } else { write_back_completed_descs_split(vq, nr_cpl_pkts); - __atomic_add_fetch(&vq->used->idx, nr_cpl_pkts, __ATOMIC_RELEASE); + __atomic_fetch_add(&vq->used->idx, nr_cpl_pkts, __ATOMIC_RELEASE); vhost_vring_call_split(dev, vq); } vq->async->pkts_inflight_n -= nr_cpl_pkts;