From patchwork Tue Dec 19 13:33:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sochin jiang X-Patchwork-Id: 10123269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 823C06019C for ; Tue, 19 Dec 2017 13:35:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75D03286F9 for ; Tue, 19 Dec 2017 13:35:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A70C28AAB; Tue, 19 Dec 2017 13:35:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7FFE286F9 for ; Tue, 19 Dec 2017 13:35:49 +0000 (UTC) Received: from localhost ([::1]:44736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRI3g-00076X-EY for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Dec 2017 08:35:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRI1l-0005gs-Fj for qemu-devel@nongnu.org; Tue, 19 Dec 2017 08:33:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRI1k-0003EK-HV for qemu-devel@nongnu.org; Tue, 19 Dec 2017 08:33:49 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2055 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eRI1g-00039l-9q; Tue, 19 Dec 2017 08:33:44 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2A7E3B7177976; Tue, 19 Dec 2017 21:33:27 +0800 (CST) Received: from localhost.localdomain (10.175.104.228) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Tue, 19 Dec 2017 21:33:23 +0800 From: sochin.jiang To: , , Date: Tue, 19 Dec 2017 21:33:03 +0800 Message-ID: <1513690383-27269-1-git-send-email-sochin.jiang@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.228] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH] virtio-blk: notify guest directly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sochin.jiang@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, eric.fangyi@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "sochin.jiang" Till now, we've already notify guest as a batch mostly, an extra BH won't decrease guest interrupts much, but cause a significant notification loss. Generally, we could have 15% or so performance lost in single queue IO models, as I tested. Signed-off-by: sochin.jiang --- hw/block/dataplane/virtio-blk.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 5556f0e..a261a1d 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -32,7 +32,6 @@ struct VirtIOBlockDataPlane { VirtIOBlkConf *conf; VirtIODevice *vdev; - QEMUBH *bh; /* bh for guest notification */ unsigned long *batch_notify_vqs; /* Note that these EventNotifiers are assigned by value. This is @@ -44,14 +43,7 @@ struct VirtIOBlockDataPlane { AioContext *ctx; }; -/* Raise an interrupt to signal guest, if necessary */ -void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq) -{ - set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); - qemu_bh_schedule(s->bh); -} - -static void notify_guest_bh(void *opaque) +static void notify_guest(void *opaque) { VirtIOBlockDataPlane *s = opaque; unsigned nvqs = s->conf->num_queues; @@ -75,7 +67,12 @@ static void notify_guest_bh(void *opaque) } } -/* Context: QEMU global mutex held */ +/* Raise an interrupt to signal guest, if necessary */ +void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq) +{ + set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); + notify_guest(s); +} void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, VirtIOBlockDataPlane **dataplane, Error **errp) @@ -122,7 +119,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *conf, } else { s->ctx = qemu_get_aio_context(); } - s->bh = aio_bh_new(s->ctx, notify_guest_bh, s); s->batch_notify_vqs = bitmap_new(conf->num_queues); *dataplane = s; @@ -140,7 +136,6 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s) vblk = VIRTIO_BLK(s->vdev); assert(!vblk->dataplane_started); g_free(s->batch_notify_vqs); - qemu_bh_delete(s->bh); if (s->iothread) { object_unref(OBJECT(s->iothread)); }