public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 4/6] fix #4295 : virtio-(blk|scsi): enable multiqueue by default
Date: Thu,  9 Mar 2023 09:52:15 +0100	[thread overview]
Message-ID: <20230309085217.3649203-5-aderumier@odiso.com> (raw)
In-Reply-To: <20230309085217.3649203-1-aderumier@odiso.com>

set num_queues = maxcpus for qemu 8.0

redhat already done it in rhev since 2021
https://bugzilla.redhat.com/show_bug.cgi?id=1827722#c11

The -device virtio-blk,num-queues= and -device virtio-scsi,num_queues= parameters control how many virtqueues are available to the guest. Allocating one virtqueue per vCPU improves performance as follows:
Interrupts are handled on the vCPU that submitted the request, avoiding IPIs
The I/O scheduler is automatically set to “none” by the Linux block layer

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/QemuServer.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b49b59b..39d30e3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1505,7 +1505,14 @@ sub print_drivedevice_full {
 	my $pciaddr = print_pci_addr("$drive_id", $bridges, $arch, $machine_type);
 	$device = "virtio-blk-pci,drive=drive-$drive_id,id=${drive_id}${pciaddr}";
 	$device .= ",iothread=iothread-$drive_id" if $drive->{iothread};
+
+	my $machine_version = extract_version($machine_type, kvm_user_version());
+	if (min_version($machine_version, 8, 0)) {
+	    my ($sockets, $cores, $maxcpus) = get_cpu_topology($conf);
+	    $drive->{queues} = $maxcpus if !$drive->{queues};
+	}
 	$device .= ",num-queues=$drive->{queues}" if $drive->{queues};
+
     } elsif ($drive->{interface} eq 'scsi') {
 
 	my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive);
@@ -4043,6 +4050,12 @@ sub config_to_command {
 		);
 	    }
 
+	    if (min_version($machine_version, 8, 0)) {
+		my ($sockets, $cores, $maxcpus) = get_cpu_topology($conf);
+		$drive->{queues} = $maxcpus if !$drive->{queues};
+
+	    }
+
 	    my $queues = '';
 	    if($conf->{scsihw} && $conf->{scsihw} eq "virtio-scsi-single" && $drive->{queues}){
 		$queues = ",num_queues=$drive->{queues}";
@@ -4306,6 +4319,12 @@ sub vm_deviceplug {
 	    $devicefull .= ",iothread=iothread-$deviceid";
 	}
 
+	my $machine_version = PVE::QemuServer::Machine::extract_version($machine_type);
+	if (min_version($machine_version, 8, 0)) {
+	    my ($sockets, $cores, $maxcpus) = get_cpu_topology($conf);
+	    $device->{queues} = $maxcpus if !$device->{queues};
+	}
+
 	if($deviceid =~ m/^virtioscsi(\d+)$/ && $device->{queues}) {
 	    $devicefull .= ",num_queues=$device->{queues}";
 	}
-- 
2.30.2




  parent reply	other threads:[~2023-03-09  8:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  8:52 [pve-devel] [PATCH qemu-server 0/6] improve virtio drive multiqueues Alexandre Derumier
2023-03-09  8:52 ` [pve-devel] [PATCH qemu-server 1/6] add virtio-scsi && virtio-scsi-single tests Alexandre Derumier
2023-03-09  8:52 ` [pve-devel] [PATCH qemu-server 2/6] virtio-blk: add queues option Alexandre Derumier
2023-03-09  8:52 ` [pve-devel] [PATCH qemu-server 3/6] cpuconfig: add get_cpu_topology helper Alexandre Derumier
2023-03-09  8:52 ` Alexandre Derumier [this message]
2023-03-09  8:52 ` [pve-devel] [PATCH qemu-server 5/6] drive: allow minimum queues = 1 Alexandre Derumier
2023-03-09  8:52 ` [pve-devel] [PATCH qemu-server 6/6] add virtio-blk|scsi default multiqueue tests Alexandre Derumier

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=20230309085217.3649203-5-aderumier@odiso.com \
    --to=aderumier@odiso.com \
    --cc=pve-devel@lists.proxmox.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal