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 1A7C1A0562; Thu, 2 Apr 2020 05:01:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 056461BE96; Thu, 2 Apr 2020 05:01:18 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 6D9CE1BE91 for ; Thu, 2 Apr 2020 05:01:16 +0200 (CEST) IronPort-SDR: YjSVwLYJNLlyNYhhyq7rOvwRhbnRA58BXcSdbq/IWmc1WB/v5Q9xNSXM2NxnJY7sQvg35PpdIZ X+OUjqqxG4TQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 01 Apr 2020 20:01:15 -0700 IronPort-SDR: HBfBXlI1X7kcZu1RWXbXdA5OFfWgadpOTJfAtqwFt46GhqbQsZImkGYzEPv2yXC+nAy+kfrSpa dBxNFpBAfABQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,334,1580803200"; d="scan'208";a="295517008" Received: from yexl-server.sh.intel.com (HELO localhost) ([10.67.117.17]) by FMSMGA003.fm.intel.com with ESMTP; 01 Apr 2020 20:01:14 -0700 Date: Thu, 2 Apr 2020 10:57:45 +0800 From: Ye Xiaolong To: Marvin Liu Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org Message-ID: <20200402025745.GA46004@intel.com> References: <20200316153353.112897-1-yong.liu@intel.com> <20200401145011.67357-1-yong.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401145011.67357-1-yong.liu@intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) 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" On 04/01, Marvin Liu wrote: >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 = NULL; > } > >- free(dev->guest_pages); >+ rte_free(dev->guest_pages); > dev->guest_pages = NULL; > > 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 == dev->max_guest_pages) { > dev->max_guest_pages *= 2; > old_pages = dev->guest_pages; >- dev->guest_pages = realloc(dev->guest_pages, >- dev->max_guest_pages * sizeof(*page)); >- if (!dev->guest_pages) { >+ dev->guest_pages = rte_realloc(dev->guest_pages, >+ dev->max_guest_pages * sizeof(*page), >+ RTE_CACHE_LINE_SIZE); >+ if (dev->guest_pages == 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]); > > dev->nr_guest_pages = 0; >- if (!dev->guest_pages) { >+ if (dev->guest_pages == NULL) { > dev->max_guest_pages = 8; >- dev->guest_pages = malloc(dev->max_guest_pages * >- sizeof(struct guest_page)); >+ dev->guest_pages = rte_zmalloc(NULL, >+ dev->max_guest_pages * >+ sizeof(struct guest_page), >+ RTE_CACHE_LINE_SIZE); > if (dev->guest_pages == NULL) { > VHOST_LOG_CONFIG(ERR, > "(%d) failed to allocate memory " >-- >2.17.1 > Reviewed-by: Xiaolong Ye