From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agsWe-0007DJ-06 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 07:25:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agsWa-0007C8-2E for qemu-devel@nongnu.org; Fri, 18 Mar 2016 07:25:03 -0400 Received: from mail-ig0-x242.google.com ([2607:f8b0:4001:c05::242]:34753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agsWZ-0007Bz-RB for qemu-devel@nongnu.org; Fri, 18 Mar 2016 07:24:59 -0400 Received: by mail-ig0-x242.google.com with SMTP id av4so2894850igc.1 for ; Fri, 18 Mar 2016 04:24:59 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <56EB34A7.9030601@redhat.com> References: <1458057598-11041-1-git-send-email-dhannawatpooja1@gmail.com> <20160317145025.GN14062@stefanha-x1.localdomain> <56EB34A7.9030601@redhat.com> Date: Fri, 18 Mar 2016 16:54:59 +0530 Message-ID: From: Pooja Dhannawat Content-Type: multipart/alternative; boundary=001a1133723651ede2052e50ff1b Subject: Re: [Qemu-devel] [PATCH v4] socket: Allocating Large sized arrays to heap List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Stefan Hajnoczi , qemu-devel@nongnu.org --001a1133723651ede2052e50ff1b Content-Type: text/plain; charset=UTF-8 On Fri, Mar 18, 2016 at 4:20 AM, Paolo Bonzini wrote: > > > On 17/03/2016 16:31, Pooja Dhannawat wrote: > > > > > > On Thu, Mar 17, 2016 at 8:20 PM, Stefan Hajnoczi > > 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 no, Can you please help me with this one? > Paolo > --001a1133723651ede2052e50ff1b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Fri, Mar 18, 2016 at 4:20 AM, Paolo Bonzini <pbonzini@redhat.com<= /a>> 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>> wrote:
>
>=C2=A0 =C2=A0 =C2=A0On Tue, Mar 15, 2016 at 09:29:58PM +0530, Pooja Dha= nnawat wrote:
>=C2=A0 =C2=A0 =C2=A0> @@ -170,8 +170,8 @@ static void net_socket_sen= d(void *opaque)
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->index = =3D 0;
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->packet= _len =3D 0;
>=C2=A0 =C2=A0 =C2=A0>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 s->nc.lin= k_down =3D true;
>=C2=A0 =C2=A0 =C2=A0> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(s->buf,= 0, sizeof(s->buf));
>
>=C2=A0 =C2=A0 =C2=A0This change is unrelated to allocating buf1 on the = heap.=C2=A0 What is the
>=C2=A0 =C2=A0 =C2=A0purpose 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.=C2=A0 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 i= f it is greater than accepted level, then only keep on heap?
If n= o, Can you please help me with this one?
Paolo

--001a1133723651ede2052e50ff1b--