[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/41] include/hw/qdev-properties: Shrink struct Property
From: |
Paolo Bonzini |
Subject: |
[PULL 21/41] include/hw/qdev-properties: Shrink struct Property |
Date: |
Thu, 19 Dec 2024 09:32:08 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
Before, via pahole:
arm32, a 32-bit host which aligns uint64_t:
struct Property {
const char * name; /* 0 4 */
const PropertyInfo * info; /* 4 4 */
ptrdiff_t offset; /* 8 4 */
uint8_t bitnr; /* 12 1 */
/* XXX 3 bytes hole, try to pack */
uint64_t bitmask; /* 16 8 */
_Bool set_default; /* 24 1 */
/* XXX 7 bytes hole, try to pack */
union {
int64_t i; /* 32 8 */
uint64_t u; /* 32 8 */
} defval; /* 32 8 */
int arrayoffset; /* 40 4 */
const PropertyInfo * arrayinfo; /* 44 4 */
int arrayfieldsize; /* 48 4 */
const char * link_type; /* 52 4 */
/* size: 56, cachelines: 1, members: 11 */
/* sum members: 46, holes: 2, sum holes: 10 */
};
arm64, an arbitrary 64-bit host:
struct Property {
const char * name; /* 0 8 */
const PropertyInfo * info; /* 8 8 */
ptrdiff_t offset; /* 16 8 */
uint8_t bitnr; /* 24 1 */
/* XXX 7 bytes hole, try to pack */
uint64_t bitmask; /* 32 8 */
_Bool set_default; /* 40 1 */
/* XXX 7 bytes hole, try to pack */
union {
int64_t i; /* 48 8 */
uint64_t u; /* 48 8 */
} defval; /* 48 8 */
int arrayoffset; /* 56 4 */
/* XXX 4 bytes hole, try to pack */
const PropertyInfo * arrayinfo; /* 64 8 */
int arrayfieldsize; /* 72 4 */
/* XXX 4 bytes hole, try to pack */
const char * link_type; /* 80 8 */
/* size: 88, cachelines: 2, members: 11 */
/* sum members: 66, holes: 4, sum holes: 22 */
};
Afterward there are no holes in either structure.
For arm32, size 48, padding 2, saved 8 bytes.
For arm64, size 72, padding 6, saved 16 bytes.
Saves 20k from qemu-system-aarch64 on a 64-bit host.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Link:
20241216035109.3486070-22-richard.henderson@linaro.org">https://lore.kernel.org/r/20241216035109.3486070-22-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/hw/qdev-properties.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index ef3fd7b4ae2..3680cd239fb 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -16,17 +16,17 @@ struct Property {
const char *name;
const PropertyInfo *info;
ptrdiff_t offset;
- uint8_t bitnr;
+ const char *link_type;
uint64_t bitmask;
- bool set_default;
union {
int64_t i;
uint64_t u;
} defval;
- int arrayoffset;
const PropertyInfo *arrayinfo;
+ int arrayoffset;
int arrayfieldsize;
- const char *link_type;
+ uint8_t bitnr;
+ bool set_default;
};
struct PropertyInfo {
--
2.47.1
- [PULL 12/41] include/hw/qdev-core: Detect most empty Property lists at compile time, (continued)
- [PULL 12/41] include/hw/qdev-core: Detect most empty Property lists at compile time, Paolo Bonzini, 2024/12/19
- [PULL 07/41] hw/tricore: Remove empty Property lists, Paolo Bonzini, 2024/12/19
- [PULL 13/41] hw/core: Introduce device_class_set_props_n, Paolo Bonzini, 2024/12/19
- [PULL 15/41] hw/scsi/megasas: Use device_class_set_props_n, Paolo Bonzini, 2024/12/19
- [PULL 14/41] migration: Use device_class_set_props_n, Paolo Bonzini, 2024/12/19
- [PULL 16/41] hw/arm/armsse: Use device_class_set_props_n, Paolo Bonzini, 2024/12/19
- [PULL 17/41] rust/qemu-api: Use device_class_set_props_n, Paolo Bonzini, 2024/12/19
- [PULL 18/41] hw/core: Replace device_class_set_props with a macro, Paolo Bonzini, 2024/12/19
- [PULL 19/41] target/riscv: Do not abuse DEFINE_PROP_END_OF_LIST, Paolo Bonzini, 2024/12/19
- [PULL 22/41] hw/core/qdev-properties: Constify Property argument to object_field_prop_ptr, Paolo Bonzini, 2024/12/19
- [PULL 21/41] include/hw/qdev-properties: Shrink struct Property,
Paolo Bonzini <=
- [PULL 23/41] hw/core/qdev-properties: Constify Property argument to PropertyInfo.print, Paolo Bonzini, 2024/12/19
- [PULL 24/41] Constify all opaque Property pointers, Paolo Bonzini, 2024/12/19
- [PULL 20/41] include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST, Paolo Bonzini, 2024/12/19
- [PULL 26/41] rust: qom: add possibility of overriding unparent, Paolo Bonzini, 2024/12/19
- [PULL 25/41] rust: qom: put class_init together from multiple ClassInitImpl<>, Paolo Bonzini, 2024/12/19
- [PULL 27/41] rust: rename qemu-api modules to follow C code a bit more, Paolo Bonzini, 2024/12/19
- [PULL 28/41] rust: re-export C types from qemu-api submodules, Paolo Bonzini, 2024/12/19
- [PULL 29/41] rust: tests: allow writing more than one test, Paolo Bonzini, 2024/12/19
- [PULL 30/41] rust: qom: add casting functionality, Paolo Bonzini, 2024/12/19
- [PULL 32/41] rust: qemu-api: add a module to wrap functions and zero-sized closures, Paolo Bonzini, 2024/12/19