Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E851C433FE for ; Thu, 13 Oct 2022 20:37:56 +0000 (UTC) Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj4xl-0006SN-RV for qemu-devel@archiver.kernel.org; Thu, 13 Oct 2022 16:37:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj4t1-0001PX-LL; Thu, 13 Oct 2022 16:32:59 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]:42520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj4sz-00025e-8o; Thu, 13 Oct 2022 16:32:59 -0400 Received: from dev006.ch-qa.sw.ru ([172.29.1.11]) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1oj4pq-00Bba4-VA; Thu, 13 Oct 2022 22:32:33 +0200 To: stefanha@redhat.com Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com, mst@redhat.com, den@virtuozzo.com, andrey.drobyshev@virtuozzo.com Subject: [RFC PATCH v2 0/1] block: vhost-blk backend Date: Thu, 13 Oct 2022 23:31:29 +0300 Message-Id: <20221013203130.690327-1-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.zhadchenko@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Andrey Zhadchenko From: Andrey Zhadchenko via Sending second version of this patchset as @stefanha requested. The main difference from the previous version is added vhost multithreading support. Also I must note currently there are several problems which I intend to reconsider/fix later: - vmsd is present but migration is not supported - BlockConf is used but block layer is actually bypassed - posix BlockDriver internal state guessing --- Although QEMU virtio-blk is quite fast, there is still some room for improvements. Disk latency can be reduced if we handle virito-blk requests in host kernel so we avoid a lot of syscalls and context switches. The biggest disadvantage of this vhost-blk flavor is raw format. Luckily Kirill Thai proposed device mapper driver for QCOW2 format to attach files as block devices: https://www.spinics.net/lists/kernel/msg4292965.html Also by using kernel modules we can bypass iothread limitation and finaly scale block requests with cpus for high-performance devices. This is planned to be implemented in next version. Linux kernel module part: v2: https://lore.kernel.org/kvm/20221013151839.689700-1-andrey.zhadchenko@virtuozzo.com/ test setups and results: fio --direct=1 --rw=randread --bs=4k --ioengine=libaio --iodepth=128 QEMU options: cache=none, iothread, aio=threads filesystem: xfs SSD: | randread, IOPS | randwrite, IOPS | Host | 95.8k | 85.3k | QEMU virtio | 61.5k | 79.9k | QEMU vhost-blk | 95.6k | 84.3k | RAMDISK (vq == vcpu == numjobs): | randread, IOPS | randwrite, IOPS | virtio, 1vcpu | 133k | 133k | virtio, 2vcpu | 305k | 306k | virtio, 4vcpu | 310k | 298k | virtio, 8vcpu | 271k | 252k | vhost-blk, 1vcpu | 110k | 113k | vhost-blk, 2vcpu | 247k | 252k | vhost-blk, 4vcpu | 558k | 556k | vhost-blk, 8vcpu | 576k | 575k | *single kernel thread vhost-blk, 8vcpu | 803k | 779k | *two kernel threads Andrey Zhadchenko (1): block: add vhost-blk backend hw/block/Kconfig | 5 + hw/block/meson.build | 4 + hw/block/vhost-blk.c | 403 ++++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 3 + hw/virtio/vhost-blk-pci.c | 102 +++++++++ include/hw/virtio/vhost-blk.h | 52 +++++ meson.build | 6 + meson_options.txt | 2 + scripts/meson-buildoptions.sh | 3 + 9 files changed, 580 insertions(+) create mode 100644 hw/block/vhost-blk.c create mode 100644 hw/virtio/vhost-blk-pci.c create mode 100644 include/hw/virtio/vhost-blk.h -- 2.31.1