From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=glOkjuEB; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 7CDA15A065C for ; Mon, 15 Dec 2025 13:40:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765802416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=790O5OxmleRR8j6eRQNDV7NaYi+qIl/uURCite3cc5o=; b=glOkjuEBaB00+fF7QGo1iI2ZkQvOKA4316KIMM7X0uazekUTfWJguI2ziKs8assK6ej3EG K3+WELJgOilboXcIQnbtGuVPoLmTK/s1GDBxeI0iwcXcpqcqtVxMHRf8HKJwWS7hZIQERB iZFJIH7Xaavin6bWvBUtbO2EAcGs8/g= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-0sTYJuZsMDyrMR5ps7gZVQ-1; Mon, 15 Dec 2025 07:40:15 -0500 X-MC-Unique: 0sTYJuZsMDyrMR5ps7gZVQ-1 X-Mimecast-MFC-AGG-ID: 0sTYJuZsMDyrMR5ps7gZVQ_1765802414 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F9DC18002DE; Mon, 15 Dec 2025 12:40:14 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.44.34.89]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF025180044F; Mon, 15 Dec 2025 12:40:12 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v4 2/6] vhost-user: Enable multiqueue Date: Mon, 15 Dec 2025 13:40:03 +0100 Message-ID: <20251215124007.1549660-3-lvivier@redhat.com> In-Reply-To: <20251215124007.1549660-1-lvivier@redhat.com> References: <20251215124007.1549660-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: EHjYwMDiKNUuotxLRR_9PObiwUvKBCJvtGG08_hbx-8_1765802414 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 4FPP5YQ5PHPXYGWFONEEEJEHM23V6ZAU X-Message-ID-Hash: 4FPP5YQ5PHPXYGWFONEEEJEHM23V6ZAU X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Advertise multi-queue support in vhost-user by setting VIRTIO_NET_F_MQ and VHOST_USER_PROTOCOL_F_MQ feature flags, and increase VHOST_USER_MAX_VQS from 2 to 32, supporting up to 16 queue pairs. Currently, only the first RX queue (queue 0) is used for receiving packets. The guest kernel selects which TX queue to use for transmission. Full multi-RX queue load balancing will be implemented in future work. Update the QEMU usage hint to show the required parameters for enabling multiqueue: queues parameter on the netdev, and mq=true on the virtio-net device. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- tap.c | 7 +++++-- vhost_user.c | 10 ++++++---- virtio.h | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tap.c b/tap.c index 62e2faa77675..f80183d95a4e 100644 --- a/tap.c +++ b/tap.c @@ -1323,8 +1323,11 @@ static void tap_backend_show_hints(struct ctx *c) break; case MODE_VU: info("You can start qemu with:"); - info(" kvm ... -chardev socket,id=chr0,path=%s -netdev vhost-user,id=netdev0,chardev=chr0 -device virtio-net,netdev=netdev0 -object memory-backend-memfd,id=memfd0,share=on,size=$RAMSIZE -numa node,memdev=memfd0\n", - c->sock_path); + info(" kvm ... -chardev socket,id=chr0,path=%s " + "-netdev vhost-user,id=netdev0,chardev=chr0,queues=$QUEUES " + "-device virtio-net,netdev=netdev0,mq=true " + "-object memory-backend-memfd,id=memfd0,share=on,size=$RAMSIZE " + "-numa node,memdev=memfd0\n", c->sock_path); break; } } diff --git a/vhost_user.c b/vhost_user.c index aa7c869d9e56..772ba97759d9 100644 --- a/vhost_user.c +++ b/vhost_user.c @@ -323,6 +323,7 @@ static bool vu_get_features_exec(struct vu_dev *vdev, uint64_t features = 1ULL << VIRTIO_F_VERSION_1 | 1ULL << VIRTIO_NET_F_MRG_RXBUF | + 1ULL << VIRTIO_NET_F_MQ | 1ULL << VHOST_F_LOG_ALL | 1ULL << VHOST_USER_F_PROTOCOL_FEATURES; @@ -767,7 +768,8 @@ static void vu_check_queue_msg_file(struct vhost_user_msg *vmsg) int idx = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; if (idx >= VHOST_USER_MAX_VQS) - die("Invalid vhost-user queue index: %u", idx); + die("Invalid vhost-user queue index: %u (maximum %u)", idx, + VHOST_USER_MAX_VQS); if (nofd) { vmsg_close_fds(vmsg); @@ -896,7 +898,8 @@ static bool vu_get_protocol_features_exec(struct vu_dev *vdev, uint64_t features = 1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | 1ULL << VHOST_USER_PROTOCOL_F_DEVICE_STATE | - 1ULL << VHOST_USER_PROTOCOL_F_RARP; + 1ULL << VHOST_USER_PROTOCOL_F_RARP | + 1ULL << VHOST_USER_PROTOCOL_F_MQ; (void)vdev; vmsg_set_reply_u64(vmsg, features); @@ -935,10 +938,9 @@ static bool vu_get_queue_num_exec(struct vu_dev *vdev, { (void)vdev; - /* NOLINTNEXTLINE(misc-redundant-expression) */ vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_VQS / 2); - debug("VHOST_USER_MAX_VQS %u", VHOST_USER_MAX_VQS / 2); + debug("Using up to %u vhost-user queue pairs", VHOST_USER_MAX_VQS / 2); return true; } diff --git a/virtio.h b/virtio.h index 12caaa0b6def..176c935cecc7 100644 --- a/virtio.h +++ b/virtio.h @@ -88,7 +88,7 @@ struct vu_dev_region { uint64_t mmap_addr; }; -#define VHOST_USER_MAX_VQS 2 +#define VHOST_USER_MAX_VQS 32 /* * Set a reasonable maximum number of ram slots, which will be supported by -- 2.51.1