From nobody Mon Nov 23 04:30:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793545895002619.9739564859327; Sun, 1 Nov 2026 07:11:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xNXD4-0002sB-Jz; Sun, 01 Nov 2026 10:11:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xNXCw-0002rj-8P for qemu-devel@nongnu.org; Sun, 01 Nov 2026 10:10:54 -0500 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1xNXCs-0003Jt-Th for qemu-devel@nongnu.org; Sun, 01 Nov 2026 10:10:53 -0500 Received: from k3-03 (unknown [159.226.43.8]) by APP-03 (Coremail) with SMTP id rQCowABXZZZwVudq7doiAA--.16850S2; Sun, 01 Nov 2026 23:10:41 +0800 (CST) From: Tan Chi To: qemu-devel@nongnu.org Cc: jasowangio@gmail.com, mst@redhat.com, Tan Chi Subject: [PATCH] hw/net/virtio-net: skip automatic zero-init of TX iovec arrays Date: Sun, 1 Nov 2026 23:10:38 +0800 Message-ID: <20261101151038.164841-1-tanchi25@mails.ucas.ac.cn> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: rQCowABXZZZwVudq7doiAA--.16850S2 X-Coremail-Antispam: 1UD129KBjvJXoWrZrWUuw1fJrWkCF4rZr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ou0/ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=159.226.251.81; envelope-from=tanchi25@mails.ucas.ac.cn; helo=cstnet.cn X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1793545904456158500 Content-Type: text/plain; charset="utf-8" virtio_net_flush_tx() has two large iovec arrays that are populated as needed. Entries are initialized explicitly or through iov_copy(), and out_num bounds the entries subsequently consumed through out_sg. Zero-initializing the entire arrays is therefore unnecessary. Similar arrays in virtio_net_receive_rcu() already use QEMU_UNINITIALIZED to avoid automatic zero-initialization overhead. Apply the same optimization to the TX path. Signed-off-by: Tan Chi --- hw/net/virtio-net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 54e42cfec9..76e3281831 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2783,7 +2783,9 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) for (;;) { ssize_t ret; unsigned int out_num; - struct iovec sg[VIRTQUEUE_MAX_SIZE], sg2[VIRTQUEUE_MAX_SIZE + 1], = *out_sg; + QEMU_UNINITIALIZED struct iovec sg[VIRTQUEUE_MAX_SIZE]; + QEMU_UNINITIALIZED struct iovec sg2[VIRTQUEUE_MAX_SIZE + 1]; + struct iovec *out_sg; struct virtio_net_hdr vhdr; =20 elem =3D virtqueue_pop(q->tx_vq, sizeof(VirtQueueElement)); --=20 2.53.0