Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Since switching to blk-mq as the default in commit 5c279bd9e406
("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: Richard W.M. Jones <rjones@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Richard W.M. Jones and committed by
Martin K. Petersen
582b0ab2 44ed8089

+2 -2
+2 -2
drivers/scsi/virtio_scsi.c
··· 818 818 .eh_timed_out = virtscsi_eh_timed_out, 819 819 .slave_alloc = virtscsi_device_alloc, 820 820 821 - .can_queue = 1024, 822 821 .dma_boundary = UINT_MAX, 823 822 .use_clustering = ENABLE_CLUSTERING, 824 823 .target_alloc = virtscsi_target_alloc, ··· 838 839 .eh_timed_out = virtscsi_eh_timed_out, 839 840 .slave_alloc = virtscsi_device_alloc, 840 841 841 - .can_queue = 1024, 842 842 .dma_boundary = UINT_MAX, 843 843 .use_clustering = ENABLE_CLUSTERING, 844 844 .target_alloc = virtscsi_target_alloc, ··· 969 971 err = virtscsi_init(vdev, vscsi); 970 972 if (err) 971 973 goto virtscsi_init_failed; 974 + 975 + shost->can_queue = virtqueue_get_vring_size(vscsi->req_vqs[0].vq); 972 976 973 977 cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1; 974 978 shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);