* [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap
@ 2016-04-26 3:35 Zhou Jie
2016-04-26 4:12 ` Max Filippov
0 siblings, 1 reply; 3+ messages in thread
From: Zhou Jie @ 2016-04-26 3:35 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, jcmvbkbc, Zhou Jie
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap
2016-04-26 3:35 [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap Zhou Jie
@ 2016-04-26 4:12 ` Max Filippov
2016-04-27 1:03 ` Zhou Jie
0 siblings, 1 reply; 3+ messages in thread
From: Max Filippov @ 2016-04-26 4:12 UTC (permalink / raw)
To: Zhou Jie; +Cc: qemu-devel, QEMU Trivial
Hi Zhou,
On Tue, Apr 26, 2016 at 6:35 AM, Zhou Jie <zhoujie2011@cn.fujitsu.com> wrote:
> open_eth_start_xmit has a huge stack usage of 65536 bytes approx.
> Moving large arrays to heap to reduce stack usage.
It's an exception, not the rule when full 65536 byte long buffer might be
needed. Can we do a little better change and not allocate and free this
buffer every time unconditionally, but instead make buf smaller (1536
bytes, maximal frame length when HUGEN bit is not set in MODER)
and only do allocation when that's not enough?
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap
2016-04-26 4:12 ` Max Filippov
@ 2016-04-27 1:03 ` Zhou Jie
0 siblings, 0 replies; 3+ messages in thread
From: Zhou Jie @ 2016-04-27 1:03 UTC (permalink / raw)
To: Max Filippov; +Cc: qemu-devel, QEMU Trivial
On 2016/4/26 12:12, Max Filippov wrote:
> Hi Zhou,
>
> On Tue, Apr 26, 2016 at 6:35 AM, Zhou Jie <zhoujie2011@cn.fujitsu.com> wrote:
>> open_eth_start_xmit has a huge stack usage of 65536 bytes approx.
>> Moving large arrays to heap to reduce stack usage.
>
> It's an exception, not the rule when full 65536 byte long buffer might be
> needed. Can we do a little better change and not allocate and free this
> buffer every time unconditionally, but instead make buf smaller (1536
> bytes, maximal frame length when HUGEN bit is not set in MODER)
> and only do allocation when that's not enough?
>
Thank you for your suggestion.
I will modify this patch.
Sincerely,
Zhou Jie
--
------------------------------------------------
周潔
Dept 1
No. 6 Wenzhu Road,
Nanjing, 210012, China
TEL:+86+25-86630566-8557
FUJITSU INTERNAL:7998-8557
E-Mail:zhoujie2011@cn.fujitsu.com
------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-27 1:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26 3:35 [Qemu-devel] [PATCH] hw/net/opencores_eth: Allocating Large sized arrays to heap Zhou Jie
2016-04-26 4:12 ` Max Filippov
2016-04-27 1:03 ` Zhou Jie
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).