qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 03/11] slavio_intctl: avoid structure holes spotted


From: Blue Swirl
Subject: [Qemu-devel] [PATCH 03/11] slavio_intctl: avoid structure holes spotted by pahole
Date: Sun, 7 Aug 2011 20:58:13 +0000

Report from pahole on amd64 host:
struct SLAVIO_INTCTLState {
        SysBusDevice               busdev;               /*     0  5648 */
        /* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
        uint32_t                   intregm_pending;      /*  5648     4 */
        uint32_t                   intregm_disabled;     /*  5652     4 */
        uint32_t                   target_cpu;           /*  5656     4 */

        /* XXX 4 bytes hole, try to pack */

        qemu_irq                   cpu_irqs[16][16];     /*  5664  2048 */
        /* --- cacheline 120 boundary (7680 bytes) was 32 bytes ago --- */
        SLAVIO_CPUINTCTLState      slaves[16];           /*  7712   384 */
        /* --- cacheline 126 boundary (8064 bytes) was 32 bytes ago --- */

        /* size: 8096, cachelines: 127 */
        /* sum members: 8092, holes: 1, sum holes: 4 */
        /* last cacheline: 32 bytes */
};      /* definitions: 1 */

struct SLAVIO_CPUINTCTLState {
        uint32_t                   intreg_pending;       /*     0     4 */

        /* XXX 4 bytes hole, try to pack */

        struct SLAVIO_INTCTLState * master;              /*     8     8 */
        uint32_t                   cpu;                  /*    16     4 */
        uint32_t                   irl_out;              /*    20     4 */

        /* size: 24, cachelines: 1 */
        /* sum members: 20, holes: 1, sum holes: 4 */
        /* last cacheline: 24 bytes */
};      /* definitions: 1 */

Fix by rearranging the structures to avoid padding.

Signed-off-by: Blue Swirl <address@hidden>
---
 hw/slavio_intctl.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c
index a83e5b8..329c251 100644
--- a/hw/slavio_intctl.c
+++ b/hw/slavio_intctl.c
@@ -46,22 +46,22 @@
 struct SLAVIO_INTCTLState;

 typedef struct SLAVIO_CPUINTCTLState {
-    uint32_t intreg_pending;
     struct SLAVIO_INTCTLState *master;
+    uint32_t intreg_pending;
     uint32_t cpu;
     uint32_t irl_out;
 } SLAVIO_CPUINTCTLState;

 typedef struct SLAVIO_INTCTLState {
     SysBusDevice busdev;
-    uint32_t intregm_pending;
-    uint32_t intregm_disabled;
-    uint32_t target_cpu;
 #ifdef DEBUG_IRQ_COUNT
     uint64_t irq_count[32];
 #endif
     qemu_irq cpu_irqs[MAX_CPUS][MAX_PILS];
     SLAVIO_CPUINTCTLState slaves[MAX_CPUS];
+    uint32_t intregm_pending;
+    uint32_t intregm_disabled;
+    uint32_t target_cpu;
 } SLAVIO_INTCTLState;

 #define INTCTL_MAXADDR 0xf
-- 
1.6.2.4

Attachment: 0003-slavio_intctl-avoid-structure-holes-spotted-by-pahol.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]