From patchwork Wed Jan 29 14:06:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Plotnikov X-Patchwork-Id: 1230918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com 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 ozlabs.org (Postfix) with ESMTPS id 48750p0fqGz9s1x for ; Thu, 30 Jan 2020 01:07:54 +1100 (AEDT) Received: from localhost ([::1]:47024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo0V-0001LN-J7 for incoming@patchwork.ozlabs.org; Wed, 29 Jan 2020 09:07:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40532) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo09-0001Ks-LR for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwo08-0001Cm-CB for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:29 -0500 Received: from relay.sw.ru ([185.231.240.75]:53592) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iwo08-00013L-4x; Wed, 29 Jan 2020 09:07:28 -0500 Received: from dptest2.qa.sw.ru ([10.94.4.71]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iwnzt-0003j6-1e; Wed, 29 Jan 2020 17:07:13 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants Date: Wed, 29 Jan 2020 17:06:59 +0300 Message-Id: <20200129140702.5411-2-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20200129140702.5411-1-dplotnikov@virtuozzo.com> References: <20200129140702.5411-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, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, stefanha@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, den@virtuozzo.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Denis Plotnikov Reviewed-by: Philippe Mathieu-Daudé --- hw/block/virtio-blk.c | 6 ++++-- hw/scsi/virtio-scsi.c | 5 +++-- include/hw/virtio/virtio.h | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 09f46ed85f..72f935033f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -914,7 +914,8 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) memset(&blkcfg, 0, sizeof(blkcfg)); virtio_stq_p(vdev, &blkcfg.capacity, capacity); virtio_stl_p(vdev, &blkcfg.seg_max, - s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2); + s->conf.seg_max_adjust ? s->conf.queue_size - 2 : + VIRTQUEUE_DEFAULT_SIZE - 2); virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls); virtio_stl_p(vdev, &blkcfg.blk_size, blk_size); virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size); @@ -1272,7 +1273,8 @@ static Property virtio_blk_properties[] = { DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, 0, true), DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1), - DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 128), + DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, + VIRTQUEUE_DEFAULT_SIZE), DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, true), DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD, IOThread *), diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3b61563609..36f66046ae 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -660,7 +660,8 @@ static void virtio_scsi_get_config(VirtIODevice *vdev, virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues); virtio_stl_p(vdev, &scsiconf->seg_max, - s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 : 128 - 2); + s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 : + VIRTQUEUE_DEFAULT_SIZE - 2); virtio_stl_p(vdev, &scsiconf->max_sectors, s->conf.max_sectors); virtio_stl_p(vdev, &scsiconf->cmd_per_lun, s->conf.cmd_per_lun); virtio_stl_p(vdev, &scsiconf->event_info_size, sizeof(VirtIOSCSIEvent)); @@ -965,7 +966,7 @@ static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp) static Property virtio_scsi_properties[] = { DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, parent_obj.conf.num_queues, 1), DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSI, - parent_obj.conf.virtqueue_size, 128), + parent_obj.conf.virtqueue_size, VIRTQUEUE_DEFAULT_SIZE), DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSI, parent_obj.conf.seg_max_adjust, true), DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, parent_obj.conf.max_sectors, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b69d517496..a66ea2368b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -48,6 +48,7 @@ size_t virtio_feature_get_config_size(VirtIOFeature *features, typedef struct VirtQueue VirtQueue; #define VIRTQUEUE_MAX_SIZE 1024 +#define VIRTQUEUE_DEFAULT_SIZE 128 typedef struct VirtQueueElement { From patchwork Wed Jan 29 14:07:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Plotnikov X-Patchwork-Id: 1230922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com 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 ozlabs.org (Postfix) with ESMTPS id 48752B1xKMz9s29 for ; Thu, 30 Jan 2020 01:09:05 +1100 (AEDT) Received: from localhost ([::1]:47054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo1f-00040F-N6 for incoming@patchwork.ozlabs.org; Wed, 29 Jan 2020 09:09:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40533) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo09-0001Kt-JW for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwo08-0001Ct-DF for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:29 -0500 Received: from relay.sw.ru ([185.231.240.75]:53604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iwo08-00013Q-68; Wed, 29 Jan 2020 09:07:28 -0500 Received: from dptest2.qa.sw.ru ([10.94.4.71]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iwnzt-0003j6-4s; Wed, 29 Jan 2020 17:07:13 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk Date: Wed, 29 Jan 2020 17:07:00 +0300 Message-Id: <20200129140702.5411-3-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20200129140702.5411-1-dplotnikov@virtuozzo.com> References: <20200129140702.5411-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, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, stefanha@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, den@virtuozzo.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The goal is to reduce the amount of requests issued by a guest on 1M reads/writes. This rises the performance up to 4% on that kind of disk access pattern. The maximum chunk size to be used for the guest disk accessing is limited with seg_max parameter, which represents the max amount of pices in the scatter-geather list in one guest disk request. Since seg_max is virqueue_size dependent, increasing the virtqueue size increases seg_max, which, in turn, increases the maximum size of data to be read/write from guest disk. More details in the original problem statment: https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html Suggested-by: Denis V. Lunev Signed-off-by: Denis Plotnikov --- hw/core/machine.c | 3 +++ include/hw/virtio/virtio.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bfceb..8bc401d8b7 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -28,6 +28,9 @@ #include "hw/mem/nvdimm.h" GlobalProperty hw_compat_4_2[] = { + { "virtio-blk-device", "queue-size", "128"}, + { "virtio-scsi-device", "virtqueue_size", "128"}, + { "vhost-blk-device", "virtqueue_size", "128"}, { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, { "virtio-blk-device", "seg-max-adjust", "off"}, { "virtio-scsi-device", "seg_max_adjust", "off"}, diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index a66ea2368b..16d540e390 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -48,7 +48,7 @@ size_t virtio_feature_get_config_size(VirtIOFeature *features, typedef struct VirtQueue VirtQueue; #define VIRTQUEUE_MAX_SIZE 1024 -#define VIRTQUEUE_DEFAULT_SIZE 128 +#define VIRTQUEUE_DEFAULT_SIZE 256 typedef struct VirtQueueElement { From patchwork Wed Jan 29 14:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Plotnikov X-Patchwork-Id: 1230923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com 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 ozlabs.org (Postfix) with ESMTPS id 48752C1Qqdz9sRY for ; Thu, 30 Jan 2020 01:09:07 +1100 (AEDT) Received: from localhost ([::1]:47056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo1h-00044h-2u for incoming@patchwork.ozlabs.org; Wed, 29 Jan 2020 09:09:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40540) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwo09-0001Ku-NN for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwo08-0001Cz-Dm for qemu-devel@nongnu.org; Wed, 29 Jan 2020 09:07:29 -0500 Received: from relay.sw.ru ([185.231.240.75]:53602) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iwo08-00013P-5d; Wed, 29 Jan 2020 09:07:28 -0500 Received: from dptest2.qa.sw.ru ([10.94.4.71]) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iwnzt-0003j6-AZ; Wed, 29 Jan 2020 17:07:13 +0300 From: Denis Plotnikov To: qemu-devel@nongnu.org Subject: [PATCH v1 3/4] tests: add virtuqueue size checking to virtio_seg_max_adjust test Date: Wed, 29 Jan 2020 17:07:01 +0300 Message-Id: <20200129140702.5411-4-dplotnikov@virtuozzo.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20200129140702.5411-1-dplotnikov@virtuozzo.com> References: <20200129140702.5411-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, vsementsov@virtuozzo.com, ehabkost@redhat.com, qemu-block@nongnu.org, mst@redhat.com, stefanha@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, den@virtuozzo.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is due to the change in the default virtqueue_size in the latest machine type to improve guest disks performance. Signed-off-by: Denis Plotnikov --- tests/acceptance/virtio_seg_max_adjust.py | 33 ++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/virtio_seg_max_adjust.py b/tests/acceptance/virtio_seg_max_adjust.py index 5458573138..645d69b313 100755 --- a/tests/acceptance/virtio_seg_max_adjust.py +++ b/tests/acceptance/virtio_seg_max_adjust.py @@ -27,8 +27,10 @@ from qemu.machine import QEMUMachine from avocado_qemu import Test #list of machine types and virtqueue properties to test -VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust'} -VIRTIO_BLK_PROPS = {'seg_max_adjust': 'seg-max-adjust'} +VIRTIO_SCSI_PROPS = {'seg_max_adjust': 'seg_max_adjust', + 'queue_size': 'virtqueue_size'} +VIRTIO_BLK_PROPS = {'seg_max_adjust': 'seg-max-adjust', + 'queue_size': 'queue-size'} DEV_TYPES = {'virtio-scsi-pci': VIRTIO_SCSI_PROPS, 'virtio-blk-pci': VIRTIO_BLK_PROPS} @@ -40,7 +42,7 @@ VM_DEV_PARAMS = {'virtio-scsi-pci': ['-device', 'virtio-scsi-pci,id=scsi0'], 'driver=null-co,id=drive0,if=none']} -class VirtioMaxSegSettingsCheck(Test): +class VirtioPramsCheck(Test): @staticmethod def make_pattern(props): pattern_items = ['{0} = \w+'.format(prop) for prop in props] @@ -72,20 +74,24 @@ class VirtioMaxSegSettingsCheck(Test): props[p[0]] = p[1] return query_ok, props, error - def check_mt(self, mt, dev_type_name): + def check_mt(self, mt, expected_props, dev_type_name): with QEMUMachine(self.qemu_bin) as vm: - vm.set_machine(mt["name"]) + vm.set_machine(mt) for s in VM_DEV_PARAMS[dev_type_name]: vm.add_args(s) vm.launch() query_ok, props, error = self.query_virtqueue(vm, dev_type_name) if not query_ok: - self.fail('machine type {0}: {1}'.format(mt['name'], error)) + self.fail('machine type {0}: {1}'.format(mt, error)) for prop_name, prop_val in props.items(): - expected_val = mt[prop_name] - self.assertEqual(expected_val, prop_val) + expected_val = expected_props[prop_name] + msg = 'Property value mismatch for (MT: {0}, '\ + 'property name: {1}): expected value: "{2}" '\ + 'actual value: "{3}"'\ + .format(mt, prop_name, expected_val, prop_val) + self.assertEqual(expected_val, prop_val, msg) @staticmethod def seg_max_adjust_enabled(mt): @@ -120,15 +126,18 @@ class VirtioMaxSegSettingsCheck(Test): for dev_type in DEV_TYPES: # create the list of machine types and their parameters. - mtypes = list() + mtypes = dict() for m in machines: if self.seg_max_adjust_enabled(m): enabled = 'true' + queue_size = '256' else: enabled = 'false' - mtypes.append({'name': m, - DEV_TYPES[dev_type]['seg_max_adjust']: enabled}) + queue_size = '128' + mtypes[m] = { + DEV_TYPES[dev_type]['seg_max_adjust']: enabled, + DEV_TYPES[dev_type]['queue_size']: queue_size } # test each machine type for a device type for mt in mtypes: - self.check_mt(mt, dev_type) + self.check_mt(mt, mtypes[mt], dev_type)