diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2014-03-19 02:38:24 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2014-03-23 21:50:18 -0400 |
commit | fc4324b4597c4eb8907207e82f9a6acec84dd335 (patch) | |
tree | e26df11a67a5eb36c29d08e57467e33692308e69 /drivers/block | |
parent | b1ee30ae6ec4aa1e711bdab7e17d6c531e492294 (diff) |
virtio-blk: base queue-depth on virtqueue ringsize or module param
Venkatash spake thus:
virtio-blk set the default queue depth to 64 requests, which was
insufficient for high-IOPS devices. Instead set the blk-queue depth to
the device's virtqueue depth divided by two (each I/O requires at least
two VQ entries).
But behold, Ted added a module parameter:
Also allow the queue depth to be something which can be set at module
load time or via a kernel boot-time parameter, for
testing/benchmarking purposes.
And I rewrote it substantially, mainly to take
VIRTIO_RING_F_INDIRECT_DESC into account.
As QEMU sets the vq size for PCI to 128, Venkatash's patch wouldn't
have made a change. This version does (since QEMU also offers
VIRTIO_RING_F_INDIRECT_DESC.
Inspired-by: "Theodore Ts'o" <tytso@mit.edu>
Based-on-the-true-story-of: Venkatesh Srinivas <venkateshs@google.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtio-dev@lists.oasis-open.org
Cc: virtualization@lists.linux-foundation.org
Cc: Frank Swiderski <fes@google.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/virtio_blk.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index a2db9ed288f2..196222271a50 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -491,10 +491,11 @@ static struct blk_mq_ops virtio_mq_ops = { | |||
491 | static struct blk_mq_reg virtio_mq_reg = { | 491 | static struct blk_mq_reg virtio_mq_reg = { |
492 | .ops = &virtio_mq_ops, | 492 | .ops = &virtio_mq_ops, |
493 | .nr_hw_queues = 1, | 493 | .nr_hw_queues = 1, |
494 | .queue_depth = 64, | 494 | .queue_depth = 0, /* Set in virtblk_probe */ |
495 | .numa_node = NUMA_NO_NODE, | 495 | .numa_node = NUMA_NO_NODE, |
496 | .flags = BLK_MQ_F_SHOULD_MERGE, | 496 | .flags = BLK_MQ_F_SHOULD_MERGE, |
497 | }; | 497 | }; |
498 | module_param_named(queue_depth, virtio_mq_reg.queue_depth, uint, 0444); | ||
498 | 499 | ||
499 | static void virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, | 500 | static void virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, |
500 | struct request *rq, unsigned int nr) | 501 | struct request *rq, unsigned int nr) |
@@ -558,6 +559,13 @@ static int virtblk_probe(struct virtio_device *vdev) | |||
558 | goto out_free_vq; | 559 | goto out_free_vq; |
559 | } | 560 | } |
560 | 561 | ||
562 | /* Default queue sizing is to fill the ring. */ | ||
563 | if (!virtio_mq_reg.queue_depth) { | ||
564 | virtio_mq_reg.queue_depth = vblk->vq->num_free; | ||
565 | /* ... but without indirect descs, we use 2 descs per req */ | ||
566 | if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)) | ||
567 | virtio_mq_reg.queue_depth /= 2; | ||
568 | } | ||
561 | virtio_mq_reg.cmd_size = | 569 | virtio_mq_reg.cmd_size = |
562 | sizeof(struct virtblk_req) + | 570 | sizeof(struct virtblk_req) + |
563 | sizeof(struct scatterlist) * sg_elems; | 571 | sizeof(struct scatterlist) * sg_elems; |