qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Pooja Dhannawat <dhannawatpooja1@gmail.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap
Date: Fri, 18 Mar 2016 12:51:11 +0100	[thread overview]
Message-ID: <56EBEBAF.2090108@redhat.com> (raw)
In-Reply-To: <CAPAwAwiYfsynruAvWuJhiWgdGO8YaG_i6HEfM1w89uezK4Q8WQ@mail.gmail.com>



On 18/03/2016 12:24, Pooja Dhannawat wrote:
> 
> 
> On Fri, Mar 18, 2016 at 4:20 AM, Paolo Bonzini <pbonzini@redhat.com
> <mailto:pbonzini@redhat.com>> wrote:
> 
> 
> 
>     On 17/03/2016 16:31, Pooja Dhannawat wrote:
>     >
>     >
>     > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi <stefanha@gmail.com <mailto:stefanha@gmail.com>
>     > <mailto:stefanha@gmail.com <mailto:stefanha@gmail.com>>> wrote:
>     >
>     >     On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dhannawat wrote:
>     >     > @@ -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));
>     >
>     >     This change is unrelated to allocating buf1 on the heap.  What is the
>     >     purpose of this line?
>     >
>     >
>     > I moved buf from stack to Heap, used g_new(), but I got your point if we
>     > need to initialize it with 0 then I have to keep that one.
>     >
>     > Other wise doing so it gets whatever garbage it has already.
> 
>     This is s->buf, not buf.  Also, the BiteSizedTasks page says "Make the
>     stack array smaller and allocate on the heap in the rare case that the
>     data does not fit in the small array".
> 
> So here, should I check with stack consumption(size of array) and if it
> is greater than accepted level, then only keep on heap?

If it is greater than the accepted level, the on-stack buffer is not
used and you allocate one that has the right size on the heap.

Paolo

> If no, Can you please help me with this one?
> 
>     Paolo
> 
> 

  reply	other threads:[~2016-03-18 11:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 15:59 [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap Pooja Dhannawat
2016-03-17 14:50 ` 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 [this message]
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=56EBEBAF.2090108@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dhannawatpooja1@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).