From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id A14612BAB for ; Thu, 10 Mar 2016 05:17:24 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 09 Mar 2016 20:17:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,314,1455004800"; d="scan'208";a="920663023" Received: from yliu-dev.sh.intel.com ([10.239.66.49]) by fmsmga001.fm.intel.com with ESMTP; 09 Mar 2016 20:17:22 -0800 From: Yuanhan Liu To: dev@dpdk.org Date: Thu, 10 Mar 2016 12:20:01 +0800 Message-Id: <1457583601-27365-4-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1457583601-27365-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1450422247-6814-1-git-send-email-yuanhan.liu@linux.intel.com> <1457583601-27365-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH v3 3/3] vhost: fix vq realloc at numa_realloc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2016 04:17:25 -0000 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 Acked-by: Huawei Xie Tested-by: Ciara Loftus --- 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