virtio_blk: use virtio IRQ affinity
Use automatic IRQ affinity assignment in the virtio layer if available, and build the blk-mq queues based on it. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
73473427bb
commit
ad71473d9c
|
@ -5,6 +5,7 @@
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/interrupt.h>
|
||||||
#include <linux/virtio.h>
|
#include <linux/virtio.h>
|
||||||
#include <linux/virtio_blk.h>
|
#include <linux/virtio_blk.h>
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
#include <scsi/scsi_cmnd.h>
|
#include <scsi/scsi_cmnd.h>
|
||||||
#include <linux/idr.h>
|
#include <linux/idr.h>
|
||||||
#include <linux/blk-mq.h>
|
#include <linux/blk-mq.h>
|
||||||
|
#include <linux/blk-mq-virtio.h>
|
||||||
#include <linux/numa.h>
|
#include <linux/numa.h>
|
||||||
|
|
||||||
#define PART_BITS 4
|
#define PART_BITS 4
|
||||||
|
@ -385,6 +387,7 @@ static int init_vq(struct virtio_blk *vblk)
|
||||||
struct virtqueue **vqs;
|
struct virtqueue **vqs;
|
||||||
unsigned short num_vqs;
|
unsigned short num_vqs;
|
||||||
struct virtio_device *vdev = vblk->vdev;
|
struct virtio_device *vdev = vblk->vdev;
|
||||||
|
struct irq_affinity desc = { 0, };
|
||||||
|
|
||||||
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_MQ,
|
err = virtio_cread_feature(vdev, VIRTIO_BLK_F_MQ,
|
||||||
struct virtio_blk_config, num_queues,
|
struct virtio_blk_config, num_queues,
|
||||||
|
@ -412,7 +415,7 @@ static int init_vq(struct virtio_blk *vblk)
|
||||||
|
|
||||||
/* Discover virtqueues and write information to configuration. */
|
/* Discover virtqueues and write information to configuration. */
|
||||||
err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names,
|
err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names,
|
||||||
NULL);
|
&desc);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -543,10 +546,18 @@ static int virtblk_init_request(void *data, struct request *rq,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int virtblk_map_queues(struct blk_mq_tag_set *set)
|
||||||
|
{
|
||||||
|
struct virtio_blk *vblk = set->driver_data;
|
||||||
|
|
||||||
|
return blk_mq_virtio_map_queues(set, vblk->vdev, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static struct blk_mq_ops virtio_mq_ops = {
|
static struct blk_mq_ops virtio_mq_ops = {
|
||||||
.queue_rq = virtio_queue_rq,
|
.queue_rq = virtio_queue_rq,
|
||||||
.complete = virtblk_request_done,
|
.complete = virtblk_request_done,
|
||||||
.init_request = virtblk_init_request,
|
.init_request = virtblk_init_request,
|
||||||
|
.map_queues = virtblk_map_queues,
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int virtblk_queue_depth;
|
static unsigned int virtblk_queue_depth;
|
||||||
|
|
Loading…
Reference in New Issue