Skip to content

Commit 0a50ed0

Browse files
igawaxboe
authored andcommitted
virtio: blk/scsi: use block layer helpers to calculate num of queues
The calculation of the upper limit for queues does not depend solely on the number of possible CPUs; for example, the isolcpus kernel command-line option must also be considered. To account for this, the block layer provides a helper function to retrieve the maximum number of queues. Use it to set an appropriate upper queue number limit. Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 94970cf commit 0a50ed0

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/block/virtio_blk.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,8 @@ static int init_vq(struct virtio_blk *vblk)
976976
return -EINVAL;
977977
}
978978

979-
num_vqs = min_t(unsigned int,
980-
min_not_zero(num_request_queues, nr_cpu_ids),
981-
num_vqs);
979+
num_vqs = blk_mq_num_possible_queues(
980+
min_not_zero(num_request_queues, num_vqs));
982981

983982
num_poll_vqs = min_t(unsigned int, poll_queues, num_vqs - 1);
984983

drivers/scsi/virtio_scsi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ static int virtscsi_probe(struct virtio_device *vdev)
919919
/* We need to know how many queues before we allocate. */
920920
num_queues = virtscsi_config_get(vdev, num_queues) ? : 1;
921921
num_queues = min_t(unsigned int, nr_cpu_ids, num_queues);
922+
num_queues = blk_mq_num_possible_queues(num_queues);
922923

923924
num_targets = virtscsi_config_get(vdev, max_target) + 1;
924925

0 commit comments

Comments
 (0)