qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Hajnoczi
Subject: Re: [PATCH v1 1/4] virtio: introduce VIRTQUEUE_DEFUALT_SIZE instead of hardcoded constants
Date: Thu, 30 Jan 2020 14:56:13 +0000

On Wed, Jan 29, 2020 at 06:55:18PM +0100, Cornelia Huck wrote:
> On Wed, 29 Jan 2020 17:06:59 +0300
> Denis Plotnikov <address@hidden> wrote:
> 
> > Signed-off-by: Denis Plotnikov <address@hidden>
> > ---
> >  hw/block/virtio-blk.c      | 6 ++++--
> >  hw/scsi/virtio-scsi.c      | 5 +++--
> >  include/hw/virtio/virtio.h | 1 +
> >  3 files changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> > index 09f46ed85f..72f935033f 100644
> > --- a/hw/block/virtio-blk.c
> > +++ b/hw/block/virtio-blk.c
> > @@ -914,7 +914,8 @@ static void virtio_blk_update_config(VirtIODevice 
> > *vdev, uint8_t *config)
> >      memset(&blkcfg, 0, sizeof(blkcfg));
> >      virtio_stq_p(vdev, &blkcfg.capacity, capacity);
> >      virtio_stl_p(vdev, &blkcfg.seg_max,
> > -                 s->conf.seg_max_adjust ? s->conf.queue_size - 2 : 128 - 
> > 2);
> > +                 s->conf.seg_max_adjust ? s->conf.queue_size - 2 :
> > +                                          VIRTQUEUE_DEFAULT_SIZE - 2);
> >      virtio_stw_p(vdev, &blkcfg.geometry.cylinders, conf->cyls);
> >      virtio_stl_p(vdev, &blkcfg.blk_size, blk_size);
> >      virtio_stw_p(vdev, &blkcfg.min_io_size, conf->min_io_size / blk_size);
> > @@ -1272,7 +1273,8 @@ static Property virtio_blk_properties[] = {
> >      DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, 
> > 0,
> >                      true),
> >      DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1),
> > -    DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size, 128),
> > +    DEFINE_PROP_UINT16("queue-size", VirtIOBlock, conf.queue_size,
> > +                       VIRTQUEUE_DEFAULT_SIZE),
> >      DEFINE_PROP_BOOL("seg-max-adjust", VirtIOBlock, conf.seg_max_adjust, 
> > true),
> >      DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD,
> >                       IOThread *),
> > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> > index 3b61563609..36f66046ae 100644
> > --- a/hw/scsi/virtio-scsi.c
> > +++ b/hw/scsi/virtio-scsi.c
> > @@ -660,7 +660,8 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
> >  
> >      virtio_stl_p(vdev, &scsiconf->num_queues, s->conf.num_queues);
> >      virtio_stl_p(vdev, &scsiconf->seg_max,
> > -                 s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 : 128 
> > - 2);
> > +                 s->conf.seg_max_adjust ? s->conf.virtqueue_size - 2 :
> > +                                          VIRTQUEUE_DEFAULT_SIZE - 2);
> >      virtio_stl_p(vdev, &scsiconf->max_sectors, s->conf.max_sectors);
> >      virtio_stl_p(vdev, &scsiconf->cmd_per_lun, s->conf.cmd_per_lun);
> >      virtio_stl_p(vdev, &scsiconf->event_info_size, 
> > sizeof(VirtIOSCSIEvent));
> > @@ -965,7 +966,7 @@ static void virtio_scsi_device_unrealize(DeviceState 
> > *dev, Error **errp)
> >  static Property virtio_scsi_properties[] = {
> >      DEFINE_PROP_UINT32("num_queues", VirtIOSCSI, 
> > parent_obj.conf.num_queues, 1),
> >      DEFINE_PROP_UINT32("virtqueue_size", VirtIOSCSI,
> > -                                         parent_obj.conf.virtqueue_size, 
> > 128),
> > +                       parent_obj.conf.virtqueue_size, 
> > VIRTQUEUE_DEFAULT_SIZE),
> >      DEFINE_PROP_BOOL("seg_max_adjust", VirtIOSCSI,
> >                        parent_obj.conf.seg_max_adjust, true),
> >      DEFINE_PROP_UINT32("max_sectors", VirtIOSCSI, 
> > parent_obj.conf.max_sectors,
> > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> > index b69d517496..a66ea2368b 100644
> > --- a/include/hw/virtio/virtio.h
> > +++ b/include/hw/virtio/virtio.h
> > @@ -48,6 +48,7 @@ size_t virtio_feature_get_config_size(VirtIOFeature 
> > *features,
> >  typedef struct VirtQueue VirtQueue;
> >  
> >  #define VIRTQUEUE_MAX_SIZE 1024
> > +#define VIRTQUEUE_DEFAULT_SIZE 128
> 
> 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.

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

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]