From patchwork Tue Dec 5 09:07:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Agota Benyhe X-Patchwork-Id: 31925 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 06B3B2B99; Tue, 5 Dec 2017 10:07:24 +0100 (CET) Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by dpdk.org (Postfix) with ESMTP id 7E6BB1E2B for ; Tue, 5 Dec 2017 10:07:22 +0100 (CET) X-AuditID: c1b4fb30-093dd9c0000029e3-14-5a2661c98a28 Received: from ESESSHC001.ericsson.se (Unknown_Domain [153.88.183.21]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 6A.03.10723.9C1662A5; Tue, 5 Dec 2017 10:07:22 +0100 (CET) Received: from labserv2.eth.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.23) with Microsoft SMTP Server id 14.3.352.0; Tue, 5 Dec 2017 10:07:21 +0100 Received: from gep5.sdn.hu.eld.ericsson.se (unknown [172.31.40.105]) by labserv2.eth.ericsson.se (Postfix) with ESMTP id 78C1729C72C; Tue, 5 Dec 2017 10:00:49 +0100 (CET) From: Agota Benyhe To: CC: Agota Benyhe , Patrik Andersson R Date: Tue, 5 Dec 2017 10:07:18 +0100 Message-ID: <1512464838-17300-1-git-send-email-agota.benyhe@ericsson.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnluLIzCtJLcpLzFFi42KZGbFdVPdUolqUwd5r7BbvPm1ncmD0+LVg KWsAYxSXTUpqTmZZapG+XQJXxqquVWwFy8QrJn/fwN7A2CvcxcjJISFgIjHv8E7mLkYuDiGB w4wSq69/hXI2M0q8bnjJCuGsZ5RYfPUkE0gLm4CexLbPe1hAbBEBIYmlHy+zg9jMAikSW9sv sYLYwgJuEo9nTgWrZxFQkdgxvZexi5GDg1fAU+LjphqIzXISJ49NBivnFRCUODnzCQvEGAmJ gy9eMIPYQgJqEt1HvzBOYOSbhaRsFpKyBYxMqxhFi1OLk3LTjYz0Uosyk4uL8/P08lJLNjEC g+fglt8GOxhfPnc8xCjAwajEw6sRqRYlxJpYVlyZe4hRgoNZSYT3yXzVKCHelMTKqtSi/Pii 0pzU4kOM0hwsSuK8Jz15o4QE0hNLUrNTUwtSi2CyTBycUg2MNrzhlaaia7IeHnHz61H0q1VZ eWhGl6u+8xtRZ76+uSxXCjw/ma3dsWqJ9c9H1dZizP5qGzrM9+41W/Vd7sCbrBNVORn5Mn+1 Jp3n5X/zOtCafUOR4eLlbZH8n6uUjJXTWqVsp/xZFDT/hv+ygj1JW7QU96w8e8V1518l1nWy OYsmVqn8fW6vxFKckWioxVxUnAgAkBDSNhoCAAA= Subject: [dpdk-dev] [PATCH] virtio_net: kick guest even when virtio queue is full 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" From: Patrik Andersson R Changing the vring call file descriptor during virtio device enqueue operation may lead to "kick" on a file descriptor that is closed. As a consequence the guest might not be notified of new packets in the enqueue. The suggested change will add some extra load on DPDK and on the guest if the queue is frequently full. Any application using DPDK should avoid attempting retransmissions when the zero packets are enqueued. To overcome this problem, the kick operation in virtio_dev_merge_rx() was excluded from the pkt_idx > 0 condition. A similar change was done in virtio_dev_rx(). Signed-off-by: Patrik Andersson R Signed-off-by: Agota Benyhe --- lib/librte_vhost/virtio_net.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 6fee16e..f5fc8c0 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -59,6 +59,13 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t nr_vring) } static __rte_always_inline void +kick_guest_if_necessary(const struct vhost_virtqueue *vq) { + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) + && (vq->callfd >= 0)) + eventfd_write(vq->callfd, (eventfd_t)1); +} + +static __rte_always_inline void do_flush_shadow_used_ring(struct virtio_net *dev, struct vhost_virtqueue *vq, uint16_t to, uint16_t from, uint16_t size) { @@ -344,8 +351,11 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, free_entries = avail_idx - start_idx; count = RTE_MIN(count, free_entries); count = RTE_MIN(count, (uint32_t)MAX_PKT_BURST); - if (count == 0) + + if (count == 0) { + kick_guest_if_necessary(vq); goto out; + } LOG_DEBUG(VHOST_DATA, "(%d) start_idx %d | end_idx %d\n", dev->vid, start_idx, start_idx + count); @@ -411,10 +421,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id, /* flush used->idx update before we read avail->flags. */ rte_mb(); - /* Kick the guest if necessary. */ - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) - && (vq->callfd >= 0)) - eventfd_write(vq->callfd, (eventfd_t)1); + kick_guest_if_necessary(vq); out: if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) vhost_user_iotlb_rd_unlock(vq); @@ -704,13 +711,9 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, /* flush used->idx update before we read avail->flags. */ rte_mb(); - - /* Kick the guest if necessary. */ - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) - && (vq->callfd >= 0)) - eventfd_write(vq->callfd, (eventfd_t)1); } + kick_guest_if_necessary(vq); out: if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) vhost_user_iotlb_rd_unlock(vq);