From 1dbdcc30075e480b1d6da9ef19a8bd38e1762ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Tue, 10 Jun 2025 13:36:44 +0100 Subject: [PATCH 14/43] chardev/char-socket: skip automatic zero-init of large array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Stefan Hajnoczi RH-MergeRequest: 381: Solve -ftrivial-auto-var-init performance regression with QEMU_UNINITIALIZED RH-Jira: RHEL-95479 RH-Acked-by: Miroslav Rezanina RH-Commit: [6/31] 97ec8420f5a8cc37d5ece5721d409e9d94f8b11f (stefanha/centos-stream-qemu-kvm) The 'tcp_chr_read' method has a 4k byte array used for copying data between the socket and device. Skip the automatic zero-init of this array to eliminate the performance overhead in the I/O hot path. The 'buf' array will be fully initialized when reading data off the network socket. Signed-off-by: Daniel P. Berrangé Reviewed-by: Stefan Hajnoczi Message-id: 20250610123709.835102-7-berrange@redhat.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit 9a23075cef1ac6e73a95a489ac72f41c573ceb9b) Signed-off-by: Stefan Hajnoczi --- chardev/char-socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 2f842f9f88..22c87d0885 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -497,7 +497,7 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) { Chardev *chr = CHARDEV(opaque); SocketChardev *s = SOCKET_CHARDEV(opaque); - uint8_t buf[CHR_READ_BUF_LEN]; + QEMU_UNINITIALIZED uint8_t buf[CHR_READ_BUF_LEN]; int len, size; if ((s->state != TCP_CHARDEV_STATE_CONNECTED) || -- 2.39.3