From: Pooja Dhannawat <dhannawatpooja1@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3] socket: Allocating Large sized arrays to heap
Date: Mon, 14 Mar 2016 23:22:33 +0530 [thread overview]
Message-ID: <1457977953-28278-1-git-send-email-dhannawatpooja1@gmail.com> (raw)
In-Reply-To: <1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com>
net_socket_send has a huge stack usage of 69712 bytes approx.
Moving large arrays to heap to reduce stack usage.
Signed-off-by: Pooja Dhannawat <dhannawatpooja1@gmail.com>
---
net/socket.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index e32e3cb..d7fa8ce 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -147,10 +147,10 @@ static void net_socket_send(void *opaque)
NetSocketState *s = opaque;
int size, err;
unsigned l;
- uint8_t buf1[NET_BUFSIZE];
+ uint8_t *buf1 = g_new(uint8_t, NET_BUFSIZE);
const uint8_t *buf;
- size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
+ size = qemu_recv(s->fd, (uint8_t *)buf1, NET_BUFSIZE, 0);
if (size < 0) {
err = socket_error();
if (err != EWOULDBLOCK)
@@ -170,8 +170,8 @@ static void net_socket_send(void *opaque)
s->index = 0;
s->packet_len = 0;
s->nc.link_down = true;
- memset(s->buf, 0, sizeof(s->buf));
memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
+ g_free(buf1);
return;
}
@@ -222,6 +222,8 @@ static void net_socket_send(void *opaque)
break;
}
}
+
+ g_free(buf1);
}
static void net_socket_send_dgram(void *opaque)
--
2.5.0
prev parent reply other threads:[~2016-03-14 17:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 3:28 [Qemu-devel] [Patch 1/1] net/socket: Allocating Large sized arrays to heap Pooja Dhannawat
2016-03-14 1:28 ` Li Zhijian
2016-03-14 16:37 ` [Qemu-devel] [PATCH v2 1/1] socket: " Pooja Dhannawat
2016-03-14 16:50 ` Daniel P. Berrange
2016-03-14 17:14 ` Pooja Dhannawat
2016-03-14 17:16 ` Daniel P. Berrange
2016-03-15 6:36 ` Markus Armbruster
2016-03-14 17:52 ` Pooja Dhannawat [this message]
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=1457977953-28278-1-git-send-email-dhannawatpooja1@gmail.com \
--to=dhannawatpooja1@gmail.com \
--cc=qemu-devel@nongnu.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).