Skip to contentSkip to conversation

Increase default virtqueue size to improve performance

PATCH In review Denis Plotnikov 8 participants 32 messages Jan 29, 2020 – Sep 9, 2021

lore
Share & tools
lore
#0 lore raw

cover Increase default virtqueue size to improve performance

The goal is to increase the performance of the block layer on
1M reads/writes up to 4% by reducing the amount of requests issued by a guest using virtio-scsi or virtio-blk devices.

Original problem description:
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html

Denis Plotnikov (4):
virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded
constants
virtio: increase virtuqueue size for virtio-scsi and virtio-blk
tests: add virtuqueue size checking to virtio_seg_max_adjust test
tests: rename virtio_seg_max_adjust to virtio_check_params

 hw/block/virtio-blk.c                         |  6 ++--
 hw/core/machine.c                             |  3 ++
 hw/scsi/virtio-scsi.c                         |  5 +--
 include/hw/virtio/virtio.h                    |  1 +
 ...g_max_adjust.py => virtio_check_params.py} | 33 ++++++++++++-------
 5 files changed, 32 insertions(+), 16 deletions(-)
 rename tests/acceptance/{virtio_seg_max_adjust.py => virtio_check_params.py} (79%)
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/4 virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

---
 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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
 {
Signature · 1 line
2.17.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 1 line · Denis Plotnikov

typo VIRTQUEUE_DEFUALT_SIZE -> VIRTQUEUE_DEFAULT_SIZE in subject

With subject fixed:

Quoted 66 lines
---
  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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
  {
#3 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

In reply to Denis Plotnikov
Quoted 59 lines · On Wed, 29 Jan 2020 17:06:59 +0300 Denis Plotnikov <[email protected]>…
---
 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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +0 -0
index b69d517496..a66ea2368b 100644

include/hw/virtio/virtio.h size_t virtio_feature_get_config_size(VirtIOFeature *features, · line 51

Quoted 4 lines
include/hw/virtio/virtio.h +1 -0
@@ -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

Going from the header only, this looks like a value that is supposed to be used for every virtqueue... but from the users, this is only for blk and scsi.

I don't think adding a default for everything makes sense, even if the same value makes sense for blk and scsi.

Quoted 3 lines
include/hw/virtio/virtio.h +0 -0
 typedef struct VirtQueueElement
 {
#4 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 71 lines · Cornelia Huck
Quoted 59 lines · On Wed, 29 Jan 2020 17:06:59 +0300 Denis Plotnikov <[email protected]>…
---
 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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +0 -0
index b69d517496..a66ea2368b 100644

include/hw/virtio/virtio.h size_t virtio_feature_get_config_size(VirtIOFeature *features, · line 51

Quoted 4 lines
include/hw/virtio/virtio.h +1 -0
@@ -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

Going from the header only, this looks like a value that is supposed to be used for every virtqueue... but from the users, this is only for blk and scsi.

Quoted 2 lines

I don't think adding a default for everything makes sense, even if the same value makes sense for blk and scsi.

Agreed, this value is too general. VIRTIO_BLK_VQ_DEFAULT_SIZE and VIRTIO_SCSI_VQ_DEFAULT_SIZE would make sense to me.

Stefan

#5 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 71 lines · Stefan Hajnoczi
Quoted 70 lines · Cornelia Huck
Quoted 59 lines · On Wed, 29 Jan 2020 17:06:59 +0300 Denis Plotnikov <[email protected]>…
---
  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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +0 -0
index b69d517496..a66ea2368b 100644

include/hw/virtio/virtio.h size_t virtio_feature_get_config_size(VirtIOFeature *features, · line 51

Quoted 4 lines
include/hw/virtio/virtio.h +1 -0
@@ -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

Going from the header only, this looks like a value that is supposed to be used for every virtqueue... but from the users, this is only for blk and scsi.

Quoted 6 lines
Quoted 2 lines

I don't think adding a default for everything makes sense, even if the same value makes sense for blk and scsi.

Agreed, this value is too general. VIRTIO_BLK_VQ_DEFAULT_SIZE and VIRTIO_SCSI_VQ_DEFAULT_SIZE would make sense to me.

Stefan

agree, that would be better.
Will redo and resend the series.

Denis

#6 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

In reply to Denis Plotnikov
Quoted 1 line · Denis Plotnikov

I'm not sure what the point is. It's more or less an accident that these two devices share the queue size, this constance makes no sense to me.

Quoted 67 lines
---
 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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
 {
Signature · 1 line
2.17.0
#7 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 6 lines · Michael S. Tsirkin
Quoted 1 line · Denis Plotnikov

I'm not sure what the point is. It's more or less an accident that these two devices share the queue size, this constance makes no sense to me.

Ok, then let's just make a separate queue length constant for each type. (Will redo and send in the next series)
Thanks!

Denis

Quoted 68 lines
Quoted 68 lines
---
  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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
  {
Signature · 1 line
2.17.0
#8 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 10 lines · Denis Plotnikov
Quoted 6 lines · Michael S. Tsirkin
Quoted 1 line · Denis Plotnikov

I'm not sure what the point is. It's more or less an accident that these two devices share the queue size, this constance makes no sense to me.

Ok, then let's just make a separate queue length constant for each type.

it's just a number, I don't think we need a constant here. If you feel it needs documentation, add a comment!

Quoted 69 lines

(Will redo and send in the next series)
Thanks!

Denis

Quoted 65 lines
Quoted 65 lines
---
  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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
  {
Signature · 1 line
2.17.0
#9 lore raw

Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants

Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Denis Plotnikov
Quoted 5 lines · Michael S. Tsirkin
Quoted 1 line · Denis Plotnikov

I'm not sure what the point is. It's more or less an accident that these two devices share the queue size, this constance makes no sense to me.

Ok, then let's just make a separate queue length constant for each type.

it's just a number, I don't think we need a constant here. If you feel it needs documentation, add a comment!

I just thought that the meaningful name for the number would be better for the code understanding. Anyway, If doesn't improve anything I'll just change the number and add a comment what it means.

Denis

Quoted 69 lines
Quoted 69 lines

(Will redo and send in the next series)
Thanks!

Denis

Quoted 64 lines
Quoted 64 lines
---
   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(-)
hw/block/virtio-blk.c +4 -2
index 09f46ed85f..72f935033f 100644
@@ -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 *),
hw/scsi/virtio-scsi.c +3 -2
index 3b61563609..36f66046ae 100644
@@ -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,
include/hw/virtio/virtio.h +1 -0
index b69d517496..a66ea2368b 100644
@@ -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
   {
Signature · 1 line
2.17.0
#10 lore raw

PATCH 2/4 virtio: increase virtuqueue size for virtio-scsi and virtio-blk

In reply to Denis Plotnikov

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

---
 hw/core/machine.c          | 3 +++
 include/hw/virtio/virtio.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},
include/hw/virtio/virtio.h +1 -1
index a66ea2368b..16d540e390 100644
@@ -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
 {
Signature · 1 line
2.17.0
#11 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 12 lines · Denis Plotnikov

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.

Quoted 5 lines

More details in the original problem statment:
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html

looks good but let's just patch each device separately.

Quoted 34 lines
---
 hw/core/machine.c          | 3 +++
 include/hw/virtio/virtio.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},
include/hw/virtio/virtio.h +1 -1
index a66ea2368b..16d540e390 100644
@@ -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
 {
Signature · 1 line
2.17.0
#12 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 13 lines · Michael S. Tsirkin
Quoted 12 lines · Denis Plotnikov

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.

Quoted 7 lines
Quoted 5 lines

More details in the original problem statment:
https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg03721.html

looks good but let's just patch each device separately.

Ok
Denis

Quoted 35 lines
Quoted 35 lines
---
  hw/core/machine.c          | 3 +++
  include/hw/virtio/virtio.h | 2 +-
  2 files changed, 4 insertions(+), 1 deletion(-)
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},
include/hw/virtio/virtio.h +1 -1
index a66ea2368b..16d540e390 100644
@@ -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
  {
Signature · 1 line
2.17.0
#13 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

In reply to Denis Plotnikov
Quoted 27 lines · Denis Plotnikov

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

---
 hw/core/machine.c          | 3 +++
 include/hw/virtio/virtio.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
hw/core/machine.c +0 -0
index 3e288bfceb..8bc401d8b7 100644

hw/core/machine.c line 33

Quoted 6 lines
hw/core/machine.c +3 -0
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

#14 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 30 lines · Stefan Hajnoczi
Quoted 29 lines · Denis Plotnikov

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

---
  hw/core/machine.c          | 3 +++
  include/hw/virtio/virtio.h | 2 +-
  2 files changed, 4 insertions(+), 1 deletion(-)
hw/core/machine.c +0 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -28,6 +28,9 @@
  #include "hw/mem/nvdimm.h"
 
Quoted 6 lines

hw/core/machine.c line 33

Quoted 4 lines
hw/core/machine.c +3 -0
  GlobalProperty hw_compat_4_2[] = {
+    { "virtio-blk-device", "queue-size", "128"},
+    { "virtio-scsi-device", "virtqueue_size", "128"},
+    { "vhost-blk-device", "virtqueue_size", "128"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

Quoted 4 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the qemu git.
Is there any way to do it with some qit.qemu available stubs or something else? If so, could you please point out the proper way to do it?

Thanks!
Denis

#15 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 48 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
  hw/core/machine.c          | 3 +++
  include/hw/virtio/virtio.h | 2 +-
  2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

Quoted 7 lines

    virtio: make seg_max virtqueue size dependent

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 4 lines
Quoted 4 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

Quoted 13 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#16 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 50 lines · Stefan Hajnoczi
Quoted 49 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
   hw/core/machine.c          | 3 +++
   include/hw/virtio/virtio.h | 2 +-
   2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi.
This is because increasing the queue sizes seems to be just useless for them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?). Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.
So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#17 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 65 lines · Denis Plotnikov
Quoted 50 lines · Stefan Hajnoczi
Quoted 49 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
   hw/core/machine.c          | 3 +++
   include/hw/virtio/virtio.h | 2 +-
   2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

Quoted 14 lines

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi. This is because increasing the queue sizes seems to be just useless for
them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?).
Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.
So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

That's fine. If it's beneficial to extend it to the vhost devices then it can be done later. I didn't look into it (and the way that responsibility for these parameters is shared between QEMU and the vhost-user device backend is a little complicated).

Stefan

#18 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

In reply to Denis Plotnikov
Quoted 65 lines · Denis Plotnikov
Quoted 50 lines · Stefan Hajnoczi
Quoted 49 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
   hw/core/machine.c          | 3 +++
   include/hw/virtio/virtio.h | 2 +-
   2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

Quoted 12 lines

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi. This is because increasing the queue sizes seems to be just useless for
them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?).
Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.

The queue size is set by qemu IIRC.

Quoted 2 lines

So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Hmm that would break ability to migrate between userspace and vhost backends, would it not?

Quoted 19 lines

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#19 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 76 lines · Michael S. Tsirkin
Quoted 63 lines · Denis Plotnikov
Quoted 49 lines · Stefan Hajnoczi
Quoted 48 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
    hw/core/machine.c          | 3 +++
    include/hw/virtio/virtio.h | 2 +-
    2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

Quoted 12 lines

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi. This is because increasing the queue sizes seems to be just useless for
them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?).
Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.

Quoted 7 lines

The queue size is set by qemu IIRC.

Quoted 2 lines

So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Hmm that would break ability to migrate between userspace and vhost backends, would it not?

I'm not sure I've understood what you meant.
Just for the record, I was going to change virtqueue-size for virtio-blk-device and virtio-scsi-device since they can adjust seg_max to the specified queue size and I don't want to touch vhost-s and vhost-user-s since they don't have adjustable seg_max for now.

Denis

Quoted 21 lines
Quoted 21 lines

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#20 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 81 lines · Denis Plotnikov
Quoted 78 lines · Michael S. Tsirkin
Quoted 63 lines · Denis Plotnikov
Quoted 49 lines · Stefan Hajnoczi
Quoted 48 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
    hw/core/machine.c          | 3 +++
    include/hw/virtio/virtio.h | 2 +-
    2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

Quoted 12 lines

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi. This is because increasing the queue sizes seems to be just useless for
them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?).
Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.

The queue size is set by qemu IIRC.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Hmm that would break ability to migrate between userspace and vhost backends, would it not?

I'm not sure I've understood what you meant.
Just for the record, I was going to change virtqueue-size for virtio-blk-device and virtio-scsi-device

If virtqueue size is different between virtio-blk-device and vhost-user-blk then one can not migrate the former to the later.

Quoted 5 lines

since they can adjust seg_max to
the specified queue size and I don't want to touch vhost-s and vhost-user-s since they don't have adjustable seg_max for now.

Denis

If I just grep seg_max_adjust I see them for vhost devices too. Is that code ineffective somehow? What's it doing then?

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#21 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin
Quoted 6 lines · Denis Plotnikov
Quoted 3 lines · Stefan Hajnoczi
Quoted 2 lines · Denis Plotnikov
Quoted 1 line · Stefan Hajnoczi

On Wed, Jan 29, 2020 at 05:07:00PM +0300, Denis Plotnikov wrote:

So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Hmm that would break ability to migrate between userspace and vhost backends, would it not?

I think live and offline migration between them would still work as long as the queue size is manually specified.

Stefan

#22 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

In reply to Denis Plotnikov

Hi Denis,
I just found this discussion since we still have the following line in hw/core/machine.c:

    { "vhost-blk-device", "seg_max_adjust", "off"}

IIUC it was a typo, and I think we should fix it since in the future we can have vhost-blk-device.

So, I think we have 2 options:
1. remove that line since for now is useless
2. replace with "vhost-scsi"

I'm not sure which is the best, what do you suggest?

Thanks,
Stefano

Quoted 88 lines · Denis Plotnikov
Quoted 49 lines · Stefan Hajnoczi
Quoted 48 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
  hw/core/machine.c          | 3 +++
  include/hw/virtio/virtio.h | 2 +-
  2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi.
This is because increasing the queue sizes seems to be just useless for them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?). Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.
So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#23 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Message bounced, I use new Denis's email address.

Quoted 104 lines · Stefano Garzarella

Hi Denis,
I just found this discussion since we still have the following line in hw/core/machine.c:

   { "vhost-blk-device", "seg_max_adjust", "off"}

IIUC it was a typo, and I think we should fix it since in the future we can have vhost-blk-device.

So, I think we have 2 options:
1. remove that line since for now is useless
2. replace with "vhost-scsi"

I'm not sure which is the best, what do you suggest?

Thanks,
Stefano

Quoted 88 lines · Denis Plotnikov
Quoted 49 lines · Stefan Hajnoczi
Quoted 48 lines · Denis Plotnikov
Quoted 23 lines · Stefan Hajnoczi
Quoted 22 lines · Denis Plotnikov

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

---
 hw/core/machine.c          | 3 +++
 include/hw/virtio/virtio.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?! Who has this? It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git? Those devices would benefit from better performance too.

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi.
This is because increasing the queue sizes seems to be just useless for them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?). Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.
So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#24 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 17 lines · Stefano Garzarella

Message bounced, I use new Denis's email address.

Quoted 14 lines · Stefano Garzarella

Hi Denis,
I just found this discussion since we still have the following line in hw/core/machine.c:
   { "vhost-blk-device", "seg_max_adjust", "off"}

IIUC it was a typo, and I think we should fix it since in the future we can have vhost-blk-device.

So, I think we have 2 options:
1. remove that line since for now is useless
2. replace with "vhost-scsi"

I'm not sure which is the best, what do you suggest?

Thanks,
Stefano

Hi Stefano

I prefer to just remove the line without replacing. This will keep things exactly like it is now.

Replacing with "vhost-scsi" will affect seg_max (limit to 126) on newly created VMs with machine types using "hw_compat_4_2" and older.

Now, because of the typo (error), their seg-max is queue-size dependent. I'm not sure, if replacing the line may cause any problems, for example on migration: source (queue-size 256, seg max 254) -> destination (queue-size 256, seg max 126). But it will definitely introduce two different behaviors for VMs with "hw_compat_4_2" and older. So, I'd choose the lesser of two evils and keep the things like it's now.

Thanks!

Denis

Quoted 91 lines
Quoted 90 lines · Denis Plotnikov
Quoted 88 lines · Stefan Hajnoczi
Quoted 49 lines · Denis Plotnikov
Quoted 48 lines · Stefan Hajnoczi
Quoted 23 lines · Denis Plotnikov
Quoted 22 lines

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

---
 hw/core/machine.c          | 3 +++
 include/hw/virtio/virtio.h | 2 +-

 2 files changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

hw/core/machine.c line 32

Quoted 10 lines
hw/core/machine.c +3 -0
index 3e288bfceb..8bc401d8b7 100644
@@ -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"},

vhost-blk-device?!  Who has this?  It's not in qemu.git so please omit this line. ;-)

So in this case the line:

{ "vhost-blk-device", "seg_max_adjust", "off"},

introduced by my patch:

commit 1bf8a989a566b2ba41c197004ec2a02562a766a4
Author: Denis Plotnikov <[email protected]> Date:   Fri Dec 20 17:09:04 2019 +0300

    virtio: make seg_max virtqueue size dependent

Quoted 12 lines
Quoted 5 lines

is also wrong. It should be:

{ "vhost-scsi-device", "seg_max_adjust", "off"},

Am I right?

It's just called "vhost-scsi":

include/hw/virtio/vhost-scsi.h:#define TYPE_VHOST_SCSI "vhost-scsi"

Quoted 3 lines
Quoted 3 lines

On the other hand, do you want to do this for the vhost-user-blk, vhost-user-scsi, and vhost-scsi devices that exist in qemu.git?  Those devices would benefit from better performance too.

After thinking about that for a while, I think we shouldn't extend queue sizes for vhost-user-blk, vhost-user-scsi and vhost-scsi.
This is because increasing the queue sizes seems to be just useless for them: the all thing is about increasing the queue sizes for increasing seg_max (it limits the max block query size from the guest). For virtio-blk-device and virtio-scsi-device it makes sense, since they have seg-max-adjust property which, if true, sets seg_max to virtqueue_size-2. vhost-scsi also have this property but it seems the property just doesn't affect anything (remove it?). Also vhost-user-blk, vhost-user-scsi and vhost-scsi don't do any seg_max settings. If I understand correctly, their backends are ment to be responsible for doing that.
So, what about changing the queue sizes just for virtio-blk-device and virtio-scsi-device?

Denis

Quoted 17 lines
Quoted 5 lines

It seems to be so. We also have the test checking those settings:
tests/acceptance/virtio_seg_max_adjust.py
For now it checks virtio-scsi-pci and virtio-blk-pci.
I'm going to extend it for the virtqueue size checking.
If I change vhost-user-blk, vhost-user-scsi and vhost-scsi it's worth

Quoted 8 lines

to check those devices too. But I don't know how to form a command line for that 3 devices since they should involve some third party components as backends (kernel modules, DPDK, etc.) and they seems to be not available in the
qemu git.
Is there any way to do it with some qit.qemu available stubs or something else?
If so, could you please point out the proper way to do it?

qemu.git has contrib/vhost-user-blk/ and contrib/vhost-user-scsi/ if you need to test those vhost-user devices without external dependencies.

Stefan

#25 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 20 lines · Denis Plotnikov
Quoted 17 lines · Stefano Garzarella

Message bounced, I use new Denis's email address.

Quoted 14 lines · Stefano Garzarella

Hi Denis,
I just found this discussion since we still have the following line in hw/core/machine.c:
   { "vhost-blk-device", "seg_max_adjust", "off"}

IIUC it was a typo, and I think we should fix it since in the future we can have vhost-blk-device.

So, I think we have 2 options:
1. remove that line since for now is useless
2. replace with "vhost-scsi"

I'm not sure which is the best, what do you suggest?

Thanks,
Stefano

Quoted 8 lines

Hi Stefano

I prefer to just remove the line without replacing. This will keep things exactly like it is now.

Replacing with "vhost-scsi" will affect seg_max (limit to 126) on newly created VMs with machine types using "hw_compat_4_2" and older.

Now, because of the typo (error), their seg-max is queue-size dependent. I'm not sure, if replacing the line may cause any problems, for example on migration: source (queue-size 256, seg max 254) -> destination (queue-size 256, seg max 126). But it will definitely introduce two different behaviors for VMs with "hw_compat_4_2" and older. So, I'd choose the lesser of two evils and keep the things like it's now.

Yep, make sense. It was the same concern I had.

Do you want to send a patch to remove it with this explanation?

Thanks for the clarification,
Stefano

#26 lore raw

Re: [PATCH v1 2/4] virtio: increase virtuqueue size for virtio-scsi and virtio-blk

Quoted 25 lines · Stefano Garzarella
Quoted 24 lines · Denis Plotnikov
Quoted 17 lines · Stefano Garzarella

Message bounced, I use new Denis's email address.

Quoted 14 lines · Stefano Garzarella

Hi Denis,
I just found this discussion since we still have the following line in hw/core/machine.c:
   { "vhost-blk-device", "seg_max_adjust", "off"}

IIUC it was a typo, and I think we should fix it since in the future we can have vhost-blk-device.

So, I think we have 2 options:
1. remove that line since for now is useless
2. replace with "vhost-scsi"

I'm not sure which is the best, what do you suggest?

Thanks,
Stefano

Hi Stefano

I prefer to just remove the line without replacing. This will keep things exactly like it is now.

Quoted 8 lines
Quoted 4 lines

Replacing with "vhost-scsi" will affect seg_max (limit to 126) on newly created VMs with machine types using "hw_compat_4_2" and older.

Now, because of the typo (error), their seg-max is queue-size dependent. I'm not sure, if replacing the line may cause any problems, for example on migration: source (queue-size 256, seg max 254) -> destination (queue-size 256, seg max 126). But it will definitely introduce two different behaviors for VMs with "hw_compat_4_2" and older. So, I'd choose the lesser of two evils and keep the things like it's now.

Yep, make sense. It was the same concern I had.

Do you want to send a patch to remove it with this explanation?

Yes, sure.

I'll do it today.

Denis

Quoted 4 lines

Thanks for the clarification,
Stefano

#27 lore raw

PATCH 3/4 tests: add virtuqueue size checking to virtio_seg_max_adjust test

In reply to Denis Plotnikov

This is due to the change in the default virtqueue_size in the latest machine type to improve guest disks performance.

---
 tests/acceptance/virtio_seg_max_adjust.py | 33 ++++++++++++++---------
 1 file changed, 21 insertions(+), 12 deletions(-)
tests/acceptance/virtio_seg_max_adjust.py +21 -12
index 5458573138..645d69b313 100755
@@ -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)
Signature · 1 line
2.17.0
#28 lore raw

Re: [PATCH v1 3/4] tests: add virtuqueue size checking to virtio_seg_max_adjust test

Quoted 3 lines · Denis Plotnikov

This is due to the change in the default virtqueue_size in the latest machine type to improve guest disks performance.

Sorry what is due to the change?

Quoted 48 lines
---
 tests/acceptance/virtio_seg_max_adjust.py | 33 ++++++++++++++---------
 1 file changed, 21 insertions(+), 12 deletions(-)
tests/acceptance/virtio_seg_max_adjust.py +8 -6
index 5458573138..645d69b313 100755
@@ -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))

tests/acceptance/virtio_seg_max_adjust.py class VirtioMaxSegSettingsCheck(Test): · line 94

Quoted 10 lines
tests/acceptance/virtio_seg_max_adjust.py +6 -2
 
         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)

