From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF997C5DF62 for ; Tue, 5 Nov 2019 16:14:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A9839214B2 for ; Tue, 5 Nov 2019 16:14:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9839214B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS1TH-0007Dp-N1 for qemu-devel@archiver.kernel.org; Tue, 05 Nov 2019 11:14:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52831) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS1QN-0005YR-CS for qemu-devel@nongnu.org; Tue, 05 Nov 2019 11:11:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iS1QJ-0002vS-Ab for qemu-devel@nongnu.org; Tue, 05 Nov 2019 11:11:19 -0500 Received: from relay.sw.ru ([185.231.240.75]:43452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iS1QI-0002ov-9F; Tue, 05 Nov 2019 11:11:14 -0500 Received: from [10.94.4.71] (helo=dptest2.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iS1QA-0000Xh-2V; Tue, 05 Nov 2019 19:11:06 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v1 3/4] virtio: increase virtuqueue sizes in new machine types Date: Tue, 5 Nov 2019 19:11:04 +0300 Message-Id: <20191105161105.19016-4-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20191105161105.19016-1-dplotnikov@virtuozzo.com> References: <20191105161105.19016-1-dplotnikov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, stefanha@redhat.com, mreitz@redhat.com, den@virtuozzo.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Linux guests submit IO requests no longer than PAGE_SIZE * max_seg field reported by SCSI controler. Thus typical sequential read with 1 MB size results in the following pattern of the IO from the guest: 8,16 1 15754 2.766095122 2071 D R 2095104 + 1008 [dd] 8,16 1 15755 2.766108785 2071 D R 2096112 + 1008 [dd] 8,16 1 15756 2.766113486 2071 D R 2097120 + 32 [dd] 8,16 1 15757 2.767668961 0 C R 2095104 + 1008 [0] 8,16 1 15758 2.768534315 0 C R 2096112 + 1008 [0] 8,16 1 15759 2.768539782 0 C R 2097120 + 32 [0] The IO was generated by dd if=/dev/sda of=/dev/null bs=1024 iflag=direct This effectively means that on rotational disks we will observe 3 IOPS for each 2 MBs processed. This definitely negatively affects both guest and host IO performance. The cure is relatively simple - we should report lengthy scatter-gather ability of the SCSI controller. Fortunately the situation here is very good. VirtIO transport layer can accomodate 1024 items in one request while we are using only 128. This situation is present since almost very beginning. 2 items are dedicated for request metadata thus we should publish VIRTQUEUE_MAX_SIZE - 2 as max_seg. The following pattern is observed after the patch: 8,16 1 9921 2.662721340 2063 D R 2095104 + 1024 [dd] 8,16 1 9922 2.662737585 2063 D R 2096128 + 1024 [dd] 8,16 1 9923 2.665188167 0 C R 2095104 + 1024 [0] 8,16 1 9924 2.665198777 0 C R 2096128 + 1024 [0] which is much better. To fix this particular case, the patch adds new machine types with extended virtqueue sizes to 256 which also increases max_seg to 254 implicitly. Suggested-by: Denis V. Lunev Signed-off-by: Denis Plotnikov --- hw/core/machine.c | 14 ++++++++++++++ hw/i386/pc_piix.c | 16 +++++++++++++--- hw/i386/pc_q35.c | 14 ++++++++++++-- include/hw/boards.h | 6 ++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 55b08f1466..28013a0e3f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -24,6 +24,13 @@ #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +GlobalProperty hw_compat_4_0_1[] = { + { "virtio-blk-device", "queue-size", "128" }, + { "virtio-scsi-device", "virtqueue_size", "128" }, + { "vhost-scsi-device", "virtqueue_size", "128" }, +}; +const size_t hw_compat_4_0_1_len = G_N_ELEMENTS(hw_compat_4_0_1); + GlobalProperty hw_compat_4_0[] = { { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, }; @@ -157,6 +164,13 @@ GlobalProperty hw_compat_2_1[] = { }; const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1); +GlobalProperty hw_compat[] = { + { "virtio-blk-device", "queue-size", "256" }, + { "virtio-scsi-device", "virtqueue_size", "256" }, + { "vhost-scsi-device", "virtqueue_size", "256" }, +}; +const size_t hw_compat_len = G_N_ELEMENTS(hw_compat); + static char *machine_get_accel(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8ad8e885c6..2260a61b1b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -426,15 +426,27 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_machine_opts = "firmware=bios-256k.bin"; m->default_display = "std"; machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); + compat_props_add(m->compat_props, hw_compat, hw_compat_len); } -static void pc_i440fx_4_0_machine_options(MachineClass *m) +static void pc_i440fx_4_0_2_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias = "pc"; m->is_default = 1; } +DEFINE_I440FX_MACHINE(v4_0_2, "pc-i440fx-4.0.2", NULL, + pc_i440fx_4_0_2_machine_options); + +static void pc_i440fx_4_0_machine_options(MachineClass *m) +{ + pc_i440fx_4_0_2_machine_options(m); + m->alias = NULL; + m->is_default = 0; + compat_props_add(m->compat_props, hw_compat_4_0_1, hw_compat_4_0_1_len); +} + DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL, pc_i440fx_4_0_machine_options); @@ -443,9 +455,7 @@ static void pc_i440fx_3_1_machine_options(MachineClass *m) PCMachineClass *pcmc = PC_MACHINE_CLASS(m); pc_i440fx_4_0_machine_options(m); - m->is_default = 0; m->smbus_no_migration_support = true; - m->alias = NULL; pcmc->pvh_enabled = false; compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len); compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 45cc29d1ad..50ccd9ebcf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -363,14 +363,25 @@ static void pc_q35_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); m->max_cpus = 288; + compat_props_add(m->compat_props, hw_compat, hw_compat_len); } -static void pc_q35_4_0_1_machine_options(MachineClass *m) +static void pc_q35_4_0_2_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias = "q35"; } +DEFINE_Q35_MACHINE(v4_0_2, "pc-q35-4.0.2", NULL, + pc_q35_4_0_2_machine_options); + +static void pc_q35_4_0_1_machine_options(MachineClass *m) +{ + pc_q35_4_0_2_machine_options(m); + m->alias = NULL; + compat_props_add(m->compat_props, hw_compat_4_0_1, hw_compat_4_0_1_len); +} + DEFINE_Q35_MACHINE(v4_0_1, "pc-q35-4.0.1", NULL, pc_q35_4_0_1_machine_options); @@ -378,7 +389,6 @@ static void pc_q35_4_0_machine_options(MachineClass *m) { pc_q35_4_0_1_machine_options(m); m->default_kernel_irqchip_split = true; - m->alias = NULL; compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); } diff --git a/include/hw/boards.h b/include/hw/boards.h index fe1885cbff..cf10632dac 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -293,6 +293,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_4_0_1[]; +extern const size_t hw_compat_4_0_1_len; + extern GlobalProperty hw_compat_4_0[]; extern const size_t hw_compat_4_0_len; @@ -338,4 +341,7 @@ extern const size_t hw_compat_2_2_len; extern GlobalProperty hw_compat_2_1[]; extern const size_t hw_compat_2_1_len; +extern GlobalProperty hw_compat[]; +extern const size_t hw_compat_len; + #endif -- 2.17.0