From: Wan Junjie <wanjunjie@bytedance.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, Wan Junjie <wanjunjie@bytedance.com>,
Peng He <hepeng.0320@bytedance.com>,
Zhihong Wang <wangzhihong.wzh@bytedance.com>
Subject: [dpdk-dev] [PATCH] vhost: avoid iotlb mempool allocation while IOMMU disabled
Date: Sat, 30 Jan 2021 00:39:09 +0800 [thread overview]
Message-ID: <20210129163909.35970-1-wanjunjie@bytedance.com> (raw)
If vhost device's IOMMU feature is disabled, iotlb mempool allocation
is unnecessary.
Reported-by: Peng He <hepeng.0320@bytedance.com>
Signed-off-by: Wan Junjie <wanjunjie@bytedance.com>
Reviewed-by: Zhihong Wang <wangzhihong.wzh@bytedance.com>
---
lib/librte_vhost/vhost.c | 6 ++++--
lib/librte_vhost/vhost_user.c | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index efb136edd..00c5040e2 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -352,7 +352,8 @@ free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq)
vhost_free_async_mem(vq);
}
rte_free(vq->batch_copy_elems);
- rte_mempool_free(vq->iotlb_pool);
+ if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
+ rte_mempool_free(vq->iotlb_pool);
rte_free(vq);
}
@@ -556,7 +557,8 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
vq->notif_enable = VIRTIO_UNINITIALIZED_NOTIF;
- vhost_user_iotlb_init(dev, vring_idx);
+ if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
+ vhost_user_iotlb_init(dev, vring_idx);
/* Backends are set to -1 indicating an inactive device. */
vq->backend = -1;
}
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index a60bb945a..d415607d7 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -575,7 +575,7 @@ numa_realloc(struct virtio_net *dev, int index)
dev->virtqueue[index] = vq;
vhost_devices[dev->vid] = dev;
- if (old_vq != vq)
+ if (old_vq != vq && (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))
vhost_user_iotlb_init(dev, index);
return dev;
--
2.29.2
next reply other threads:[~2021-01-29 17:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 16:39 Wan Junjie [this message]
2021-02-01 7:41 ` Xia, Chenbo
2021-02-02 8:38 ` [dpdk-dev] [PATCH v2] " Wan Junjie
2021-02-03 2:26 ` Xia, Chenbo
2021-02-03 16:49 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210129163909.35970-1-wanjunjie@bytedance.com \
--to=wanjunjie@bytedance.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=hepeng.0320@bytedance.com \
--cc=maxime.coquelin@redhat.com \
--cc=wangzhihong.wzh@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).