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 199B18D8F for ; Tue, 22 Dec 2015 07:46:36 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 21 Dec 2015 22:46:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,463,1444719600"; d="scan'208";a="867044488" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 21 Dec 2015 22:46:36 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Dec 2015 22:46:35 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 21 Dec 2015 22:46:34 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.190]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.151]) with mapi id 14.03.0248.002; Tue, 22 Dec 2015 14:46:32 +0800 From: "Xie, Huawei" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [PATCH 2/3] vhost: simplify numa_realloc Thread-Index: AdE8hH5GUVJ8d8/gTj2jAt9YrqVmFQ== Date: Tue, 22 Dec 2015 06:46:32 +0000 Message-ID: References: <1450422247-6814-1-git-send-email-yuanhan.liu@linux.intel.com> <1450422247-6814-2-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/3] vhost: simplify 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: Tue, 22 Dec 2015 06:46:37 -0000 On 12/18/2015 3:03 PM, Yuanhan Liu wrote:=0A= > We could first check if we need realloc vq or not, if so,=0A= > reallocate it. We then do similar to vhost dev realloc.=0A= >=0A= > This could get rid of the tons of repeated "if (realloc_dev)"=0A= > and "if (realloc_vq)" statements, therefore, makes code=0A= > a bit more readable.=0A= >=0A= > Signed-off-by: Yuanhan Liu =0A= > ---=0A= > lib/librte_vhost/virtio-net.c | 77 ++++++++++++++++++++-----------------= ------=0A= > 1 file changed, 36 insertions(+), 41 deletions(-)=0A= >=0A= > diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.= c=0A= > index 2f83438..31ca4f7 100644=0A= > --- a/lib/librte_vhost/virtio-net.c=0A= > +++ b/lib/librte_vhost/virtio-net.c=0A= > @@ -441,64 +441,59 @@ static struct virtio_net*=0A= > numa_realloc(struct virtio_net *dev, int index)=0A= > {=0A= > int oldnode, newnode;=0A= > - struct virtio_net *old_dev, *new_dev =3D NULL;=0A= > - struct vhost_virtqueue *old_vq, *new_vq =3D NULL;=0A= > + struct virtio_net *old_dev;=0A= > + struct vhost_virtqueue *old_vq, *vq;=0A= > int ret;=0A= > - int realloc_dev =3D 0, realloc_vq =3D 0;=0A= > =0A= > old_dev =3D dev;=0A= > - old_vq =3D dev->virtqueue[index];=0A= > + vq =3D old_vq =3D dev->virtqueue[index];=0A= > =0A= > - ret =3D get_mempolicy(&newnode, NULL, 0, old_vq->desc,=0A= > - MPOL_F_NODE | MPOL_F_ADDR);=0A= > - ret =3D ret | get_mempolicy(&oldnode, NULL, 0, old_dev,=0A= > + ret =3D get_mempolicy(&newnode, NULL, 0, old_vq->desc,=0A= > MPOL_F_NODE | MPOL_F_ADDR);=0A= > +=0A= > + /* check if we need to reallocate vq */=0A= > + ret =3D get_mempolicy(&oldnode, NULL, 0, old_vq, MPOL_F_NODE | MPOL_F_A= DDR);=0A= =0A= Why remove the ret =3D ret | ? Both get_mempolicy could fail.=0A= =0A= > if (ret) {=0A= > RTE_LOG(ERR, VHOST_CONFIG,=0A= > - "Unable to get vring desc or dev numa information.\n");=0A= > + "Unable to get vq numa information.\n");=0A= > return dev;=0A= > }=0A= > - if (oldnode !=3D newnode)=0A= > - realloc_dev =3D 1;=0A= > + if (oldnode !=3D newnode) {=0A= > + RTE_LOG(INFO, VHOST_CONFIG,=0A= > + "reallocate vq from %d to %d node\n", oldnode, newnode);=0A= > + vq =3D rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);=0A= > + if (!vq)=0A= > + return dev;=0A= > +=0A= > + memcpy(vq, old_vq, sizeof(*vq));=0A= > + rte_free(old_vq);=0A= > + }=0A= > =0A= > - ret =3D get_mempolicy(&oldnode, NULL, 0, old_vq,=0A= > - MPOL_F_NODE | MPOL_F_ADDR);=0A= > + /* check if we need to reallocate dev */=0A= > + ret =3D get_mempolicy(&oldnode, NULL, 0, old_dev, MPOL_F_NODE | MPOL_F_= ADDR);=0A= > if (ret) {=0A= > RTE_LOG(ERR, VHOST_CONFIG,=0A= > - "Unable to get vq numa information.\n");=0A= > - return dev;=0A= > + "Unable to get vring desc or dev numa information.\n");=0A= > + goto out;=0A= > }=0A= =0A= Why vring desc in the err message?=0A= -huawei=0A= [...]=0A=