From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 3/3] vhost: fix vq realloc at numa_realloc
Date: Thu, 10 Mar 2016 12:20:01 +0800 [thread overview]
Message-ID: <1457583601-27365-4-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1457583601-27365-1-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>
Tested-by: Ciara Loftus <ciara.loftus@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 764810e..28c3912 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -448,6 +448,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];
@@ -465,11 +472,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);
}
@@ -497,6 +505,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
next prev parent reply other threads:[~2016-03-10 4:17 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
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 ` Yuanhan Liu [this message]
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=1457583601-27365-4-git-send-email-yuanhan.liu@linux.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.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).