virtio: don't zero out memory region cache for indirect descriptors
authorIlya Maximets <i.maximets@ovn.org>
Fri, 11 Aug 2023 14:34:23 +0000 (16:34 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 4 Oct 2023 08:54:15 +0000 (04:54 -0400)
commit43d6376980d5567f2a6d00cfb30d10c0961671e6
tree894ee07bbeba05676b153513f02426de97f64ca6
parente213c45a042db2506b5e8f16293f1f1c5083a577
virtio: don't zero out memory region cache for indirect descriptors

Lots of virtio functions that are on a hot path in data transmission
are initializing indirect descriptor cache at the point of stack
allocation.  It's a 112 byte structure that is getting zeroed out on
each call adding unnecessary overhead.  It's going to be correctly
initialized later via special init function.  The only reason to
actually initialize right away is the ability to safely destruct it.
Replacing a designated initializer with a function to only initialize
what is necessary.

Removal of the unnecessary stack initializations improves throughput
of virtio-net devices in terms of 64B packets per second by 6-14 %
depending on the case.  Tested with a proposed af-xdp network backend
and a dpdk testpmd application in the guest, but should be beneficial
for other virtio devices as well.

Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Message-Id: <20230811143423.3258788-1-i.maximets@ovn.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/virtio.c
include/exec/memory.h