From patchwork Mon May 17 08:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 93283 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44B0BA0A02; Mon, 17 May 2021 11:00:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2EFE4014E; Mon, 17 May 2021 11:00:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 6DDF240041 for ; Mon, 17 May 2021 11:00:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621242012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P8fosMMDhVqE+1eFS3xOUKzsXfaNu5wfsM5+XUwxwKA=; b=dbYqmd6c1mlOgo9ubfuQ5ZR1wqM7LPvuBHLRnH2a9xdtNi/246XgDOPUsZGmLSZ2vWKsQJ gnHRsZxz/XoT3WjO7ITl72XWqUPmPib2W8aKSDzsBpt0TBWRFB/Ng/AOdREKrJ1m1N2TKH kD2VPicv0Uub58hg8Y/Siua96WvlKhQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-1S6r1AXEPGyv00l__YgRYA-1; Mon, 17 May 2021 05:00:10 -0400 X-MC-Unique: 1S6r1AXEPGyv00l__YgRYA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19DD18015DB; Mon, 17 May 2021 09:00:09 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A2615B4A8; Mon, 17 May 2021 08:59:59 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, Maxime Coquelin , Chenbo Xia , Zhihong Wang , Junjie Wan Date: Mon, 17 May 2021 10:59:51 +0200 Message-Id: <20210517085951.28970-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH] vhost: restore IOTLB mempool allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" As explained by Chenbo, IOTLB messages will be sent when some queues are not enabled. If we initialize IOTLB in vhost_user_set_vring_num, it could happen that IOTLB update comes when IOTLB pool of disabled queues are not initialized. Fixes: 968bbc7e2e50 ("vhost: avoid IOTLB mempool allocation while IOMMU disabled") Signed-off-by: David Marchand Reviewed-by: Chenbo Xia --- Summary of a discussion with Maxime: To keep the mempool allocation optimization, we could try to initialise the per-vring mempools at reception of the first IOTLB message. Since those pools are used as caches, it is not an issue if some vrings received more IOTLB updates than others. But looking/testing this now is too late for 21.05, hence reverting is the safer. --- lib/vhost/vhost.c | 5 +++-- lib/vhost/vhost_user.c | 6 +----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 9cbcf650b6..c96f6335c8 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -365,8 +365,7 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq) vhost_free_async_mem(vq); rte_free(vq->batch_copy_elems); - if (vq->iotlb_pool) - rte_mempool_free(vq->iotlb_pool); + rte_mempool_free(vq->iotlb_pool); rte_free(vq->log_cache); rte_free(vq); } @@ -570,6 +569,8 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx) vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD; vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD; vq->notif_enable = VIRTIO_UNINITIALIZED_NOTIF; + + vhost_user_iotlb_init(dev, vring_idx); } static void diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 611ff209e3..8f0eba6412 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -469,10 +469,6 @@ vhost_user_set_vring_num(struct virtio_net **pdev, return RTE_VHOST_MSG_RESULT_ERR; } - if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) { - if (vhost_user_iotlb_init(dev, msg->payload.state.index)) - return RTE_VHOST_MSG_RESULT_ERR; - } return RTE_VHOST_MSG_RESULT_OK; } @@ -578,7 +574,7 @@ numa_realloc(struct virtio_net *dev, int index) dev->virtqueue[index] = vq; vhost_devices[dev->vid] = dev; - if (old_vq != vq && (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) + if (old_vq != vq) vhost_user_iotlb_init(dev, index); return dev;