Patchwork [02/11] slavio_misc: avoid structure holes spotted by pahole

login
register
mail settings
Submitter Blue Swirl
Date Aug. 7, 2011, 8:57 p.m.
Message ID <CAAu8pHuLYGSa7SYUSirKfSeo_wMtv22Vb5ddN7ggntLRaAjpzw@mail.gmail.com>
Download mbox | patch
Permalink /patch/108847/
State New
Headers show

Comments

Blue Swirl - Aug. 7, 2011, 8:57 p.m.
Report from pahole on amd64 host:
struct MiscState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	qemu_irq                   irq;                  /*  5648     8 */
	uint32_t                   dummy;                /*  5656     4 */
	uint8_t                    config;               /*  5660     1 */
	uint8_t                    aux1;                 /*  5661     1 */
	uint8_t                    aux2;                 /*  5662     1 */
	uint8_t                    diag;                 /*  5663     1 */
	uint8_t                    mctrl;                /*  5664     1 */
	uint8_t                    sysctrl;              /*  5665     1 */
	uint16_t                   leds;                 /*  5666     2 */

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

	qemu_irq                   fdc_tc;               /*  5672     8 */

	/* size: 5680, cachelines: 89 */
	/* sum members: 5676, holes: 1, sum holes: 4 */
	/* last cacheline: 48 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/slavio_misc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

From 386cc069182db6e0657eac26270aa1a3ef282774 Mon Sep 17 00:00:00 2001
Message-Id: <386cc069182db6e0657eac26270aa1a3ef282774.1312750600.git.blauwirbel@gmail.com>
In-Reply-To: <54eae070f9056790fa41b468360d23cdd17503f4.1312750600.git.blauwirbel@gmail.com>
References: <54eae070f9056790fa41b468360d23cdd17503f4.1312750600.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sun, 7 Aug 2011 19:03:18 +0000
Subject: [PATCH 02/11] slavio_misc: avoid structure holes spotted by pahole

Report from pahole on amd64 host:
struct MiscState {
	SysBusDevice               busdev;               /*     0  5648 */
	/* --- cacheline 88 boundary (5632 bytes) was 16 bytes ago --- */
	qemu_irq                   irq;                  /*  5648     8 */
	uint32_t                   dummy;                /*  5656     4 */
	uint8_t                    config;               /*  5660     1 */
	uint8_t                    aux1;                 /*  5661     1 */
	uint8_t                    aux2;                 /*  5662     1 */
	uint8_t                    diag;                 /*  5663     1 */
	uint8_t                    mctrl;                /*  5664     1 */
	uint8_t                    sysctrl;              /*  5665     1 */
	uint16_t                   leds;                 /*  5666     2 */

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

	qemu_irq                   fdc_tc;               /*  5672     8 */

	/* size: 5680, cachelines: 89 */
	/* sum members: 5676, holes: 1, sum holes: 4 */
	/* last cacheline: 48 bytes */
};	/* definitions: 1 */

Fix by rearranging the structure to avoid padding.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/slavio_misc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c
index 198360d..1f5a2d7 100644
--- a/hw/slavio_misc.c
+++ b/hw/slavio_misc.c
@@ -37,13 +37,13 @@ 
 typedef struct MiscState {
     SysBusDevice busdev;
     qemu_irq irq;
+    qemu_irq fdc_tc;
     uint32_t dummy;
     uint8_t config;
     uint8_t aux1, aux2;
     uint8_t diag, mctrl;
     uint8_t sysctrl;
     uint16_t leds;
-    qemu_irq fdc_tc;
 } MiscState;
 
 typedef struct APCState {
-- 
1.7.2.5