Received: from [140.186.70.92] (port=33242 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OF5Ww-0000f1-8g for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OF5Wm-00071R-TR for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47264) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OF5Wm-000712-M5 for qemu-devel@nongnu.org; Thu, 20 May 2010 09:11:08 -0400 From: Kevin Wolf Date: Thu, 20 May 2010 15:10:37 +0200 Message-Id: <1274361043-25862-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1274361043-25862-1-git-send-email-kwolf@redhat.com> References: <1274361043-25862-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 2/8] virtio-blk: Avoid zeroing every request structure List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi The VirtIOBlockRequest structure is about 40 KB in size. This patch avoids zeroing every request by only initializing fields that are read. The other fields are either written to or may not be used at all. Oprofile shows about 10% of CPU samples in memset called by virtio_blk_alloc_request(). The workload is dd if=/dev/vda of=/dev/null iflag=direct bs=8k running concurrently 4 times. This patch makes memset disappear to the bottom of the profile. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- hw/virtio-blk.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) 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) static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s) { - VirtIOBlockReq *req = qemu_mallocz(sizeof(*req)); + VirtIOBlockReq *req = qemu_malloc(sizeof(*req)); req->dev = s; + req->qiov.size = 0; + req->next = NULL; return req; } -- 1.6.6.1