From: Zhou Jie <zhoujie2011@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, jcmvbkbc@gmail.com,
Zhou Jie <zhoujie2011@cn.fujitsu.com>
Subject: [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap
Date: Tue, 26 Apr 2016 11:35:13 +0800 [thread overview]
Message-ID: <1461641713-32720-1-git-send-email-zhoujie2011@cn.fujitsu.com> (raw)
open_eth_start_xmit has a huge stack usage of 65536 bytes approx.
Moving large arrays to heap to reduce stack usage.
Signed-off-by: Zhou Jie <zhoujie2011@cn.fujitsu.com>
---
hw/net/opencores_eth.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
index c6094fb..ba23922 100644
--- a/hw/net/opencores_eth.c
+++ b/hw/net/opencores_eth.c
@@ -483,7 +483,7 @@ static NetClientInfo net_open_eth_info = {
static void open_eth_start_xmit(OpenEthState *s, desc *tx)
{
- uint8_t buf[65536];
+ uint8_t *buf = NULL;
unsigned len = GET_FIELD(tx->len_flags, TXD_LEN);
unsigned tx_len = len;
@@ -498,6 +498,7 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
trace_open_eth_start_xmit(tx->buf_ptr, len, tx_len);
+ buf = g_new(uint8_t, tx_len);
if (len > tx_len) {
len = tx_len;
}
@@ -506,6 +507,7 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
memset(buf + len, 0, tx_len - len);
}
qemu_send_packet(qemu_get_queue(s->nic), buf, tx_len);
+ g_free(buf);
if (tx->len_flags & TXD_WR) {
s->tx_desc = 0;
--
2.5.5
next reply other threads:[~2016-04-26 3:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 3:35 Zhou Jie [this message]
2016-04-26 4:12 ` [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap Max Filippov
2016-04-27 1:03 ` Zhou Jie
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=1461641713-32720-1-git-send-email-zhoujie2011@cn.fujitsu.com \
--to=zhoujie2011@cn.fujitsu.com \
--cc=jcmvbkbc@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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).