From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkTkG-0004LT-Du for qemu-devel@nongnu.org; Fri, 09 Oct 2015 05:13:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkTkC-0003mQ-Hl for qemu-devel@nongnu.org; Fri, 09 Oct 2015 05:13:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkTkC-0003mM-Cd for qemu-devel@nongnu.org; Fri, 09 Oct 2015 05:13:40 -0400 From: Stefan Hajnoczi Date: Fri, 9 Oct 2015 10:13:24 +0100 Message-Id: <1444382007-20416-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1444382007-20416-1-git-send-email-stefanha@redhat.com> References: <1444382007-20416-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 2/5] virtio-blk: use blk_io_plug/unplug for Linux AIO batching List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi The raw-posix block driver implements Linux AIO batching so multiple requests can be submitted with a single io_submit(2) system call. Batching is currently only used by virtio-scsi and virtio-blk-data-plane. Enable batching for regular virtio-blk so the number of io_submit(2) system calls is reduced for workloads with queue depth > 1. In 4KB random read performance tests with queue depth 32, the CPU utilization on the host is reduced by 9.4%. The fio job is as follows: [global] bs=4k ioengine=libaio iodepth=32 direct=1 sync=0 time_based=1 runtime=30 clocksource=gettimeofday ramp_time=5 [job1] rw=randread filename=/dev/vdb size=4096M write_bw_log=fio write_iops_log=fio write_lat_log=fio log_avg_msec=1000 This benchmark was run on an raw image on LVM. The disk was an SSD drive and -drive cache=none,aio=native was used. Tested-by: Pradeep Surisetty Signed-off-by: Stefan Hajnoczi Reviewed-by: Fam Zheng --- hw/block/virtio-blk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f9301ae..76d27f9 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -600,6 +600,8 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) return; } + blk_io_plug(s->blk); + while ((req = virtio_blk_get_request(s))) { virtio_blk_handle_request(req, &mrb); } @@ -607,6 +609,8 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) if (mrb.num_reqs) { virtio_blk_submit_multireq(s->blk, &mrb); } + + blk_io_unplug(s->blk); } static void virtio_blk_dma_restart_bh(void *opaque) -- 2.4.3