Skip to content

Skip automatic zero-init of large arrays / structs in I/O paths

Daniel P. Berrangé qemu-devel 1 version Applied

Status from this message: Thanks, applied to my block tree:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest31 patches 10 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/31include/qemu/compiler: add QEMU_UNINITIALIZED attribute macroinclude/qemu/compiler.h+20 -00 replies
2/31hw/virtio/virtio: avoid cost of -ftrivial-auto-var-init in hot pathhw/virtio/virtio.c+4 -40 replies
3/31block: skip automatic zero-init of large array in ioq_submitblock/linux-aio.c+1 -10 replies
4/31chardev/char-fd: skip automatic zero-init of large arraychardev/char-fd.c+1 -10 replies
5/31chardev/char-pty: skip automatic zero-init of large arraychardev/char-pty.c+1 -10 replies
6/31chardev/char-socket: skip automatic zero-init of large arraychardev/char-socket.c+1 -10 replies
7/31hw/audio/ac97: skip automatic zero-init of large arrayshw/audio/ac97.c+2 -20 replies
8/31hw/audio/cs4231a: skip automatic zero-init of large arrayshw/audio/cs4231a.c+2 -20 replies
9/31hw/audio/es1370: skip automatic zero-init of large arrayhw/audio/es1370.c+1 -10 replies
10/31hw/audio/gus: skip automatic zero-init of large arrayhw/audio/gus.c+1 -10 replies
11/31hw/audio/gus: skip automatic zero-init of large arrayhw/audio/marvell_88w8618.c+1 -11 reply
12/31hw/audio/sb16: skip automatic zero-init of large arrayhw/audio/sb16.c+1 -10 replies
13/31hw/audio/via-ac97: skip automatic zero-init of large arrayhw/audio/via-ac97.c+1 -10 replies
14/31hw/char/sclpconsole-lm: skip automatic zero-init of large arrayhw/char/sclpconsole-lm.c+1 -10 replies
15/31hw/dma/xlnx_csu_dma: skip automatic zero-init of large arrayhw/dma/xlnx_csu_dma.c+1 -10 replies
16/31hw/display/vmware_vga: skip automatic zero-init of large structhw/display/vmware_vga.c+1 -10 replies
17/31hw/hyperv/syndbg: skip automatic zero-init of large arrayhw/hyperv/syndbg.c+1 -10 replies
18/31hw/misc/aspeed_hace: skip automatic zero-init of large arrayhw/misc/aspeed_hace.c+1 -10 replies
19/31hw/net/rtl8139: skip automatic zero-init of large arrayhw/net/rtl8139.c+1 -10 replies
20/31hw/net/tulip: skip automatic zero-init of large arrayhw/net/tulip.c+1 -10 replies
21/31hw/net/virtio-net: skip automatic zero-init of large arrayshw/net/virtio-net.c+3 -30 replies
22/31hw/net/xgamc: skip automatic zero-init of large arrayhw/net/xgmac.c+1 -10 replies
23/31hw/nvme/ctrl: skip automatic zero-init of large arrayshw/nvme/ctrl.c+3 -31 reply
24/31hw/ppc/pnv_occ: skip automatic zero-init of large structhw/ppc/pnv_occ.c+1 -11 reply
25/31hw/ppc/spapr_tpm_proxy: skip automatic zero-init of large arrayshw/ppc/spapr_tpm_proxy.c+2 -21 reply
26/31hw/usb/hcd-ohci: skip automatic zero-init of large arrayhw/usb/hcd-ohci.c+1 -10 replies
27/31hw/scsi/lsi53c895a: skip automatic zero-init of large arrayhw/scsi/lsi53c895a.c+1 -10 replies
28/31hw/scsi/megasas: skip automatic zero-init of large arrayshw/scsi/megasas.c+2 -50 replies
29/31hw/ufs/lu: skip automatic zero-init of large arrayhw/ufs/lu.c+1 -10 replies
30/31net/socket: skip automatic zero-init of large arraynet/socket.c+1 -10 replies
31/31net/stream: skip automatic zero-init of large arraynet/stream.c+1 -10 replies

Reviews trailers per patch

3 of 31 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchStefan HajnocziKlaus JensenHarsh Prateek Bora
SeriesR-b
1/31
2/31
3/31
4/31
5/31
6/31
7/31
8/31
9/31
10/31
11/31
12/31
13/31
14/31
15/31
16/31
17/31
18/31
19/31
20/31
21/31
22/31
23/31R-b
24/31R-b
25/31R-b
26/31
27/31
28/31
29/31
30/31
31/31

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/31] Skip automatic zero-init of large arrays / structs in I/O paths

