Skip to contentSkip to conversation

virtio: increase virtuqueue size for virtio-scsi and virtio-blk

PATCH Applied Denis Plotnikov 3 participants 5 messages Feb 13, 2020 – Feb 18, 2020

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio: increase virtuqueue size for virtio-scsi and virtio-blk

v1:
* seg_max default value changing removed

---
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 a guest disk.

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

---
 hw/block/virtio-blk.c | 2 +-
 hw/core/machine.c     | 2 ++
 hw/scsi/virtio-scsi.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
hw/block/virtio-blk.c +1 -1
index 09f46ed85f..142863a3b2 100644
@@ -1272,7 +1272,7 @@ 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, 256),
     DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, true),
     DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD,
                      IOThread *),
hw/core/machine.c +2 -0
index 2501b540ec..3427d6cf4c 100644
@@ -28,6 +28,8 @@
 #include "hw/mem/nvdimm.h"
 
 GlobalProperty hw_compat_4_2[] = {
+    { "virtio-blk-device", "queue-size", "128"},
+    { "virtio-scsi-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"},
hw/scsi/virtio-scsi.c +1 -1
index 3b61563609..472bbd233b 100644
@@ -965,7 +965,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, 256),
     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,
Signature · 1 line
2.17.0
#1 lore raw

Typo 'virtuqueue' in subject.

Quoted 3 lines · Denis Plotnikov

v1:
* seg_max default value changing removed

^^^ This part ...

Quoted 13 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 a guest disk.

Quoted 6 lines

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

---

... goes here.

Quoted 45 lines
  hw/block/virtio-blk.c | 2 +-
  hw/core/machine.c     | 2 ++
  hw/scsi/virtio-scsi.c | 2 +-
  3 files changed, 4 insertions(+), 2 deletions(-)
hw/block/virtio-blk.c +1 -1
index 09f46ed85f..142863a3b2 100644
@@ -1272,7 +1272,7 @@ 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, 256),
      DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, true),
      DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD,
                       IOThread *),
hw/core/machine.c +2 -0
index 2501b540ec..3427d6cf4c 100644
@@ -28,6 +28,8 @@
  #include "hw/mem/nvdimm.h"
 
  GlobalProperty hw_compat_4_2[] = {
+    { "virtio-blk-device", "queue-size", "128"},
+    { "virtio-scsi-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"},
hw/scsi/virtio-scsi.c +1 -1
index 3b61563609..472bbd233b 100644
@@ -965,7 +965,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, 256),
      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,
#2 lore raw
In reply to Denis Plotnikov
Quoted 19 lines · Denis Plotnikov

v1:
* seg_max default value changing removed

---
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 a guest disk.

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

Quoted 7 lines
---
 hw/block/virtio-blk.c | 2 +-
 hw/core/machine.c     | 2 ++
 hw/scsi/virtio-scsi.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

I fixed up the "virtuqueue" typo in the commit message and the mis-formatted commit description (git-am(1) stops including lines after the first "---").

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#3 lore raw
Quoted 27 lines · Stefan Hajnoczi
Quoted 19 lines · Denis Plotnikov

v1:
* seg_max default value changing removed

---
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 a guest disk.

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

Quoted 7 lines
---
  hw/block/virtio-blk.c | 2 +-
  hw/core/machine.c     | 2 ++
  hw/scsi/virtio-scsi.c | 2 +-
  3 files changed, 4 insertions(+), 2 deletions(-)
Quoted 3 lines

I fixed up the "virtuqueue" typo in the commit message and the mis-formatted commit description (git-am(1) stops including lines after the first "---").

Actually, I sent the corrected version v3 of the patch last week. But it seems it got lost among that gigantic patch flow in the mailing list :) Thanks for applying!

Denis

Quoted 5 lines

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

#4 lore raw
Quoted 30 lines · Denis Plotnikov
Quoted 27 lines · Stefan Hajnoczi
Quoted 26 lines · Denis Plotnikov

v1:
   * seg_max default value changing removed

---
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 a guest disk.

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

---
  hw/block/virtio-blk.c | 2 +-
  hw/core/machine.c     | 2 ++
  hw/scsi/virtio-scsi.c | 2 +-

  3 files changed, 4 insertions(+), 2 deletions(-)
Quoted 12 lines
Quoted 3 lines

I fixed up the "virtuqueue" typo in the commit message and the mis-formatted commit description (git-am(1) stops including lines after the first "---").

Actually, I sent the corrected version v3 of the patch last week. But it seems it got lost among that gigantic patch flow in the mailing list :) Thanks for applying!

Denis

Quoted 5 lines

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

I'm going to send the test checking the virtqueue-sizes for machine types a little bit later.

Denis