From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2ED505A56 for ; Thu, 28 May 2015 04:04:34 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 27 May 2015 19:04:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,509,1427785200"; d="scan'208";a="701336554" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 27 May 2015 19:04:30 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t4S24T7j001867; Thu, 28 May 2015 10:04:29 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t4S24Qia025470; Thu, 28 May 2015 10:04:28 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t4S24QwW025466; Thu, 28 May 2015 10:04:26 +0800 From: Huawei Xie To: dev@dpdk.org Date: Thu, 28 May 2015 10:04:20 +0800 Message-Id: <1432778661-25428-2-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1432778661-25428-1-git-send-email-huawei.xie@intel.com> References: <1432778661-25428-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH RFC 1/2] vhost: malloc -> rte_malloc for virtio_net and virt queue allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2015 02:04:34 -0000 use rte_malloc/free for virtio_net and virt queue allocation/free Signed-off-by: Huawei Xie --- lib/librte_vhost/virtio-net.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 4672e67..19b74d6 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include "vhost-net.h" @@ -202,9 +203,9 @@ static void free_device(struct virtio_net_config_ll *ll_dev) { /* Free any malloc'd memory */ - free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); - free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); - free(ll_dev); + rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); + rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); + rte_free(ll_dev); } /* @@ -278,7 +279,7 @@ new_device(struct vhost_device_ctx ctx) struct vhost_virtqueue *virtqueue_rx, *virtqueue_tx; /* Setup device and virtqueues. */ - new_ll_dev = malloc(sizeof(struct virtio_net_config_ll)); + new_ll_dev = rte_malloc(NULL, sizeof(struct virtio_net_config_ll), 0); if (new_ll_dev == NULL) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for dev.\n", @@ -286,19 +287,19 @@ new_device(struct vhost_device_ctx ctx) return -1; } - virtqueue_rx = malloc(sizeof(struct vhost_virtqueue)); + virtqueue_rx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); if (virtqueue_rx == NULL) { - free(new_ll_dev); + rte_free(new_ll_dev); RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for rxq.\n", ctx.fh); return -1; } - virtqueue_tx = malloc(sizeof(struct vhost_virtqueue)); + virtqueue_tx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); if (virtqueue_tx == NULL) { - free(virtqueue_rx); - free(new_ll_dev); + rte_free(virtqueue_rx); + rte_free(new_ll_dev); RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for txq.\n", ctx.fh); -- 1.8.1.4