This series is an extension of Stefan's proposal:

https://lists.nongnu.org/archive/html/qemu-devel/2025-06/msg00736.html

It used '-Wframe-larger-than=4096' to identify all code locations with more than 4k on the stack. Any locations in the I/O paths were chosen to avoid automatic zero-init, to eliminate the performance overhead of the automatic initialization.

Note, although all the changed locations are I/O paths, this does not imply that the changes make a measurement performance difference in every case.

This is because many of the emulated devices are likely limited by the emulation impl, rather than any implicit memory zero'ing overhead of stack data.

None the less the memory zero'ing is still a redundant CPU burn in all these cases, so I felt it worth setting the general precedent that any data over 4k on a stack in a device I/O path should be skipping zero-init.

I did reasonable review in each case to identify that the data was indeed initialized explicitly later in the method.

Daniel P. Berrangé (29):
block: skip automatic zero-init of large array in ioq_submit chardev/char-fd: skip automatic zero-init of large array chardev/char-pty: skip automatic zero-init of large array chardev/char-socket: skip automatic zero-init of large array hw/audio/ac97: skip automatic zero-init of large arrays hw/audio/cs4231a: skip automatic zero-init of large arrays hw/audio/es1370: skip automatic zero-init of large array hw/audio/gus: skip automatic zero-init of large array hw/audio/gus: skip automatic zero-init of large array hw/audio/sb16: skip automatic zero-init of large array hw/audio/via-ac97: skip automatic zero-init of large array hw/char/sclpconsole-lm: skip automatic zero-init of large array hw/dma/xlnx_csu_dma: skip automatic zero-init of large array hw/display/vmware_vga: skip automatic zero-init of large struct hw/hyperv/syndbg: skip automatic zero-init of large array hw/misc/aspeed_hace: skip automatic zero-init of large array hw/net/rtl8139: skip automatic zero-init of large array hw/net/tulip: skip automatic zero-init of large array hw/net/virtio-net: skip automatic zero-init of large arrays hw/net/xgamc: skip automatic zero-init of large array hw/nvme/ctrl: skip automatic zero-init of large arrays hw/ppc/pnv_occ: skip automatic zero-init of large struct hw/ppc/spapr_tpm_proxy: skip automatic zero-init of large arrays hw/usb/hcd-ohci: skip automatic zero-init of large array hw/scsi/lsi53c895a: skip automatic zero-init of large array hw/scsi/megasas: skip automatic zero-init of large arrays hw/ufs/lu: skip automatic zero-init of large array net/socket: skip automatic zero-init of large array net/stream: skip automatic zero-init of large array

Stefan Hajnoczi (2):
include/qemu/compiler: add QEMU_UNINITIALIZED attribute macro hw/virtio/virtio: avoid cost of -ftrivial-auto-var-init in hot path

 block/linux-aio.c          |  2 +-
 chardev/char-fd.c          |  2 +-
 chardev/char-pty.c         |  2 +-
 chardev/char-socket.c      |  2 +-
 hw/audio/ac97.c            |  4 ++--
 hw/audio/cs4231a.c         |  4 ++--
 hw/audio/es1370.c          |  2 +-
 hw/audio/gus.c             |  2 +-
 hw/audio/marvell_88w8618.c |  2 +-
 hw/audio/sb16.c            |  2 +-
 hw/audio/via-ac97.c        |  2 +-
 hw/char/sclpconsole-lm.c   |  2 +-
 hw/display/vmware_vga.c    |  2 +-
 hw/dma/xlnx_csu_dma.c      |  2 +-
 hw/hyperv/syndbg.c         |  2 +-
 hw/misc/aspeed_hace.c      |  2 +-
 hw/net/rtl8139.c           |  2 +-
 hw/net/tulip.c             |  2 +-
 hw/net/virtio-net.c        |  6 +++---
 hw/net/xgmac.c             |  2 +-
 hw/nvme/ctrl.c             |  6 +++---
 hw/ppc/pnv_occ.c           |  2 +-
 hw/ppc/spapr_tpm_proxy.c   |  4 ++--
 hw/scsi/lsi53c895a.c       |  2 +-
 hw/scsi/megasas.c          |  7 ++-----
 hw/ufs/lu.c                |  2 +-
 hw/usb/hcd-ohci.c          |  2 +-
 hw/virtio/virtio.c         |  8 ++++----
 include/qemu/compiler.h    | 20 ++++++++++++++++++++
 net/socket.c               |  2 +-
 net/stream.c               |  2 +-
 31 files changed, 61 insertions(+), 44 deletions(-)
Signature · 1 line
2.49.0