From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36258 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ODfLG-00016y-49 for qemu-devel@nongnu.org; Sun, 16 May 2010 11:01:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ODfLE-0005kO-KH for qemu-devel@nongnu.org; Sun, 16 May 2010 11:01:21 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:37722) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ODfLE-0005kD-HO for qemu-devel@nongnu.org; Sun, 16 May 2010 11:01:20 -0400 Received: by vws1 with SMTP id 1so307526vws.4 for ; Sun, 16 May 2010 08:01:19 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20100516132557.GB26872@lst.de> References: <1273873950-25756-1-git-send-email-stefanha@linux.vnet.ibm.com> <20100516132557.GB26872@lst.de> Date: Sun, 16 May 2010 16:01:19 +0100 Message-ID: Subject: Re: [Qemu-devel] [PATCH] virtio-blk: Avoid zeroing every request structure From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On Sun, May 16, 2010 at 2:25 PM, Christoph Hellwig wrote: > On Fri, May 14, 2010 at 10:52:30PM +0100, Stefan Hajnoczi wrote: >> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c >> index b05d15e..d270225 100644 >> --- a/hw/virtio-blk.c >> +++ b/hw/virtio-blk.c >> @@ -105,8 +105,10 @@ static void virtio_blk_flush_complete(void *opaque,= int ret) >> >> =A0static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s) >> =A0{ >> - =A0 =A0VirtIOBlockReq *req =3D qemu_mallocz(sizeof(*req)); >> + =A0 =A0VirtIOBlockReq *req =3D qemu_malloc(sizeof(*req)); >> =A0 =A0 =A0req->dev =3D s; >> + =A0 =A0req->qiov.size =3D 0; >> + =A0 =A0req->next =3D NULL; >> =A0 =A0 =A0return req; > > Looks good, but you shouldn't even need to initialize req->qiov.size, we > do this later by calling qemu_iovec_init_external before using it. virtio_blk_req_complete() uses req->qiov.size and may be called by virtio_blk_handle_flush() or virtio_blk_handle_scsi() without being initialized. It's a little ugly that we use the qiov like that. Stefan