DPDK patches and discussions
 help / color / mirror / Atom feed
From: Huawei Xie <huawei.xie@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 1/2] vhost: use rte_malloc to allocate device and queues
Date: Fri, 19 Jun 2015 00:59:55 +0800	[thread overview]
Message-ID: <1434646796-23101-2-git-send-email-huawei.xie@intel.com> (raw)
In-Reply-To: <1434646796-23101-1-git-send-email-huawei.xie@intel.com>

use rte_malloc to allocate vhost device and queues

Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
 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 <rte_log.h>
 #include <rte_string_fns.h>
 #include <rte_memory.h>
+#include <rte_malloc.h>
 #include <rte_virtio_net.h>
 
 #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

  reply	other threads:[~2015-06-18 17:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28  2:04 [dpdk-dev] [PATCH RFC 0/2] vhost: numa aware allocation of virtio_net device and vhost virt queue Huawei Xie
2015-05-28  2:04 ` [dpdk-dev] [PATCH RFC 1/2] vhost: malloc -> rte_malloc for virtio_net and virt queue allocation Huawei Xie
2015-05-28  2:04 ` [dpdk-dev] [PATCH RFC 2/2] vhost: realloc virtio_net and virtqueue to the same node of vring desc table Huawei Xie
2015-06-03 23:38 ` [dpdk-dev] [PATCH RFC 0/2] vhost: numa aware allocation of virtio_net device and vhost virt queue Long, Thomas
2015-06-05  3:13 ` [dpdk-dev] [PATCH " Huawei Xie
2015-06-05  3:13   ` [dpdk-dev] [PATCH 1/2] vhost: malloc -> rte_malloc for virtio_net and virt queue allocation Huawei Xie
2015-06-17 17:06     ` Thomas Monjalon
2015-06-05  3:13   ` [dpdk-dev] [PATCH 2/2] vhost: realloc virtio_net and virtqueue to the same node of vring desc table Huawei Xie
2015-06-17 16:47     ` Thomas Monjalon
2015-06-17 17:02       ` Thomas Monjalon
2015-06-09  4:05   ` [dpdk-dev] [PATCH 0/2] vhost: numa aware allocation of virtio_net device and vhost virt queue Long, Thomas
2015-06-18 16:59   ` [dpdk-dev] [PATCH v2 0/2] vhost: numa aware allocation of vhost device and queues Huawei Xie
2015-06-18 16:59     ` Huawei Xie [this message]
2015-06-18 16:59     ` [dpdk-dev] [PATCH v2 2/2] vhost: realloc vhost device and queues to the same numa node of vring desc table Huawei Xie
2015-06-25  5:47     ` [dpdk-dev] [PATCH v3 0/2] vhost: numa aware allocation of vhost device and queues Huawei Xie
2015-06-25  5:47       ` [dpdk-dev] [PATCH v3 1/2] vhost: use rte_malloc to allocate " Huawei Xie
2015-06-25  5:47       ` [dpdk-dev] [PATCH v3 2/2] vhost: realloc vhost device and queues to the same numa node of vring desc table Huawei Xie
2015-06-29 17:04       ` [dpdk-dev] [PATCH v3 0/2] vhost: numa aware allocation of vhost device and queues Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434646796-23101-2-git-send-email-huawei.xie@intel.com \
    --to=huawei.xie@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).