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 96D49A057B; Wed, 1 Apr 2020 15:53:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F1CA1FFA; Wed, 1 Apr 2020 15:53:33 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 1915E3B5 for ; Wed, 1 Apr 2020 15:53:31 +0200 (CEST) IronPort-SDR: nW2K3GDAcFaMewseJk+Q5RCRAmgSsDRP8EXfpB6ss5izbZ5ltZQru34eOlq902Cl0NP1iq82eu yQbkRFEgx8/g== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 06:53:31 -0700 IronPort-SDR: E8GWeyZQnhRItxPjaxiwNuylZ+siYlrVKN7Nl8R9CInOeN8tJYbAyb19fdIxRcUMHBUBFH0+JI K5H4wWaeEFLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,331,1580803200"; d="scan'208";a="449193278" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.58]) by fmsmga005.fm.intel.com with ESMTP; 01 Apr 2020 06:53:29 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, xiaolong.ye@intel.com, zhihong.wang@intel.com, eperezma@redhat.com Cc: dev@dpdk.org, Marvin Liu Date: Thu, 2 Apr 2020 05:29:26 +0800 Message-Id: <20200401212926.74989-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] vhost: remove deferred shadow update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Defer shadow ring update will help overall throughput when frontend much slower than backend. But that is not all the cases we faced now. In case like ovs-dpdk + dpdk virtio user, frontend will much faster than backend. Frontend may not be able to collect available descs when shadow update is deferred. Thus will harm RFC2544 performance. Solution is just remove deferred shadow update, which will help RFC2544 and fix potential issue with virtio net driver. Signed-off-by: Marvin Liu diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 37c47c7dc..2ba0575a7 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -382,25 +382,6 @@ vhost_shadow_enqueue_single_packed(struct virtio_net *dev, } } -static __rte_always_inline void -vhost_flush_dequeue_packed(struct virtio_net *dev, - struct vhost_virtqueue *vq) -{ - int shadow_count; - if (!vq->shadow_used_idx) - return; - - shadow_count = vq->last_used_idx - vq->shadow_last_used_idx; - if (shadow_count <= 0) - shadow_count += vq->size; - - if ((uint32_t)shadow_count >= (vq->size - MAX_PKT_BURST)) { - do_data_copy_dequeue(vq); - vhost_flush_dequeue_shadow_packed(dev, vq); - vhost_vring_call_packed(dev, vq); - } -} - /* avoid write operation when necessary, to lessen cache issues */ #define ASSIGN_UNLESS_EQUAL(var, val) do { \ if ((var) != (val)) \ @@ -2133,20 +2114,6 @@ virtio_dev_tx_packed_zmbuf(struct virtio_net *dev, return pkt_idx; } -static __rte_always_inline bool -next_desc_is_avail(const struct vhost_virtqueue *vq) -{ - bool wrap_counter = vq->avail_wrap_counter; - uint16_t next_used_idx = vq->last_used_idx + 1; - - if (next_used_idx >= vq->size) { - next_used_idx -= vq->size; - wrap_counter ^= 1; - } - - return desc_is_avail(&vq->desc_packed[next_used_idx], wrap_counter); -} - static __rte_noinline uint16_t virtio_dev_tx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, @@ -2163,7 +2130,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (remained >= PACKED_BATCH_SIZE) { if (!virtio_dev_tx_batch_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) { - vhost_flush_dequeue_packed(dev, vq); pkt_idx += PACKED_BATCH_SIZE; remained -= PACKED_BATCH_SIZE; continue; @@ -2173,7 +2139,6 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (virtio_dev_tx_single_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) break; - vhost_flush_dequeue_packed(dev, vq); pkt_idx++; remained--; @@ -2182,15 +2147,8 @@ virtio_dev_tx_packed(struct virtio_net *dev, if (vq->shadow_used_idx) { do_data_copy_dequeue(vq); - if (remained && !next_desc_is_avail(vq)) { - /* - * The guest may be waiting to TX some buffers to - * enqueue more to avoid bufferfloat, so we try to - * reduce latency here. - */ - vhost_flush_dequeue_shadow_packed(dev, vq); - vhost_vring_call_packed(dev, vq); - } + vhost_flush_dequeue_shadow_packed(dev, vq); + vhost_vring_call_packed(dev, vq); } return pkt_idx; -- 2.17.1