DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: Yi Yang <yi.y.yang@intel.com>
Cc: yliu@fridaylinux.org, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] vhost: fix vhost_user_set_mem_table error
Date: Mon, 25 Sep 2017 12:46:51 +0800	[thread overview]
Message-ID: <20170925044651.GA18891@debian-ZGViaWFuCg> (raw)
In-Reply-To: <1505896323-125943-1-git-send-email-yi.y.yang@intel.com>

Hi Yi,

On Wed, Sep 20, 2017 at 04:32:03PM +0800, Yi Yang wrote:
> Usually vhost_user message VHOST_USER_SET_MEM_TABLE
> is only sent out during initialization and only sent
> once, but it isn't so for memory hotplug and hotunplug
> , for that case, vhost_user message VHOST_USER_SET_MEM_TABLE
> will be resent with the old memory regions (not hotunplugged)
> and the new memory regions (hotplugged), so current
> vhost_user_set_mem_table implementation is wrong for
> memory hotplug and hotunplug case, it will free current
> memory regions and unmap hugepages no matter if they
> are be using or not and if they are memory regions which
> have been initialized and mapped in the previous vhost_user
> message VHOST_USER_SET_MEM_TABLE or not.
> 
> This commit fixed this issue very well, it will keep them
> intact for those old memory region it will unmap those
> memroy regions if they have been hotunplugged, it will
> initialize the new hotplugged memory regions and map
> hugepages if they are hotplugged.
> 
> vhost_user message VHOST_USER_SET_MEM_TABLE will include
> all the current effective memory regions, the hotunplugged
> memory regions won't be included in VHOST_USER_SET_MEM_TABLE,
> the hotplugged memroy regions will be included in
> VHOST_USER_SET_MEM_TABLE.
> 
> This has been verified in OVS DPDK by memory hotplug and
> hotunplug in qemu.
> 
> Signed-off-by: Yi Yang <yi.y.yang@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 72 ++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 65 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index ad2e8d3..1c475d1 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
[...]
> @@ -532,7 +558,7 @@ vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
>  		}
>  	}
>  
> -	dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_memory) +
> +	dev->mem = rte_realloc(dev->mem, sizeof(struct rte_vhost_memory) +

The rte_realloc() will free the memory pointed by the dev->mem.
But it's possible that some other threads are using it (e.g. by
calling rte_vhost_gpa_to_vva()). It's an issue that needs to be
fixed in this patch.

Best regards,
Tiwei Bie

      parent reply	other threads:[~2017-09-25  4:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20  8:32 Yi Yang
2017-09-22  5:28 ` Tan, Jianfeng
2017-09-25  2:29   ` Yang, Yi
2017-09-25  4:46 ` Tiwei Bie [this message]

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=20170925044651.GA18891@debian-ZGViaWFuCg \
    --to=tiwei.bie@intel.com \
    --cc=dev@dpdk.org \
    --cc=yi.y.yang@intel.com \
    --cc=yliu@fridaylinux.org \
    /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).