virtio: increase virtuqueue size for virtio-scsi and virtio-blk
PATCH v2 1/1 virtio: increase virtuqueue size for virtio-scsi and virtio-blk
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 | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)
hw/block/virtio-blk.c +2 -2
@@ -914,7 +914,7 @@ 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 :256 -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 +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
@@ -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 +2 -2
@@ -660,7 +660,7 @@ 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 :256 -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 +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
Quoted 28 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)hw/block/virtio-blk.c +0
-0
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 5 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );
This value must not change on older machine types. So does this patch need to turn seg-max-adjust *on* in hw_compat_4_2 so that old machine types get 126 instead of 254?
Quoted 51 lines
hw/block/virtio-blk.c +1
-1virtio_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 +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@@ -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 +2
-2@@ -660,7 +660,7 @@ 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 :256 -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 +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
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)
Quoted 11 lines
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 10 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );This value must not change on older machine types.
Yes, that's true, but ..
Quoted 3 lines
So does this patch
need to turn seg-max-adjust *on* inhw_compat_4_2so that old machine types get 126 instead of 254?
If we set seg-max-adjust "on" in older machine types, the setups using them and having queue_sizes set , for example, 1024 will also set seg_max to 1024 - 2 which isn't the expected behavior: older mt didn't change seg_max in that case and stuck with 128 - 2. So, should we, instead, leave the default 128 - 2, for seg_max?
Denis
Quoted 52 lines
Quoted 52 lines
hw/block/virtio-blk.c +1
-1virtio_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 +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@@ -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 +2
-2@@ -660,7 +660,7 @@ 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 :256 -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 +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
Quoted 37 lines · Denis Plotnikov
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)Quoted 11 lines
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 10 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );This value must not change on older machine types.
Yes, that's true, but ..
Quoted 8 lines
Quoted 3 lines
So does this patch
need to turn seg-max-adjust *on* inhw_compat_4_2so that old machine types get 126 instead of 254?If we set seg-max-adjust "on" in older machine types, the setups using them and having
queue_sizesset , for example, 1024 will also setseg_maxto 1024
- 2 which isn't the expected behavior: older mt didn't changeseg_maxin that case and stuck with 128 - 2.
So, should we, instead, leave the default 128 - 2, forseg_max?
Argh! Good point :-).
How about a seg_max_default property that is initialized to 254 for modern machines and 126 to old machines?
Stefan
Quoted 46 lines · Stefan Hajnoczi
Quoted 37 lines · Denis Plotnikov
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)Quoted 11 lines
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 10 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );This value must not change on older machine types.
Yes, that's true, but ..
Quoted 8 lines
Quoted 3 lines
So does this patch
need to turn seg-max-adjust *on* inhw_compat_4_2so that old machine types get 126 instead of 254?If we set seg-max-adjust "on" in older machine types, the setups using them and having
queue_sizesset , for example, 1024 will also setseg_maxto 1024
- 2 which isn't the expected behavior: older mt didn't changeseg_maxin that case and stuck with 128 - 2.
So, should we, instead, leave the default 128 - 2, forseg_max?
Quoted 4 lines
Argh! Good point :-).
How about a
seg_max_defaultproperty that is initialized to 254 for modern machines and 126 to old machines?
Hmm, but we'll achieve the same but with more code changes, don't we?
254 is because the queue-size is 256. We gonna leave 128-2 for older machine types
just for not breaking anything. All other seg_max adjustment is provided by seg_max_adjust which is "on" by default in modern machine types.
to summarize:
modern mt defaults:seg_max_adjust = onqueue_size = 256
=> default seg_max = 254
=> changing queue-size will change seg_max = queue_size - 2
old mt defaults:seg_max_adjust = offqueue_size = 128
=> default seg_max = 126
=> changing queue-size won't change seg_max, it's always = 126 like it was before
Denis
Quoted 2 lines
Stefan
Quoted 68 lines · Denis Plotnikov
Quoted 46 lines · Stefan Hajnoczi
Quoted 37 lines · Denis Plotnikov
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)Quoted 11 lines
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 10 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );This value must not change on older machine types.
Yes, that's true, but ..
Quoted 8 lines
Quoted 3 lines
So does this patch
need to turn seg-max-adjust *on* inhw_compat_4_2so that old machine types get 126 instead of 254?If we set seg-max-adjust "on" in older machine types, the setups using them and having
queue_sizesset , for example, 1024 will also setseg_maxto 1024
- 2 which isn't the expected behavior: older mt didn't changeseg_maxin that case and stuck with 128 - 2.
So, should we, instead, leave the default 128 - 2, forseg_max?Quoted 4 lines
Argh! Good point :-).
How about a
seg_max_defaultproperty that is initialized to 254 for modern machines and 126 to old machines?Hmm, but we'll achieve the same but with more code changes, don't we? 254 is because the queue-size is 256. We gonna leave 128-2 for older machine types
just for not breaking anything. All otherseg_maxadjustment is provided byseg_max_adjustwhich is "on" by default in modern machine types.to summarize:
modern mt defaults:
seg_max_adjust= onqueue_size= 256=> default
seg_max= 254
=> changing queue-size will changeseg_max=queue_size- 2
Quoted 7 lines
old mt defaults:
seg_max_adjust= offqueue_size= 128=> default
seg_max= 126
=> changing queue-size won't changeseg_max, it's always = 126 like it was before
You're right! The only strange case is a modern machine type with seg_max_adjust=off, where queue_size will be 256 but seg_max will be
126. But no user would want to disable seg_max_adjust, so it's okay.
I agree with you that the line of code can remain unchanged:
/*
* Only old machine types use seg_max_adjust=off and there the default
* value of queue_size is 128.
*/
virtio_stl_p(vdev, &blkcfg.seg_max,
s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2);
Stefan
Quoted 81 lines · Stefan Hajnoczi
Quoted 67 lines · Denis Plotnikov
Quoted 46 lines · Stefan Hajnoczi
Quoted 37 lines · Denis Plotnikov
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 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_maxparameter, which represents the max amount of pices in the scatter-geather list in one guest disk request.Since
seg_maxisvirqueue_sizedependent, increasing the virtqueue size increasesseg_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.htmlSuggested-by Denis V. Lunev <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- hw/block/virtio-blk.c | 4 ++-- hw/core/machine.c | 2 ++ hw/scsi/virtio-scsi.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)Quoted 11 lines
hw/block/virtio-blk.c static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config) · line 917
Quoted 10 lines
hw/block/virtio-blk.c +1
-1@@ -914,7 +914,7 @@ 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 :256 -2 );This value must not change on older machine types.
Yes, that's true, but ..
Quoted 8 lines
Quoted 3 lines
So does this patch
need to turn seg-max-adjust *on* inhw_compat_4_2so that old machine types get 126 instead of 254?If we set seg-max-adjust "on" in older machine types, the setups using them and having
queue_sizesset , for example, 1024 will also setseg_maxto 1024
- 2 which isn't the expected behavior: older mt didn't changeseg_maxin that case and stuck with 128 - 2.
So, should we, instead, leave the default 128 - 2, forseg_max?Quoted 4 lines
Argh! Good point :-).
How about a
seg_max_defaultproperty that is initialized to 254 for modern machines and 126 to old machines?Hmm, but we'll achieve the same but with more code changes, don't we? 254 is because the queue-size is 256. We gonna leave 128-2 for older machine types
just for not breaking anything. All otherseg_maxadjustment is provided byseg_max_adjustwhich is "on" by default in modern machine types.to summarize:
modern mt defaults:
seg_max_adjust= onqueue_size= 256=> default
seg_max= 254
=> changing queue-size will changeseg_max=queue_size- 2Quoted 7 lines
old mt defaults:
seg_max_adjust= offqueue_size= 128=> default
seg_max= 126
=> changing queue-size won't changeseg_max, it's always = 126 like it was beforeYou're right! The only strange case is a modern machine type with seg_max_adjust=off, where
queue_sizewill be 256 butseg_maxwill be
126. But no user would want to disableseg_max_adjust, so it's okay.I agree with you that the line of code can remain unchanged:
Quoted 8 lines
/* * Only old machine types use seg_max_adjust=off and there the default * value of queue_size is 128. */ virtio_stl_p(vdev, &blkcfg.seg_max, s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 2);Stefan
Ok, I'll resend the patch sortly
Thanks!
Denis