[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH] Reducing stack frame size in stream_process_mem2s
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-arm] [PATCH] Reducing stack frame size in stream_process_mem2s() |
Date: |
Mon, 3 Oct 2016 22:39:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 03/10/2016 18:56, address@hidden wrote:
> From: Rutuja Shah <address@hidden>
>
> This patch allocates memory for txbuf array on the heap rather than the stack.
> As a result, the stack frame size is reduced.
>
> Signed-off-by: Rutuja Shah <address@hidden>
> ---
> hw/dma/xilinx_axidma.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
> index b135a5f..6c63575 100644
> --- a/hw/dma/xilinx_axidma.c
> +++ b/hw/dma/xilinx_axidma.c
> @@ -256,13 +256,14 @@ static void stream_process_mem2s(struct Stream *s,
> StreamSlave *tx_data_dev,
> StreamSlave *tx_control_dev)
> {
> uint32_t prev_d;
> - unsigned char txbuf[16 * 1024];
> + unsigned char *txbuf;
> unsigned int txlen;
>
> if (!stream_running(s) || stream_idle(s)) {
> return;
> }
>
> + txbuf = g_malloc(16 * 1024);
Hello, please place the allocated buffer in struct Stream (see
xilinx_axidma_realize) instead. This function is a hot path, and it's
better to keep allocations outside it.
Thanks,
Paolo
> while (1) {
> stream_desc_load(s, s->regs[R_CURDESC]);
>
> @@ -304,6 +305,7 @@ static void stream_process_mem2s(struct Stream *s,
> StreamSlave *tx_data_dev,
> break;
> }
> }
> + g_free(txbuf);
> }
>
> static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
>