All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Liu, Changcheng" <jerrliu@nvidia.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: pbonzini@redhat.com, virtualization@lists.linux.dev,
	changcheng.liu@aliyun.com
Subject: [PATCH v2] virtio_blk: add use_irq_affinity module parameter
Date: Sat, 15 Aug 2026 00:14:56 +0800	[thread overview]
Message-ID: <an8/AKBnqAAa6y7M@yokbvdiprd370.nvidia.com> (raw)
In-Reply-To: <CAJSP0QU0Ys6Kb+hbftW1CaWT9pyZ31VzUJfTYmVZGqHGubgsXw@mail.gmail.com>

When many virtio-blk devices are present, managed IRQ reservations
can exhaust the per-CPU interrupt vector space and cause probe to
fail with -ENOSPC:

  virtio_blk virtioNNN: probe with driver virtio_blk failed with error -28

On x86, the affinity masks of the managed request-queue interrupts
collectively cover the possible CPUs. irq_matrix_reserve_managed()
therefore reserves one vector slot per possible CPU for each device,
even when the device has far fewer queues than CPUs. Once a CPU's
vector space is exhausted, further managed reservations fail.

Add use_irq_affinity, defaulting to true to keep existing behavior.
Setting it to false makes the request-queue interrupts unmanaged, so
each interrupt consumes a vector on only one CPU. The vector allocator
places each unmanaged interrupt on the least-loaded CPU, allowing the
interrupts to be spread across CPUs.

For example, the reported 64-CPU system used one request queue per
device, so each device needs two interrupts (config-change and
request queue). With managed affinity disabled, 800 devices consume
about 800 * 2 / 64 = 25 vector slots per CPU. This stays well below
the per-CPU vector limit and allows more devices to probe.

Signed-off-by: Liu, Changcheng <jerrliu@nvidia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 32bf3ba07a9d..184f1c1f4485 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -41,6 +41,11 @@ static unsigned int poll_queues;
 module_param(poll_queues, uint, 0644);
 MODULE_PARM_DESC(poll_queues, "The number of dedicated virtqueues for polling I/O");
 
+static bool use_irq_affinity = true;
+module_param(use_irq_affinity, bool, 0644);
+MODULE_PARM_DESC(use_irq_affinity,
+		 "Use managed IRQ affinity for virtqueues (default: true)");
+
 static int major;
 static DEFINE_IDA(vd_index_ida);
 
@@ -1016,7 +1021,8 @@ static int init_vq(struct virtio_blk *vblk)
 	}
 
 	/* Discover virtqueues and write information to configuration.  */
-	err = virtio_find_vqs(vdev, num_vqs, vqs, vqs_info, &desc);
+	err = virtio_find_vqs(vdev, num_vqs, vqs, vqs_info,
+			      use_irq_affinity ? &desc : NULL);
 	if (err)
 		goto out;
 
-- 
2.43.7


      reply	other threads:[~2026-08-14 16:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01  6:21 [PATCH] virtio_blk: add use_irq_affinity module parameter Liu, Changcheng
2026-08-05 17:45 ` Stefan Hajnoczi
2026-08-06  2:40   ` Liu, Changcheng
2026-08-11 14:37     ` Stefan Hajnoczi
2026-08-12  2:25       ` Liu, Changcheng
2026-08-13 17:33         ` Stefan Hajnoczi
2026-08-14 16:14           ` Liu, Changcheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=an8/AKBnqAAa6y7M@yokbvdiprd370.nvidia.com \
    --to=jerrliu@nvidia.com \
    --cc=changcheng.liu@aliyun.com \
    --cc=pbonzini@redhat.com \
    --cc=stefanha@gmail.com \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.