[PATCH v7 06/10] virtio: blk/scsi: use block layer helpers to constrain queue affinity

Hannes Reinecke hare at suse.de
Wed Jul 2 23:43:41 PDT 2025


On 7/2/25 18:33, Daniel Wagner wrote:
> Ensure that IRQ affinity setup also respects the queue-to-CPU mapping
> constraints provided by the block layer. This allows the virtio drivers
> to avoid assigning interrupts to CPUs that the block layer has excluded
> (e.g., isolated CPUs).
> 
> Signed-off-by: Daniel Wagner <wagi at kernel.org>
> ---
>   drivers/block/virtio_blk.c | 4 +++-
>   drivers/scsi/virtio_scsi.c | 5 ++++-
>   2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index e649fa67bac16b4f0c6e8e8f0e6bec111897c355..41b06540c7fb22fd1d2708338c514947c4bdeefe 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -963,7 +963,9 @@ static int init_vq(struct virtio_blk *vblk)
>   	unsigned short num_vqs;
>   	unsigned short num_poll_vqs;
>   	struct virtio_device *vdev = vblk->vdev;
> -	struct irq_affinity desc = { 0, };
> +	struct irq_affinity desc = {
> +		.mask = blk_mq_possible_queue_affinity(),
> +	};
>   
>   	err = virtio_cread_feature(vdev, VIRTIO_BLK_F_MQ,
>   				   struct virtio_blk_config, num_queues,
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 96a69edddbe5555574fc8fed1ba7c82a99df4472..67dfb265bf9e54adc68978ac8d93187e6629c330 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -842,7 +842,10 @@ static int virtscsi_init(struct virtio_device *vdev,
>   	u32 num_vqs, num_poll_vqs, num_req_vqs;
>   	struct virtqueue_info *vqs_info;
>   	struct virtqueue **vqs;
> -	struct irq_affinity desc = { .pre_vectors = 2 };
> +	struct irq_affinity desc = {
> +		.pre_vectors = 2,
> +		.mask = blk_mq_possible_queue_affinity(),
> +	};
>   
>   	num_req_vqs = vscsi->num_queues;
>   	num_vqs = num_req_vqs + VIRTIO_SCSI_VQ_BASE;
> 
Reviewed-by: Hannes Reinecke <hare at suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare at suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich



More information about the Linux-nvme mailing list