Looks like an unrelated change, no?

Quoted 27 lines
tests/acceptance/virtio_seg_max_adjust.py +7 -4
     @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)
Signature · 1 line
2.17.0
#29 lore raw

Re: [PATCH v1 3/4] tests: add virtuqueue size checking to virtio_seg_max_adjust test

Quoted 55 lines · Michael S. Tsirkin
Quoted 3 lines · Denis Plotnikov

This is due to the change in the default virtqueue_size in the latest machine type to improve guest disks performance.

Sorry what is due to the change?

Quoted 49 lines
---
  tests/acceptance/virtio_seg_max_adjust.py | 33 ++++++++++++++---------
  1 file changed, 21 insertions(+), 12 deletions(-)
tests/acceptance/virtio_seg_max_adjust.py +8 -6
index 5458573138..645d69b313 100755
@@ -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))
 
Quoted 11 lines

tests/acceptance/virtio_seg_max_adjust.py class VirtioMaxSegSettingsCheck(Test): · line 94

Quoted 9 lines
tests/acceptance/virtio_seg_max_adjust.py +6 -2
          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)

Looks like an unrelated change, no?

Yep, I'd better split the patches and add the test improvements in the separate one.

Denis

Quoted 28 lines
Quoted 28 lines
tests/acceptance/virtio_seg_max_adjust.py +7 -4
      @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)
