From db3892c47ddeed292e79167f391b29e9b78757aa Mon Sep 17 00:00:00 2001 From: Jes Sorensen <Jes.Sorensen@redhat.com> Date: Thu, 10 Jun 2010 16:50:16 -0300 Subject: [PATCH 1/2] virtio-blk.c avoid zero every request structure RH-Author: Jes Sorensen <Jes.Sorensen@redhat.com> Message-id: <patch-9837-clone-for-rhel5-rhel56> Patchwork-id: 9840 O-Subject: [PATCH RHEL55 kvm-userspace-rhel5 1/1] virtio-blk.c avoid zero every request structure Bugzilla: 598042 RH-Acked-by: Glauber Costa <glommer@redhat.com> RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> From: Jes Sorensen <Jes.Sorensen@redhat.com> virtio-blk.c avoid zero every request structure Backport of patch from upstream patch from Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>. 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: Jes Sorensen <Jes.Sorensen@redhat.com> --- qemu/hw/virtio-blk.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/hw/virtio-blk.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qemu/hw/virtio-blk.c b/qemu/hw/virtio-blk.c index 7dd03cc..3e1ffd9 100644 --- a/qemu/hw/virtio-blk.c +++ b/qemu/hw/virtio-blk.c @@ -116,9 +116,13 @@ static void virtio_blk_flush_complete(void *opaque, int ret) static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s) { - VirtIOBlockReq *req = qemu_mallocz(sizeof(*req)); - if (req != NULL) + VirtIOBlockReq *req = qemu_malloc(sizeof(*req)); + if (req != NULL) { req->dev = s; + req->size = 0; + req->buffer = NULL; + req->next = NULL; + } return req; } -- 1.7.0.3