From patchwork Tue Apr 28 09:52:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sivaprasad Tummala X-Patchwork-Id: 69454 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0353A00BE; Tue, 28 Apr 2020 11:52:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F3841D5CC; Tue, 28 Apr 2020 11:52:12 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 7DBAC1C00D for ; Tue, 28 Apr 2020 11:52:11 +0200 (CEST) IronPort-SDR: sZUaP0WPkg425fyFw6Ck3tsP+107TmGZardDdmntLkFfilg5njOPoLk4mdarNpSqabJxfze8sc 14ZIME7hPVDA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 02:52:09 -0700 IronPort-SDR: oyamr1HKhAMCH2c/081UoV2UIpl43fzgQe4slXvqC+KYOooHUiuuIkABazVDw71S4bwS0L4Egv FG4SciNwg9EA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,327,1583222400"; d="scan'208";a="404639362" Received: from unknown (HELO localhost.localdomain) ([10.190.212.182]) by orsmga004.jf.intel.com with ESMTP; 28 Apr 2020 02:52:08 -0700 From: Sivaprasad Tummala To: Maxime Coquelin , Zhihong Wang , Xiaolong Ye Cc: dev@dpdk.org Date: Tue, 28 Apr 2020 15:22:03 +0530 Message-Id: <20200428095203.64935-1-Sivaprasad.Tummala@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] vhost: fix mbuf allocation failures 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" vhost buffer allocation is successful for packets that fit into a linear buffer. If it fails, vhost library is expected to drop the current buffer descriptor and skip to the next. The patch fixes the error scenario by skipping to next descriptor. Note: Drop counters are not currently supported. Signed-off-by: Sivaprasad Tummala --- lib/librte_vhost/virtio_net.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 37c47c7dc..b0d3a85c2 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -1688,6 +1688,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, { uint16_t i; uint16_t free_entries; + uint16_t dropped = 0; if (unlikely(dev->dequeue_zero_copy)) { struct zcopy_mbuf *zmbuf, *next; @@ -1751,8 +1752,19 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, update_shadow_used_ring_split(vq, head_idx, 0); pkts[i] = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); - if (unlikely(pkts[i] == NULL)) + if (unlikely(pkts[i] == NULL)) { + /* + * mbuf allocation fails for jumbo packets with + * linear buffer flag set. Drop this packet and + * proceed with the next available descriptor to + * avoid HOL blocking + */ + VHOST_LOG_DATA(WARNING, + "Failed to allocate memory for mbuf. Packet dropped!\n"); + dropped += 1; + i++; break; + } err = copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, pkts[i], mbuf_pool); @@ -1796,7 +1808,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, } } - return i; + return (i - dropped); } static __rte_always_inline int