DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Loftus, Ciara" <ciara.loftus@intel.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 3/3] vhost: fix vq realloc at numa_realloc
Date: Mon, 7 Mar 2016 13:49:26 +0000	[thread overview]
Message-ID: <74F120C019F4A64C9B78E802F6AD4CC24F833781@IRSMSX153.ger.corp.intel.com> (raw)
In-Reply-To: <1450769304-22986-3-git-send-email-yuanhan.liu@linux.intel.com>

> 
> vq is allocated on pairs, hence we should do pair reallocation
> at numa_realloc() as well, otherwise an error like following
> occurs while do numa reallocation:
> 
>     VHOST_CONFIG: reallocate vq from 0 to 1 node
>     PANIC in rte_free():
>     Fatal error: Invalid memory
> 
> The reason we don't catch it is because numa_realloc() will
> not take effect when RTE_LIBRTE_VHOST_NUMA is not enabled,
> which is the default case.
> 
> Fixes: e049ca6d10e0 ("vhost-user: prepare multiple queue setup")
> 
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Acked-by: Huawei Xie <huawei.xie@intel.com>
> ---
>  lib/librte_vhost/virtio-net.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
> index 1566c93..7469312 100644
> --- a/lib/librte_vhost/virtio-net.c
> +++ b/lib/librte_vhost/virtio-net.c
> @@ -445,6 +445,13 @@ numa_realloc(struct virtio_net *dev, int index)
>  	struct vhost_virtqueue *old_vq, *vq;
>  	int ret;
> 
> +	/*
> +	 * vq is allocated on pairs, we should try to do realloc
> +	 * on first queue of one queue pair only.
> +	 */
> +	if (index % VIRTIO_QNUM != 0)
> +		return dev;
> +
>  	old_dev = dev;
>  	vq = old_vq = dev->virtqueue[index];
> 
> @@ -461,11 +468,12 @@ numa_realloc(struct virtio_net *dev, int index)
>  	if (oldnode != newnode) {
>  		RTE_LOG(INFO, VHOST_CONFIG,
>  			"reallocate vq from %d to %d node\n", oldnode,
> newnode);
> -		vq = rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);
> +		vq = rte_malloc_socket(NULL, sizeof(*vq) * VIRTIO_QNUM,
> 0,
> +				       newnode);
>  		if (!vq)
>  			return dev;
> 
> -		memcpy(vq, old_vq, sizeof(*vq));
> +		memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM);
>  		rte_free(old_vq);
>  	}
> 
> @@ -491,6 +499,7 @@ numa_realloc(struct virtio_net *dev, int index)
> 
>  out:
>  	dev->virtqueue[index] = vq;
> +	dev->virtqueue[index + 1] = vq + 1;
>  	vhost_devices[dev->device_fh] = dev;
> 
>  	return dev;
> --
> 1.9.0

I encountered the " PANIC in rte_free():" error when using RTE_LIBRTE_VHOST_NUMA too, and applying this series resolved the issue. Thanks for the patches.

Tested-by: Ciara Loftus <ciara.loftus@intel.com>

Thanks,
Ciara

  reply	other threads:[~2016-03-07 13:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18  7:04 [dpdk-dev] [PATCH 1/3] vhost: get rid of linked list dev Yuanhan Liu
2015-12-18  7:04 ` [dpdk-dev] [PATCH 2/3] vhost: simplify numa_realloc Yuanhan Liu
2015-12-22  6:46   ` Xie, Huawei
2015-12-22  6:52     ` Yuanhan Liu
2015-12-18  7:04 ` [dpdk-dev] [PATCH 3/3] vhost: fix vq realloc at numa_realloc Yuanhan Liu
2015-12-22  6:56   ` Xie, Huawei
2015-12-22  3:33 ` [dpdk-dev] [PATCH 1/3] vhost: get rid of linked list dev Xie, Huawei
2015-12-22  6:21 ` Xie, Huawei
2015-12-22  7:28 ` [dpdk-dev] [PATCH v2 " Yuanhan Liu
2015-12-22  7:28   ` [dpdk-dev] [PATCH v2 2/3] vhost: simplify numa_realloc Yuanhan Liu
2015-12-22 14:40     ` Xie, Huawei
2015-12-22  7:28   ` [dpdk-dev] [PATCH v2 3/3] vhost: fix vq realloc at numa_realloc Yuanhan Liu
2016-03-07 13:49     ` Loftus, Ciara [this message]
2016-03-08 11:54       ` Yuanhan Liu
2016-03-10  4:19 ` [dpdk-dev] [PATCH v3 0/3] vhost: virtio-net.c cleanups and fixes Yuanhan Liu
2016-03-10  4:19   ` [dpdk-dev] [PATCH v3 1/3] vhost: get rid of linked list dev Yuanhan Liu
2016-03-10  4:20   ` [dpdk-dev] [PATCH v3 2/3] vhost: simplify numa_realloc Yuanhan Liu
2016-03-10  4:20   ` [dpdk-dev] [PATCH v3 3/3] vhost: fix vq realloc at numa_realloc Yuanhan Liu
2016-03-11 15:35   ` [dpdk-dev] [PATCH v3 0/3] vhost: virtio-net.c cleanups and fixes Thomas Monjalon

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=74F120C019F4A64C9B78E802F6AD4CC24F833781@IRSMSX153.ger.corp.intel.com \
    --to=ciara.loftus@intel.com \
    --cc=dev@dpdk.org \
    --cc=yuanhan.liu@linux.intel.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).