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 C8FD01B020 for ; Mon, 15 Jan 2018 10:05:49 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2018 01:05:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,362,1511856000"; d="scan'208";a="10160235" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 15 Jan 2018 01:05:48 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Jan 2018 01:05:48 -0800 Received: from bgsmsx102.gar.corp.intel.com (10.223.4.172) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Jan 2018 01:05:48 -0800 Received: from bgsmsx101.gar.corp.intel.com ([169.254.1.245]) by BGSMSX102.gar.corp.intel.com ([10.223.4.172]) with mapi id 14.03.0319.002; Mon, 15 Jan 2018 14:35:45 +0530 From: "Yang, Zhiyong" To: "Chen, Junjie J" , "yliu@fridaylinux.org" , "maxime.coquelin@redhat.com" CC: "dev@dpdk.org" , "Chen, Junjie J" Thread-Topic: [dpdk-dev] [PATCH] vhost: do deep copy while reallocate vq Thread-Index: AQHTjbQ/5KsxoduuNUyWcernZcX9X6N0oo6Q Date: Mon, 15 Jan 2018 09:05:45 +0000 Message-ID: References: <1516015939-11266-1-git-send-email-junjie.j.chen@intel.com> In-Reply-To: <1516015939-11266-1-git-send-email-junjie.j.chen@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.223.10.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vhost: do deep copy while reallocate vq X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 09:05:50 -0000 Hi Junjie, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Junjie Chen > Sent: Monday, January 15, 2018 7:32 PM > To: yliu@fridaylinux.org; maxime.coquelin@redhat.com > Cc: dev@dpdk.org; Chen, Junjie J > Subject: [dpdk-dev] [PATCH] vhost: do deep copy while reallocate vq >=20 > When vhost reallocate dev and vq for NUMA enabled case, it doesn't > perform deep copy, which lead to 1) zmbuf list not valid 2) remote memory > access. > This patch is to re-initlize the zmbuf list and also do the deep copy. >=20 > Signed-off-by: Junjie Chen > --- > lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) >=20 > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c > index f4c7ce4..795462c 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -227,6 +227,7 @@ vhost_user_set_vring_num(struct virtio_net *dev, > "zero copy is force disabled\n"); > dev->dequeue_zero_copy =3D 0; > } > + TAILQ_INIT(&vq->zmbuf_list); > } >=20 > vq->shadow_used_ring =3D rte_malloc(NULL, @@ -261,6 +262,9 @@ > numa_realloc(struct virtio_net *dev, int index) > int oldnode, newnode; > struct virtio_net *old_dev; > struct vhost_virtqueue *old_vq, *vq; > + struct zcopy_mbuf *new_zmbuf; > + struct vring_used_elem *new_shadow_used_ring; > + struct batch_copy_elem *new_batch_copy_elems; > int ret; >=20 > old_dev =3D dev; > @@ -285,6 +289,33 @@ numa_realloc(struct virtio_net *dev, int index) > return dev; >=20 > memcpy(vq, old_vq, sizeof(*vq)); > + TAILQ_INIT(&vq->zmbuf_list); > + > + new_zmbuf =3D rte_malloc_socket(NULL, vq->zmbuf_size * > + sizeof(struct zcopy_mbuf), 0, newnode); > + if (new_zmbuf) { > + rte_free(vq->zmbufs); > + vq->zmbufs =3D new_zmbuf; > + } You need to consider how to handle the case ( rte_malloc_socket return NUL= L). > + new_shadow_used_ring =3D rte_malloc_socket(NULL, > + vq->size * sizeof(struct vring_used_elem), > + RTE_CACHE_LINE_SIZE, > + newnode); > + if (new_shadow_used_ring) { > + rte_free(vq->shadow_used_ring); > + vq->shadow_used_ring =3D new_shadow_used_ring; > + } > + Ditto > + new_batch_copy_elems =3D rte_malloc_socket(NULL, > + vq->size * sizeof(struct batch_copy_elem), > + RTE_CACHE_LINE_SIZE, > + newnode); > + if (new_batch_copy_elems) { > + rte_free(vq->batch_copy_elems); > + vq->batch_copy_elems =3D new_batch_copy_elems; > + } Ditto > + > rte_free(old_vq); > } >=20 > -- > 2.0.1