From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 297131B796 for ; Wed, 7 Feb 2018 09:59:41 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D58BF20BA9; Wed, 7 Feb 2018 03:59:40 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 07 Feb 2018 03:59:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=/jIIRvFPS0gV7GxGB hj8e62w6b2fHh5LZywkednC+iY=; b=p5Kf8XRQPhnm5Fia/eyczxu37r5uRnLLA bvEoPWGwgGdvWEMiOWtuGOroKC+qFqcfpZ0o3A255i5u3RegaFxseQMDojk8i7SC gZfqbN8DTM98pH5JyZiR54nKILhvaMHecPYnYFawDSNm9LTej0FK92VENNQZ8J/M I/cflaYho0bkeZRFf2cOW3a5bwYLZo/yIKnCaQrUtmv5HF2yFvIBZEtl/cnmZ18S MNfUbjnz/BxEn4xRNrdjJkC+U8qfjSJ6nn2/F1sdIqRtCWqVl+N42mXuj3MuZEqs mtRhuI3pbtH+4eC8rM79GSCm7K1uDNLLzu+d0TRQONWZGh/bp/YAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=/jIIRvFPS0gV7GxGBhj8e62w6b2fHh5LZywkednC+iY=; b=D8dIggzt iN3xZ2dkySrFPi/+uRcyk2mIK8zwpuaaF20OAjJhxjKbXJc2KbOYMBlwVqd3fZj1 AjyeTTgrgzPNaMYXikmKMc7EsgZ9Ja00IPwj3UGNMXyjfJjRfNZu5yDsYX29aNU/ nOIHssYhW18uqJgVZ2WbT5RmxZTi0snmoCMpVv+bvDCwtSXcJkB1dzKAcYC7RmkX A82DYjfMOnpoiRHi+tjurBM1YgSDHce4a2IpQgkAlXKb8cSkqqxPV3TGpsJL0EC/ Wkfn/9+rxIOMRPJtpDTiXaSXHHqiDcqTo6Tebqfk2ykN0o+nh46/o1FzDK3lFveW +ljxlr2DDX1Tlw== X-ME-Sender: Received: from localhost.localdomain (unknown [182.84.161.100]) by mail.messagingengine.com (Postfix) with ESMTPA id 5558A240DE; Wed, 7 Feb 2018 03:59:39 -0500 (EST) From: Yuanhan Liu To: Maxime Coquelin Cc: dpdk stable Date: Wed, 7 Feb 2018 16:57:02 +0800 Message-Id: <1517993838-26692-8-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517993838-26692-1-git-send-email-yliu@fridaylinux.org> References: <1517993838-26692-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'vhost: fix IOTLB pool out-of-memory handling' has been queued to LTS release 17.11.1 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: , X-List-Received-Date: Wed, 07 Feb 2018 08:59:41 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/09/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 2f6b2ae70c32cc9e9bcc377945cdedaa3d7e515d Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Mon, 5 Feb 2018 16:04:56 +0100 Subject: [PATCH] vhost: fix IOTLB pool out-of-memory handling [ upstream commit 37771844a05c7b0a7b039dcae1b4b0a69b4acced ] In the unlikely case the IOTLB memory pool runs out of memory, an issue may happen if all entries are used by the IOTLB cache, and an IOTLB miss happen. If the iotlb pending list is empty, then no memory is freed and allocation fails a second time. This patch fixes this by doing an IOTLB cache random evict if the IOTLB pending list is empty, ensuring the second allocation try will succeed. In the same spirit, the opposite is done when inserting an IOTLB entry in the IOTLB cache fails due to out of memory. In this case, the IOTLB pending is flushed if the IOTLB cache is empty to ensure the new entry can be inserted. Fixes: d012d1f293f4 ("vhost: add IOTLB helper functions") Fixes: f72c2ad63aeb ("vhost: add pending IOTLB miss request list and helpers") Signed-off-by: Maxime Coquelin --- lib/librte_vhost/iotlb.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c index b74cc6a..72cd27d 100644 --- a/lib/librte_vhost/iotlb.c +++ b/lib/librte_vhost/iotlb.c @@ -51,6 +51,9 @@ struct vhost_iotlb_entry { #define IOTLB_CACHE_SIZE 2048 static void +vhost_user_iotlb_cache_random_evict(struct vhost_virtqueue *vq); + +static void vhost_user_iotlb_pending_remove_all(struct vhost_virtqueue *vq) { struct vhost_iotlb_entry *node, *temp_node; @@ -95,9 +98,11 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, ret = rte_mempool_get(vq->iotlb_pool, (void **)&node); if (ret) { - RTE_LOG(INFO, VHOST_CONFIG, - "IOTLB pool empty, clear pending misses\n"); - vhost_user_iotlb_pending_remove_all(vq); + RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n"); + if (!TAILQ_EMPTY(&vq->iotlb_pending_list)) + vhost_user_iotlb_pending_remove_all(vq); + else + vhost_user_iotlb_cache_random_evict(vq); ret = rte_mempool_get(vq->iotlb_pool, (void **)&node); if (ret) { RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n"); @@ -186,8 +191,11 @@ vhost_user_iotlb_cache_insert(struct vhost_virtqueue *vq, uint64_t iova, ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node); if (ret) { - RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, evict one entry\n"); - vhost_user_iotlb_cache_random_evict(vq); + RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n"); + if (!TAILQ_EMPTY(&vq->iotlb_list)) + vhost_user_iotlb_cache_random_evict(vq); + else + vhost_user_iotlb_pending_remove_all(vq); ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node); if (ret) { RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n"); -- 2.7.4