From patchwork Wed Apr 1 14:50:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Liu X-Patchwork-Id: 67564 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7FDBFA057B; Wed, 1 Apr 2020 09:14:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D711C1BEA3; Wed, 1 Apr 2020 09:14:17 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id C30A51BE96 for ; Wed, 1 Apr 2020 09:14:15 +0200 (CEST) IronPort-SDR: fWg01IKwhrbB6CtUvaAAfiZ5qTQxVte1s1PWCU9JtZuspP0YPHpxjTkwvwSSZ9pWModg3F0P/s MfLlitKCVenQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 00:14:15 -0700 IronPort-SDR: MbcHXZdLQDmL8vGF9r2swM9fq3DMruplba14jUfTJkOQOwua2/djbqGksf2Al2vhVJowjhE4/W gzoUP5Y2FiTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,330,1580803200"; d="scan'208";a="252508284" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.58]) by orsmga006.jf.intel.com with ESMTP; 01 Apr 2020 00:14:12 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, xiaolong.ye@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu Date: Wed, 1 Apr 2020 22:50:10 +0800 Message-Id: <20200401145011.67357-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200316153353.112897-1-yong.liu@intel.com> References: <20200316153353.112897-1-yong.liu@intel.com> Subject: [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" Replace dynamic memory allocator with dpdk memory allocator. Signed-off-by: Marvin Liu Reviewed-by: Gavin Hu Reviewed-by: Xiaolong Ye Tested-by: ma,lihong Signed-off-by: Marvin Liu Reviewed-by: Maxime Coquelin 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 "