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 64BB4A00BE; Wed, 29 Apr 2020 03:01:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6910E1D6AE; Wed, 29 Apr 2020 03:01:13 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id AF4D31D6A5 for ; Wed, 29 Apr 2020 03:01:10 +0200 (CEST) IronPort-SDR: KZZu0M4sfmseydHZPWoR2Bxi0bvEUo0gaKI4Zpl6+KTlAUHDlyJU8CoQ1vT7K9jo+C/VmtyRCo PzyhkskzujoQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 18:01:09 -0700 IronPort-SDR: sr9HrElP0jnTIFaxwdgxceJ7mBpSveXAvKfcRFP9VtJ0BAxMRLgk5Gi+8SLyPgXr1f5bBpG0AW ceLWu5uRMt7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,329,1583222400"; d="scan'208";a="282336201" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.56]) by fmsmga004.fm.intel.com with ESMTP; 28 Apr 2020 18:01:08 -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, 29 Apr 2020 09:00:58 +0800 Message-Id: <20200429010100.22003-2-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429010100.22003-1-yong.liu@intel.com> References: <20200316153353.112897-1-yong.liu@intel.com> <20200429010100.22003-1-yong.liu@intel.com> Subject: [dpdk-dev] [PATCH v4 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 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