From: Jianfeng Tan <jianfeng.tan@intel.com>
To: dev@dpdk.org
Cc: Jianfeng Tan <jianfeng.tan@intel.com>, maxime.coquelin@redhat.com
Subject: [dpdk-dev] [PATCH v2] vhost: avoid populate guest memory
Date: Wed, 28 Mar 2018 06:56:07 +0000 [thread overview]
Message-ID: <1522220167-29059-1-git-send-email-jianfeng.tan@intel.com> (raw)
In-Reply-To: <161752fc-9dd8-f952-eb00-ff1cb6e5fbdd@redhat.com>
It's not necessary to populate guest memory from vhost side unless
zerocopy is enabled or users want better performance.
Update the doc for guest memory requirement clarification.
Cc: maxime.coquelin@redhat.com
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
doc/guides/prog_guide/vhost_lib.rst | 21 +++++++++++++++++++++
doc/guides/sample_app_ug/vhost.rst | 9 ---------
lib/librte_vhost/vhost_user.c | 4 +++-
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst
index 18227b6..f474736 100644
--- a/doc/guides/prog_guide/vhost_lib.rst
+++ b/doc/guides/prog_guide/vhost_lib.rst
@@ -214,6 +214,27 @@ the vhost device from the data plane.
When the socket connection is closed, vhost will destroy the device.
+Guest memory requirement
+------------------------
+
+* Memory pre-allocation
+
+ For non-zerocopy, guest memory pre-allocation is not a must. This can help
+ save of memory. If users really want the guest memory to be pre-allocated
+ (e.g., for performance reason), we can add option ``-mem-prealloc`` when
+ starting QEMU. Or, we can lock all memory at vhost side which will force
+ memory to be allocated when mmap at vhost side; option --mlockall in
+ ovs-dpdk is an example in hand.
+
+ For zerocopy, we force the VM memory to be pre-allocated at vhost lib when
+ mapping the guest memory; and also we need to lock the memory to prevent
+ pages being swapped out to disk.
+
+* Memory sharing
+
+ Make sure ``share=on`` QEMU option is given. vhost-user will not work with
+ a QEMU version without shared memory mapping.
+
Vhost supported vSwitch reference
---------------------------------
diff --git a/doc/guides/sample_app_ug/vhost.rst b/doc/guides/sample_app_ug/vhost.rst
index a4bdc6a..da161a9 100644
--- a/doc/guides/sample_app_ug/vhost.rst
+++ b/doc/guides/sample_app_ug/vhost.rst
@@ -175,15 +175,6 @@ Common Issues
The command above indicates how many hugepages are free to support QEMU's
allocation request.
-* vhost-user will not work with QEMU without the ``-mem-prealloc`` option
-
- The current implementation works properly only when the guest memory is
- pre-allocated.
-
-* vhost-user will not work with a QEMU version without shared memory mapping:
-
- Make sure ``share=on`` QEMU option is given.
-
* Failed to build DPDK in VM
Make sure "-cpu host" QEMU option is given.
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 90ed211..9bd0391 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -644,6 +644,7 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
uint64_t mmap_offset;
uint64_t alignment;
uint32_t i;
+ int populate;
int fd;
if (dev->mem && !vhost_memory_changed(&memory, dev->mem)) {
@@ -714,8 +715,9 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
}
mmap_size = RTE_ALIGN_CEIL(mmap_size, alignment);
+ populate = (dev->dequeue_zero_copy) ? MAP_POPULATE : 0;
mmap_addr = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_POPULATE, fd, 0);
+ MAP_SHARED | populate, fd, 0);
if (mmap_addr == MAP_FAILED) {
RTE_LOG(ERR, VHOST_CONFIG,
--
2.7.4
next prev parent reply other threads:[~2018-03-28 6:54 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 4:01 [dpdk-dev] [PATCH 0/4] some fixes target for 18.05 Jianfeng Tan
2018-02-14 4:01 ` [dpdk-dev] [PATCH 1/4] vhost: remove unused macro Jianfeng Tan
2018-02-19 20:49 ` Maxime Coquelin
2018-02-21 7:32 ` Maxime Coquelin
2018-02-14 4:01 ` [dpdk-dev] [PATCH 2/4] vhost: avoid function call in data path Jianfeng Tan
2018-02-19 20:48 ` Maxime Coquelin
2018-02-21 7:32 ` Maxime Coquelin
2018-02-14 4:01 ` [dpdk-dev] [PATCH 3/4] app/testpmd: add option to avoid lock all memory Jianfeng Tan
2018-02-14 6:40 ` Wu, Jingjing
2018-02-24 3:26 ` [dpdk-dev] [PATCH v2] " Jianfeng Tan
2018-04-22 23:05 ` Thomas Monjalon
2018-05-03 11:32 ` Burakov, Anatoly
2018-02-14 4:01 ` [dpdk-dev] [PATCH 4/4] vhost: avoid populate guest memory Jianfeng Tan
2018-02-19 20:44 ` Maxime Coquelin
2018-02-22 2:42 ` Tan, Jianfeng
2018-02-22 8:25 ` Maxime Coquelin
2018-02-22 8:40 ` Tan, Jianfeng
2018-02-22 12:32 ` Maxime Coquelin
2018-02-23 3:17 ` Tan, Jianfeng
2018-03-28 6:56 ` Jianfeng Tan [this message]
2018-03-30 8:21 ` [dpdk-dev] [PATCH v2] " Maxime Coquelin
2018-03-30 8:34 ` Maxime Coquelin
2018-02-21 7:35 ` [dpdk-dev] [PATCH 0/4] some fixes target for 18.05 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=1522220167-29059-1-git-send-email-jianfeng.tan@intel.com \
--to=jianfeng.tan@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.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).