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 50E7041DB5; Thu, 2 Mar 2023 15:47:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3358640E09; Thu, 2 Mar 2023 15:47:27 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id F0718400D6 for ; Thu, 2 Mar 2023 15:47:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677768444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nwwhl5Artp4sx7OOm2dPI2wFgSimu4YmkyIwD3KLLA0=; b=VgZBTTWmSm+1FMEXNJ+78ZDGz/84Tve+1+WONzYls8oil6TDBpc2GZQoRYUu1rhlIYj81+ lo7WPIVc28aU/WRO1NZAGMoXr8AFY61vZX9Btu/T0kt1jweeKCj2wYuXsL6hNlc6414PWa coARf16oLVavl4rNPK7Pi/C8/cxqQ00= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-kKVVblGBOHWHyNLwLvh8_g-1; Thu, 02 Mar 2023 09:47:21 -0500 X-MC-Unique: kKVVblGBOHWHyNLwLvh8_g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F2F038173D1; Thu, 2 Mar 2023 14:47:20 +0000 (UTC) Received: from [10.39.208.28] (unknown [10.39.208.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 965B12026D4B; Thu, 2 Mar 2023 14:47:19 +0000 (UTC) Message-ID: Date: Thu, 2 Mar 2023 15:47:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 01/17] vhost: use previous value atomic fetch operations To: Tyler Retzlaff , dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, thomas@monjalon.net References: <1677718068-2412-1-git-send-email-roretzla@linux.microsoft.com> <1677718068-2412-2-git-send-email-roretzla@linux.microsoft.com> From: Maxime Coquelin In-Reply-To: <1677718068-2412-2-git-send-email-roretzla@linux.microsoft.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 3/2/23 01:47, Tyler Retzlaff wrote: > 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 > --- > 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; Reviewed-by: Maxime Coquelin Thanks, Maxime