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 93DBFA0562; Fri, 3 Apr 2020 10:22:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C7D41C0D4; Fri, 3 Apr 2020 10:22:09 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 84DA11C0D1 for ; Fri, 3 Apr 2020 10:22:07 +0200 (CEST) IronPort-SDR: tc3dn4i2A00ht1WGLtojwqe1dJPKFBVO9MHYHYbl8dhv1Xru7ea1lvvDFH+T4PWsdHLqHTCF4L YQ5cU48uqZ6A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 01:22:06 -0700 IronPort-SDR: +iAxtJcanwuiIsVpe0wdQIs+UJEQZSrMXjVQN82TyxPutTugEDNJvgTv1fnumvGJ34qFNgHetL Wwj8fN9sHKZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="scan'208";a="242751642" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 03 Apr 2020 01:22:06 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 3 Apr 2020 01:22:05 -0700 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by SHSMSX601.ccr.corp.intel.com (10.109.6.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 3 Apr 2020 16:22:03 +0800 Received: from shsmsx603.ccr.corp.intel.com ([10.109.6.143]) by SHSMSX603.ccr.corp.intel.com ([10.109.6.143]) with mapi id 15.01.1713.004; Fri, 3 Apr 2020 16:22:03 +0800 From: "Ma, LihongX" To: "Liu, Yong" , "maxime.coquelin@redhat.com" , "Ye, Xiaolong" , "Wang, Zhihong" CC: "dev@dpdk.org" , "Liu, Yong" Thread-Topic: [dpdk-dev] [PATCH v2 1/2] vhost: utilize dpdk dynamic memory allocator Thread-Index: AQHWB/U2ubatomFp/0+u01I686jX7KhlIhhA Date: Fri, 3 Apr 2020 08:22:03 +0000 Message-ID: <68f8230dfe2643b3856cbe17f10c478b@intel.com> References: <20200316153353.112897-1-yong.liu@intel.com> <20200401145011.67357-1-yong.liu@intel.com> In-Reply-To: <20200401145011.67357-1-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/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" Tested-by: ma,lihong Regards, Ma,lihong -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Marvin Liu Sent: Wednesday, April 1, 2020 10:50 PM To: maxime.coquelin@redhat.com; Ye, Xiaolong ; Wang,= Zhihong Cc: dev@dpdk.org; Liu, Yong Subject: [dpdk-dev] [PATCH v2 1/2] vhost: utilize dpdk dynamic memory alloc= ator Replace dynamic memory allocator with dpdk memory allocator. Signed-off-by: Marvin Liu 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 g= uest_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