diff options
| author | Ilya Maximets <i.maximets@ovn.org> | 2023-08-11 16:34:23 +0200 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2023-10-04 04:54:15 -0400 |
| commit | 43d6376980d5567f2a6d00cfb30d10c0961671e6 (patch) | |
| tree | 894ee07bbeba05676b153513f02426de97f64ca6 /include/exec/memory.h | |
| parent | e213c45a042db2506b5e8f16293f1f1c5083a577 (diff) | |
| download | focaccia-qemu-43d6376980d5567f2a6d00cfb30d10c0961671e6.tar.gz focaccia-qemu-43d6376980d5567f2a6d00cfb30d10c0961671e6.zip | |
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>
Diffstat (limited to 'include/exec/memory.h')
| -rw-r--r-- | include/exec/memory.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/exec/memory.h b/include/exec/memory.h index ef23d65afc..c99842d2fc 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2671,9 +2671,6 @@ struct MemoryRegionCache { bool is_write; }; -#define MEMORY_REGION_CACHE_INVALID ((MemoryRegionCache) { .mrs.mr = NULL }) - - /* address_space_ld*_cached: load from a cached #MemoryRegion * address_space_st*_cached: store into a cached #MemoryRegion * @@ -2763,6 +2760,19 @@ int64_t address_space_cache_init(MemoryRegionCache *cache, bool is_write); /** + * address_space_cache_init_empty: Initialize empty #MemoryRegionCache + * + * @cache: The #MemoryRegionCache to operate on. + * + * Initializes #MemoryRegionCache structure without memory region attached. + * Cache initialized this way can only be safely destroyed, but not used. + */ +static inline void address_space_cache_init_empty(MemoryRegionCache *cache) +{ + cache->mrs.mr = NULL; +} + +/** * address_space_cache_invalidate: complete a write to a #MemoryRegionCache * * @cache: The #MemoryRegionCache to operate on. |