qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Pooja Dhannawat <dhannawatpooja1@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/1] socket: Allocating Large sized arrays to heap
Date: Mon, 14 Mar 2016 16:50:32 +0000	[thread overview]
Message-ID: <20160314165032.GJ21198@redhat.com> (raw)
In-Reply-To: <1457973473-21791-1-git-send-email-dhannawatpooja1@gmail.com>

On Mon, Mar 14, 2016 at 10:07:53PM +0530, Pooja Dhannawat wrote:
> 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..3fcd7a6 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);

You're allocating NET_BUFSIZE worth of uint8_t's

>      const uint8_t *buf;
>  
> -    size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
> +    size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0);

But only reading 1 byte which is clearly wrong. You likely wanted
NET_BUFSIZE here, not sizeof(uint8_t)

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2016-03-14 16:50 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 [this message]
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 ` [Qemu-devel] [PATCH v3] " 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=20160314165032.GJ21198@redhat.com \
    --to=berrange@redhat.com \
    --cc=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).