Signature · 1 line
2.17.0
#30 lore raw

PATCH 4/4 tests: rename virtio_seg_max_adjust to virtio_check_params

In reply to Denis Plotnikov

Since, virtio_seg_max_adjust checks not only seg_max, but also virtqueue_size parameter, let's make the test more general and add new parameters to be checked there in the future.

---
 .../{virtio_seg_max_adjust.py => virtio_check_params.py}          | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tests/acceptance/{virtio_seg_max_adjust.py => virtio_check_params.py} (100%)
tests/acceptance/virtio_check_params.py renamed from tests/acceptance/virtio_seg_max_adjust.py +0 -0
similarity index 100%
rename from tests/acceptance/virtio_seg_max_adjust.py
rename to tests/acceptance/virtio_check_params.py
Signature · 1 line
2.17.0
Reviewed-by on v1 4/4
#31 lore raw

Re: [PATCH v1 4/4] tests: rename virtio_seg_max_adjust to virtio_check_params

Quoted 9 lines · Denis Plotnikov

Since, virtio_seg_max_adjust checks not only seg_max, but also virtqueue_size parameter, let's make the test more general and add new parameters to be checked there in the future.

---
 .../{virtio_seg_max_adjust.py => virtio_check_params.py}          | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tests/acceptance/{virtio_seg_max_adjust.py => virtio_check_params.py} (100%)

Old one... reminds me of
https://lore.kernel.org/qemu-devel/[email protected]/
:~(