From patchwork Mon Jan 11 07:40:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Rozenfeld X-Patchwork-Id: 42590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 14CD2B7C38 for ; Mon, 11 Jan 2010 18:44:21 +1100 (EST) Received: from localhost ([127.0.0.1]:56232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUEv7-0003Ne-SV for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2010 02:42:37 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUEtk-0003NQ-57 for qemu-devel@nongnu.org; Mon, 11 Jan 2010 02:41:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUEtf-0003MM-4n for qemu-devel@nongnu.org; Mon, 11 Jan 2010 02:41:11 -0500 Received: from [199.232.76.173] (port=38879 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUEte-0003MH-Tj for qemu-devel@nongnu.org; Mon, 11 Jan 2010 02:41:06 -0500 Received: from mx20.gnu.org ([199.232.41.8]:52255) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NUEte-0005z1-I5 for qemu-devel@nongnu.org; Mon, 11 Jan 2010 02:41:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUEtc-0000Gr-Vd for qemu-devel@nongnu.org; Mon, 11 Jan 2010 02:41:05 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0B7f2sH019945 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Jan 2010 02:41:03 -0500 Received: from [10.35.6.46] (vpn-6-46.tlv.redhat.com [10.35.6.46]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0B7f0KL016544; Mon, 11 Jan 2010 02:41:01 -0500 From: Vadim Rozenfeld To: qemu-devel Date: Mon, 11 Jan 2010 09:40:47 +0200 Message-Id: <1263195647.2005.44.camel@localhost> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Dor Laor , Avi Kivity Subject: [Qemu-devel] [RFC][PATCH] performance improvement for windows guests, running on top of virtio block device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The following patch allows us to improve Windows virtio block driver performance on small size requests. Additionally, it leads to reducing of cpu usage on write IOs repository: /home/vadimr/work/win7/qemu branch: master commit 68290c4e9c96f345d544ca5d2b89f27a1e67e27a Author: Vadim Rozenfeld Date: Mon Jan 11 09:00:21 2010 +0200 [RFC][PATCH] small IOs performance for windows guests, running on top of virtio block device VirtIOBlock *s = req->dev; @@ -95,6 +98,11 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in)); virtio_notify(&s->vdev, s->vq); + if(--s->pending == 0) { + virtio_queue_set_notification(s->vq, 1); + virtio_blk_handle_output(&s->vdev, s->vq); + } + qemu_free(req); } @@ -340,6 +348,9 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) exit(1); } + if(++s->pending == 1) + virtio_queue_set_notification(s->vq, 0); + req->out = (void *)req->elem.out_sg[0].iov_base; req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base; diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index a2f0639..0e3a8d5 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -28,6 +28,7 @@ typedef struct VirtIOBlock char serial_str[BLOCK_SERIAL_STRLEN + 1]; QEMUBH *bh; size_t config_size; + unsigned int pending; } VirtIOBlock; static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev) @@ -87,6 +88,8 @@ typedef struct VirtIOBlockReq struct VirtIOBlockReq *next; } VirtIOBlockReq; +static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq); + static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) {