Commit 582b0ab2 authored by Richard W.M. Jones's avatar Richard W.M. Jones Committed by Martin K. Petersen

scsi: virtio: virtio_scsi: Set can_queue to the length of the virtqueue.

Since switching to blk-mq as the default in commit 5c279bd9
("scsi: default to scsi-mq"), virtio-scsi LUNs consume about 10x as
much kernel memory.

qemu currently allocates a fixed 128 entry virtqueue.  can_queue
currently is set to 1024.  But with indirect descriptors, each command
in the queue takes 1 virtqueue entry, so the number of commands which
can be queued is equal to the length of the virtqueue.

Note I intend to send a patch to qemu to allow the virtqueue size to be
configured from the qemu command line.
Signed-off-by: default avatarRichard W.M. Jones <rjones@redhat.com>
Acked-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 44ed8089
...@@ -818,7 +818,6 @@ static struct scsi_host_template virtscsi_host_template_single = { ...@@ -818,7 +818,6 @@ static struct scsi_host_template virtscsi_host_template_single = {
.eh_timed_out = virtscsi_eh_timed_out, .eh_timed_out = virtscsi_eh_timed_out,
.slave_alloc = virtscsi_device_alloc, .slave_alloc = virtscsi_device_alloc,
.can_queue = 1024,
.dma_boundary = UINT_MAX, .dma_boundary = UINT_MAX,
.use_clustering = ENABLE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING,
.target_alloc = virtscsi_target_alloc, .target_alloc = virtscsi_target_alloc,
...@@ -839,7 +838,6 @@ static struct scsi_host_template virtscsi_host_template_multi = { ...@@ -839,7 +838,6 @@ static struct scsi_host_template virtscsi_host_template_multi = {
.eh_timed_out = virtscsi_eh_timed_out, .eh_timed_out = virtscsi_eh_timed_out,
.slave_alloc = virtscsi_device_alloc, .slave_alloc = virtscsi_device_alloc,
.can_queue = 1024,
.dma_boundary = UINT_MAX, .dma_boundary = UINT_MAX,
.use_clustering = ENABLE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING,
.target_alloc = virtscsi_target_alloc, .target_alloc = virtscsi_target_alloc,
...@@ -972,6 +970,8 @@ static int virtscsi_probe(struct virtio_device *vdev) ...@@ -972,6 +970,8 @@ static int virtscsi_probe(struct virtio_device *vdev)
if (err) if (err)
goto virtscsi_init_failed; goto virtscsi_init_failed;
shost->can_queue = virtqueue_get_vring_size(vscsi->req_vqs[0].vq);
cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1; cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue); shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF; shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment