From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 3FCA32946 for ; Mon, 7 Mar 2016 14:49:29 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 07 Mar 2016 05:49:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,551,1449561600"; d="scan'208";a="665187865" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by FMSMGA003.fm.intel.com with ESMTP; 07 Mar 2016 05:49:28 -0800 Received: from irsmsx153.ger.corp.intel.com ([169.254.9.60]) by IRSMSX103.ger.corp.intel.com ([169.254.3.239]) with mapi id 14.03.0248.002; Mon, 7 Mar 2016 13:49:26 +0000 From: "Loftus, Ciara" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 3/3] vhost: fix vq realloc at numa_realloc Thread-Index: AQHRPIpZrpSdmkwwxU2Z62xX8MDCSp9Odoog Date: Mon, 7 Mar 2016 13:49:26 +0000 Message-ID: <74F120C019F4A64C9B78E802F6AD4CC24F833781@IRSMSX153.ger.corp.intel.com> References: <1450422247-6814-1-git-send-email-yuanhan.liu@linux.intel.com> <1450769304-22986-1-git-send-email-yuanhan.liu@linux.intel.com> <1450769304-22986-3-git-send-email-yuanhan.liu@linux.intel.com> In-Reply-To: <1450769304-22986-3-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 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: Mon, 07 Mar 2016 13:49:29 -0000 >=20 > 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: >=20 > VHOST_CONFIG: reallocate vq from 0 to 1 node > PANIC in rte_free(): > Fatal error: Invalid memory >=20 > 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. >=20 > Fixes: e049ca6d10e0 ("vhost-user: prepare multiple queue setup") >=20 > Signed-off-by: Yuanhan Liu > Acked-by: Huawei Xie > --- > lib/librte_vhost/virtio-net.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > 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; >=20 > + /* > + * vq is allocated on pairs, we should try to do realloc > + * on first queue of one queue pair only. > + */ > + if (index % VIRTIO_QNUM !=3D 0) > + return dev; > + > old_dev =3D dev; > vq =3D old_vq =3D dev->virtqueue[index]; >=20 > @@ -461,11 +468,12 @@ numa_realloc(struct virtio_net *dev, int index) > if (oldnode !=3D newnode) { > RTE_LOG(INFO, VHOST_CONFIG, > "reallocate vq from %d to %d node\n", oldnode, > newnode); > - vq =3D rte_malloc_socket(NULL, sizeof(*vq), 0, newnode); > + vq =3D rte_malloc_socket(NULL, sizeof(*vq) * VIRTIO_QNUM, > 0, > + newnode); > if (!vq) > return dev; >=20 > - memcpy(vq, old_vq, sizeof(*vq)); > + memcpy(vq, old_vq, sizeof(*vq) * VIRTIO_QNUM); > rte_free(old_vq); > } >=20 > @@ -491,6 +499,7 @@ numa_realloc(struct virtio_net *dev, int index) >=20 > out: > dev->virtqueue[index] =3D vq; > + dev->virtqueue[index + 1] =3D vq + 1; > vhost_devices[dev->device_fh] =3D dev; >=20 > 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 patc= hes. Tested-by: Ciara Loftus Thanks, Ciara