From: Pooja Dhannawat <dhannawatpooja1@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
Date: Tue, 15 Mar 2016 21:29:58 +0530 [thread overview]
Message-ID: <1458057598-11041-1-git-send-email-dhannawatpooja1@gmail.com> (raw)
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..fd7f39f 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, 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
next reply other threads:[~2016-03-15 16:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 15:59 Pooja Dhannawat [this message]
2016-03-17 14:50 ` [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap Stefan Hajnoczi
2016-03-17 15:31 ` Pooja Dhannawat
2016-03-17 22:50 ` Paolo Bonzini
2016-03-18 9:35 ` Stefan Hajnoczi
2016-03-18 11:12 ` Pooja Dhannawat
2016-03-18 11:24 ` Pooja Dhannawat
2016-03-18 11:51 ` Paolo Bonzini
2016-03-18 13:27 ` Jaya Tiwari
2016-03-18 13:29 ` Jaya Tiwari
2016-03-18 13:49 ` Pooja Dhannawat
2016-03-18 15:14 ` Paolo Bonzini
2016-03-18 15:58 ` Pooja Dhannawat
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=1458057598-11041-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).