From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7AFD3A0500 for ; Tue, 17 Dec 2019 19:07:00 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 61FD21BE9E; Tue, 17 Dec 2019 19:07:00 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 8D4101BE9E for ; Tue, 17 Dec 2019 19:06:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576606019; 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=SLcHqlhWQdoltMUeFWf0GOMPtggknYtC5w+hsTNXEWI=; b=eKPfxlZmjM3kh+ML2coKIyK92bUqnBnqQQrus7lEPvYWU0fOfKsgewKdz7MDCSUUqv4Apo ino6Yn5mioAOI8AxmJnzDySXMseE8Alf0bEjC6/NU4K78MMvPc7mXsvcEDvOrUoxRexSzK T/YL04dRWS+XhFbOOO4swkdiH9Cac0w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-108-StP2GxklM7-I8AQbCEBXoA-1; Tue, 17 Dec 2019 13:06:55 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74DC0911E9; Tue, 17 Dec 2019 18:06:54 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-117-34.ams2.redhat.com [10.36.117.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCD3A7C839; Tue, 17 Dec 2019 18:06:50 +0000 (UTC) From: Adrian Moreno To: stable@dpdk.org Cc: ktraynor@redhat.com, maxime.coquelin@redhat.com, "Michael S . Tsirkin" , Tiwei Bie Date: Tue, 17 Dec 2019 19:06:34 +0100 Message-Id: <20191217180640.17993-2-amorenoz@redhat.com> In-Reply-To: <20191217180640.17993-1-amorenoz@redhat.com> References: <20191217180640.17993-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: StP2GxklM7-I8AQbCEBXoA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] [PATCH 18.11 1/7] vhost: batch used descs chains write-back with packed ring X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Maxime Coquelin [ upstream commit b473ec1131ee44ee25e0536a04be65246b93f4f3 ] Instead of writing back descriptors chains in order, let's write the first chain flags last in order to improve batching. Also, move the write barrier in logging cache sync, so that it is done only when logging is enabled. It means there is now one more barrier for split ring when logging is enabled. With Kernel's pktgen benchmark, ~3% performance gain is measured. Signed-off-by: Maxime Coquelin Acked-by: Michael S. Tsirkin Reviewed-by: Tiwei Bie --- lib/librte_vhost/vhost.h | 7 ++----- lib/librte_vhost/virtio_net.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index daccf5c65..47d64bad3 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -456,12 +456,9 @@ vhost_log_cache_sync(struct virtio_net *dev, struct vh= ost_virtqueue *vq) =09=09 !dev->log_base)) =09=09return; =20 -=09log_base =3D (unsigned long *)(uintptr_t)dev->log_base; +=09rte_smp_wmb(); =20 -=09/* -=09 * It is expected a write memory barrier has been issued -=09 * before this function is called. -=09 */ +=09log_base =3D (unsigned long *)(uintptr_t)dev->log_base; =20 =09for (i =3D 0; i < vq->log_cache_nb_elem; i++) { =09=09struct log_cache_entry *elem =3D vq->log_cache + i; diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 740db2ed7..6ae617698 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -136,6 +136,8 @@ flush_shadow_used_ring_packed(struct virtio_net *dev, { =09int i; =09uint16_t used_idx =3D vq->last_used_idx; +=09uint16_t head_idx =3D vq->last_used_idx; +=09uint16_t head_flags =3D 0; =20 =09/* Split loop in two to save memory barriers */ =09for (i =3D 0; i < vq->shadow_used_idx; i++) { @@ -165,12 +167,17 @@ flush_shadow_used_ring_packed(struct virtio_net *dev, =09=09=09flags &=3D ~VRING_DESC_F_AVAIL; =09=09} =20 -=09=09vq->desc_packed[vq->last_used_idx].flags =3D flags; +=09=09if (i > 0) { +=09=09=09vq->desc_packed[vq->last_used_idx].flags =3D flags; =20 -=09=09vhost_log_cache_used_vring(dev, vq, +=09=09=09vhost_log_cache_used_vring(dev, vq, =09=09=09=09=09vq->last_used_idx * =09=09=09=09=09sizeof(struct vring_packed_desc), =09=09=09=09=09sizeof(struct vring_packed_desc)); +=09=09} else { +=09=09=09head_idx =3D vq->last_used_idx; +=09=09=09head_flags =3D flags; +=09=09} =20 =09=09vq->last_used_idx +=3D vq->shadow_used_packed[i].count; =09=09if (vq->last_used_idx >=3D vq->size) { @@ -179,7 +186,13 @@ flush_shadow_used_ring_packed(struct virtio_net *dev, =09=09} =09} =20 -=09rte_smp_wmb(); +=09vq->desc_packed[head_idx].flags =3D head_flags; + +=09vhost_log_cache_used_vring(dev, vq, +=09=09=09=09head_idx * +=09=09=09=09sizeof(struct vring_packed_desc), +=09=09=09=09sizeof(struct vring_packed_desc)); + =09vq->shadow_used_idx =3D 0; =09vhost_log_cache_sync(dev, vq); } --=20 2.21.0