[dpdk-dev] [PATCH 4/4] vhost: avoid populate guest memory

Tan, Jianfeng jianfeng.tan at intel.com
Thu Feb 22 03:42:42 CET 2018


Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin [mailto:maxime.coquelin at redhat.com]
> Sent: Tuesday, February 20, 2018 4:45 AM
> To: Tan, Jianfeng; dev at dpdk.org
> Cc: yliu at fridaylinux.org
> Subject: Re: [PATCH 4/4] vhost: avoid populate guest memory
> 
> Hi Jianfeng,
> 
> On 02/14/2018 05:01 AM, Jianfeng Tan wrote:
> > It's not necessary to polulate guest memory from vhost side.
> >
> > Cc: maxime.coquelin at redhat.com
> > Cc: yliu at fridaylinux.org
> >
> > Signed-off-by: Jianfeng Tan <jianfeng.tan at intel.com>
> > ---
> >   lib/librte_vhost/vhost_user.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > 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,
> >
> 
> Wouldn't not populating all the guest memory have a bad impact on 0%
> acceptable loss use-cases?

Yes, it could affect such use case; but we can address that by warming up the system a little bit, can't we?

From a good point of view, it could save the memory for VMs without pre-allocating.

Thanks,
Jianfeng


More information about the dev mailing list