From 3d7a4479fca08fea065b45de24485ef91f210a51 Mon Sep 17 00:00:00 2001
Message-Id: <3d7a4479fca08fea065b45de24485ef91f210a51.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:55:23 +0000
Subject: [PATCH 10/11] escc: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct ChannelState {
...
ChnType type; /* 32 4 */
/* XXX 4 bytes hole, try to pack */
...
uint8_t rregs[16]; /* 66 16 */
/* XXX 2 bytes hole, try to pack */
...
/* size: 392, cachelines: 7 */
/* sum members: 382, holes: 2, sum holes: 6 */
/* padding: 4 */
/* last cacheline: 8 bytes */
}; /* definitions: 1 */
Fix by rearranging the structure to avoid padding.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
hw/escc.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
@@ -108,18 +108,19 @@ typedef struct {
#define SERIAL_REGS 16
typedef struct ChannelState {
qemu_irq irq;
- uint32_t reg;
uint32_t rxint, txint, rxint_under_svc, txint_under_svc;
- ChnID chn; // this channel, A (base+4) or B (base+0)
- ChnType type;
struct ChannelState *otherchn;
- uint8_t rx, tx, wregs[SERIAL_REGS], rregs[SERIAL_REGS];
+ uint32_t reg;
+ uint8_t wregs[SERIAL_REGS], rregs[SERIAL_REGS];
SERIOQueue queue;
CharDriverState *chr;
int e0_mode, led_mode, caps_lock_mode, num_lock_mode;
int disabled;
int clock;
uint32_t vmstate_dummy;
+ ChnID chn; // this channel, A (base+4) or B (base+0)
+ ChnType type;
+ uint8_t rx, tx;
} ChannelState;
struct SerialState {
--
1.7.2.5
Edited report from pahole on amd64 host: struct ChannelState { ... ChnType type; /* 32 4 */ /* XXX 4 bytes hole, try to pack */ ... uint8_t rregs[16]; /* 66 16 */ /* XXX 2 bytes hole, try to pack */ ... /* size: 392, cachelines: 7 */ /* sum members: 382, holes: 2, sum holes: 6 */ /* padding: 4 */ /* last cacheline: 8 bytes */ }; /* definitions: 1 */ Fix by rearranging the structure to avoid padding. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- hw/escc.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)