From patchwork Tue Dec 5 11:30:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Agota Benyhe X-Patchwork-Id: 31934 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 E70642A5D; Tue, 5 Dec 2017 12:30:42 +0100 (CET) Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by dpdk.org (Postfix) with ESMTP id 5C93E200 for ; Tue, 5 Dec 2017 12:30:41 +0100 (CET) X-AuditID: c1b4fb3a-7b5619c000003538-e2-5a2683600780 Received: from ESESSHC003.ericsson.se (Unknown_Domain [153.88.183.27]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 3B.65.13624.063862A5; Tue, 5 Dec 2017 12:30:40 +0100 (CET) Received: from labserv2.eth.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.29) with Microsoft SMTP Server id 14.3.352.0; Tue, 5 Dec 2017 12:30:36 +0100 Received: from gep5.sdn.hu.eld.ericsson.se (unknown [172.31.40.105]) by labserv2.eth.ericsson.se (Postfix) with ESMTP id 1259C29C72C; Tue, 5 Dec 2017 12:24:04 +0100 (CET) From: Agota Benyhe To: CC: Agota Benyhe , Patrik Andersson R Date: Tue, 5 Dec 2017 12:30:33 +0100 Message-ID: <1512473433-18170-1-git-send-email-agota.benyhe@ericsson.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512464838-17300-1-git-send-email-agota.benyhe@ericsson.com> References: <1512464838-17300-1-git-send-email-agota.benyhe@ericsson.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsUyM2K7tG5Cs1qUwfdOK4t3n7YzOTB6/Fqw lDWAMYrLJiU1J7MstUjfLoErY8enmSwFzeIVE07MZW9g7BXuYuTkkBAwkfg9rYm5i5GLQ0jg MKNE+6UzbBDOZkaJKWe/skI46xklDq6bwAjSwiagJ7Ht8x4WEFtEQEhi6cfL7CA2s0CKxNb2 S0ANHBzCAp4SfzrsQMIsAioS61beBmvlBQrPOvqNCWKznMTJY5NZQWxOAS+Jli/NYCOFgGpe X97FBlEvKHFy5hMWiPESEgdfvGCGqFGT6D76hXECo8AsJGWzkJQtYGRaxShanFpcnJtuZKSX WpSZXFycn6eXl1qyiREYbAe3/LbawXjwueMhRgEORiUe3nXFalFCrIllxZW5hxglOJiVRHh9 m4BCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeU968kYJCaQnlqRmp6YWpBbBZJk4OKUaGO064x4c s0nZu83r6fl/V5jdHHc+mHIkM1ddNPCKdy6vRVe8Wt1hqfLXPhlLAn2N+k8qPLvOdO6q4NuO jErRKe0LHmgEaHOuupekcqw4qyPfYPaL6c3LY3SLeuV7YtgqHn46HGo+e3/ghtZyluQDDmuY 4qbPki/m/SpovITDdUWHp6Att4WrEktxRqKhFnNRcSIANWp5YzICAAA= Subject: [dpdk-dev] [PATCH v2] 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..dcc1879 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);