55 lines
2.2 KiB
Diff
55 lines
2.2 KiB
Diff
From 9ecc539204dd6ab7a1124089f9e557248e321282 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
|
Date: Tue, 10 Jun 2025 13:36:59 +0100
|
|
Subject: [PATCH 22/31] hw/net/virtio-net: skip automatic zero-init of large
|
|
arrays
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
|
RH-MergeRequest: 461: Solve -ftrivial-auto-var-init performance regression with QEMU_UNINITIALIZED
|
|
RH-Jira: RHEL-99887
|
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
RH-Commit: [21/30] f093a50cc162bd376fd74ea47c6274d7e718ba69
|
|
|
|
The 'virtio_net_receive_rcu' method has three arrays with
|
|
VIRTQUEUE_MAX_SIZE elements, which are apprixmately 32k in
|
|
size used for copying data between guest and host. Skip the
|
|
automatic zero-init of these arrays to eliminate the
|
|
performance overhead in the I/O hot path.
|
|
|
|
The three arrays will be selectively initialized as required
|
|
when processing network buffers.
|
|
|
|
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
Message-id: 20250610123709.835102-22-berrange@redhat.com
|
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
(cherry picked from commit 21cf31c51a7aeff4270c9b30b37e019c536d54b2)
|
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
---
|
|
hw/net/virtio-net.c | 6 +++---
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
|
|
index 3d2b2460ad..086ea20ea0 100644
|
|
--- a/hw/net/virtio-net.c
|
|
+++ b/hw/net/virtio-net.c
|
|
@@ -1895,9 +1895,9 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,
|
|
VirtIONet *n = qemu_get_nic_opaque(nc);
|
|
VirtIONetQueue *q = virtio_net_get_subqueue(nc);
|
|
VirtIODevice *vdev = VIRTIO_DEVICE(n);
|
|
- VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE];
|
|
- size_t lens[VIRTQUEUE_MAX_SIZE];
|
|
- struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
|
|
+ QEMU_UNINITIALIZED VirtQueueElement *elems[VIRTQUEUE_MAX_SIZE];
|
|
+ QEMU_UNINITIALIZED size_t lens[VIRTQUEUE_MAX_SIZE];
|
|
+ QEMU_UNINITIALIZED struct iovec mhdr_sg[VIRTQUEUE_MAX_SIZE];
|
|
struct virtio_net_hdr_v1_hash extra_hdr;
|
|
unsigned mhdr_cnt = 0;
|
|
size_t offset, i, guest_offset, j;
|
|
--
|
|
2.39.3
|
|
|