From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C38D0A00BE; Wed, 29 Apr 2020 03:06:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97D891D6B9; Wed, 29 Apr 2020 03:06:34 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id AE4AB1D6B7 for ; Wed, 29 Apr 2020 03:06:33 +0200 (CEST) IronPort-SDR: 0a8qDcrAxxbYDdazT0cfd7B2Dnhtm+BmnoUW0N6pp9LYXzTECYmDXoW+/+Jw1Z6CpOAZ2l1PNb pXhvGJQUUFmA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 18:06:32 -0700 IronPort-SDR: fBgISU4VqhdSzuwNwbQtzYG9AuXAxVyQJzR7X0vs4My2UtWLhX3dnJx4yUy+9niEdKW2PfwQmN AUqChB5R1eZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,329,1583222400"; d="scan'208";a="404877622" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 28 Apr 2020 18:06:32 -0700 Received: from fmsmsx163.amr.corp.intel.com (10.18.125.72) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 28 Apr 2020 18:06:32 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx163.amr.corp.intel.com (10.18.125.72) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 28 Apr 2020 18:06:31 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.146]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.213]) with mapi id 14.03.0439.000; Wed, 29 Apr 2020 09:06:29 +0800 From: "Liu, Yong" To: "maxime.coquelin@redhat.com" , "Ye, Xiaolong" , "Wang, Zhihong" CC: "dev@dpdk.org" Thread-Topic: [PATCH v4 2/2] vhost: utilize dpdk dynamic memory allocator Thread-Index: AQHWHcGykPLBBtPz60ScBPQYRlfAlKiPSUkQ Date: Wed, 29 Apr 2020 01:06:29 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E63548DEE@SHSMSX103.ccr.corp.intel.com> References: <20200316153353.112897-1-yong.liu@intel.com> <20200429010100.22003-1-yong.liu@intel.com> <20200429010100.22003-4-yong.liu@intel.com> In-Reply-To: <20200429010100.22003-4-yong.liu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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 v4 2/2] vhost: utilize dpdk dynamic memory allocator 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is sent by mistake, please ignore. > -----Original Message----- > From: Liu, Yong > Sent: Wednesday, April 29, 2020 9:01 AM > To: maxime.coquelin@redhat.com; Ye, Xiaolong ; > Wang, Zhihong > Cc: dev@dpdk.org; Liu, Yong > Subject: [PATCH v4 2/2] vhost: utilize dpdk dynamic memory allocator >=20 > Replace dynamic memory allocator with dpdk memory allocator. >=20 > Signed-off-by: Marvin Liu > Reviewed-by: Maxime Coquelin >=20 > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c > index bd1be0104..79fcb9d19 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -191,7 +191,7 @@ vhost_backend_cleanup(struct virtio_net *dev) > dev->mem =3D NULL; > } >=20 > - free(dev->guest_pages); > + rte_free(dev->guest_pages); > dev->guest_pages =3D NULL; >=20 > if (dev->log_addr) { > @@ -903,11 +903,12 @@ add_one_guest_page(struct virtio_net *dev, > uint64_t guest_phys_addr, > if (dev->nr_guest_pages =3D=3D dev->max_guest_pages) { > dev->max_guest_pages *=3D 2; > old_pages =3D dev->guest_pages; > - dev->guest_pages =3D realloc(dev->guest_pages, > - dev->max_guest_pages * > sizeof(*page)); > - if (!dev->guest_pages) { > + dev->guest_pages =3D rte_realloc(dev->guest_pages, > + dev->max_guest_pages * > sizeof(*page), > + RTE_CACHE_LINE_SIZE); > + if (dev->guest_pages =3D=3D NULL) { > VHOST_LOG_CONFIG(ERR, "cannot realloc > guest_pages\n"); > - free(old_pages); > + rte_free(old_pages); > return -1; > } > } > @@ -1062,10 +1063,12 @@ vhost_user_set_mem_table(struct virtio_net > **pdev, struct VhostUserMsg *msg, > vhost_user_iotlb_flush_all(dev->virtqueue[i]); >=20 > dev->nr_guest_pages =3D 0; > - if (!dev->guest_pages) { > + if (dev->guest_pages =3D=3D NULL) { > dev->max_guest_pages =3D 8; > - dev->guest_pages =3D malloc(dev->max_guest_pages * > - sizeof(struct guest_page)); > + dev->guest_pages =3D rte_zmalloc(NULL, > + dev->max_guest_pages * > + sizeof(struct guest_page), > + RTE_CACHE_LINE_SIZE); > if (dev->guest_pages =3D=3D NULL) { > VHOST_LOG_CONFIG(ERR, > "(%d) failed to allocate memory " > -- > 2.17.1