From patchwork Sun Aug 7 21:01:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 108845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6F40B6F70 for ; Mon, 8 Aug 2011 13:10:15 +1000 (EST) Received: from localhost ([::1]:50366 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqAUM-00050B-Pv for incoming@patchwork.ozlabs.org; Sun, 07 Aug 2011 17:02:26 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqAUG-000502-Rd for qemu-devel@nongnu.org; Sun, 07 Aug 2011 17:02:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqAUF-0001z3-KE for qemu-devel@nongnu.org; Sun, 07 Aug 2011 17:02:20 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:50803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqAUF-0001yz-H1 for qemu-devel@nongnu.org; Sun, 07 Aug 2011 17:02:19 -0400 Received: by qyk31 with SMTP id 31so2115138qyk.4 for ; Sun, 07 Aug 2011 14:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=OQkFL+3+bCXK0LimN+Vt7Azbq/zT3Hzcvp3N0toFF1Q=; b=PUw+zmSWlUsOF687W9oCAXNRDJvR+DTpjnKF9Qpm+NaXpRDQ2kqNzfPUNm9Tjv4t/u 0PVgmkUGZdaJmHiEbv+29ubqkc6DADFJoUWmGUI+SvxtRqjCeYOPF07Jku3SlrFxY2LD 5BTu0bdWPVafl/8sWz2sPNRT3KD6v89H8/qWs= Received: by 10.224.71.69 with SMTP id g5mr3356652qaj.382.1312750939079; Sun, 07 Aug 2011 14:02:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.37.82 with HTTP; Sun, 7 Aug 2011 14:01:59 -0700 (PDT) From: Blue Swirl Date: Sun, 7 Aug 2011 21:01:59 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.180 Subject: [Qemu-devel] [PATCH 11/11] m48t59: avoid structure holes spotted by pahole X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Report from pahole on amd64 host: struct M48t59State { uint32_t type; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ qemu_irq IRQ; /* 8 8 */ uint32_t io_base; /* 16 4 */ uint32_t size; /* 20 4 */ time_t time_offset; /* 24 8 */ time_t stop_time; /* 32 8 */ struct tm alarm; /* 40 56 */ /* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */ struct QEMUTimer * alrm_timer; /* 96 8 */ struct QEMUTimer * wd_timer; /* 104 8 */ uint8_t lock; /* 112 1 */ /* XXX 1 byte hole, try to pack */ uint16_t addr; /* 114 2 */ /* XXX 4 bytes hole, try to pack */ uint8_t * buffer; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ /* size: 128, cachelines: 2 */ /* sum members: 119, holes: 3, sum holes: 9 */ }; /* definitions: 1 */ Fix by rearranging the structure to avoid padding. Signed-off-by: Blue Swirl --- hw/m48t59.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) From b8a1e6b0170f26924c35750ba387a656ea2c614c Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <54eae070f9056790fa41b468360d23cdd17503f4.1312750600.git.blauwirbel@gmail.com> References: <54eae070f9056790fa41b468360d23cdd17503f4.1312750600.git.blauwirbel@gmail.com> From: Blue Swirl Date: Sun, 7 Aug 2011 20:02:02 +0000 Subject: [PATCH 11/11] m48t59: avoid structure holes spotted by pahole Report from pahole on amd64 host: struct M48t59State { uint32_t type; /* 0 4 */ /* XXX 4 bytes hole, try to pack */ qemu_irq IRQ; /* 8 8 */ uint32_t io_base; /* 16 4 */ uint32_t size; /* 20 4 */ time_t time_offset; /* 24 8 */ time_t stop_time; /* 32 8 */ struct tm alarm; /* 40 56 */ /* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */ struct QEMUTimer * alrm_timer; /* 96 8 */ struct QEMUTimer * wd_timer; /* 104 8 */ uint8_t lock; /* 112 1 */ /* XXX 1 byte hole, try to pack */ uint16_t addr; /* 114 2 */ /* XXX 4 bytes hole, try to pack */ uint8_t * buffer; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ /* size: 128, cachelines: 2 */ /* sum members: 119, holes: 3, sum holes: 9 */ }; /* definitions: 1 */ Fix by rearranging the structure to avoid padding. Signed-off-by: Blue Swirl --- hw/m48t59.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/m48t59.c b/hw/m48t59.c index 537c0f7..67685cd 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -50,8 +50,6 @@ */ struct M48t59State { - /* Model parameters */ - uint32_t type; // 2 = m48t02, 8 = m48t08, 59 = m48t59 /* Hardware parameters */ qemu_irq IRQ; uint32_t io_base; @@ -64,9 +62,12 @@ struct M48t59State { struct QEMUTimer *alrm_timer; struct QEMUTimer *wd_timer; /* NVRAM storage */ - uint8_t lock; - uint16_t addr; uint8_t *buffer; + /* Model parameters */ + uint32_t type; /* 2 = m48t02, 8 = m48t08, 59 = m48t59 */ + /* NVRAM storage */ + uint16_t addr; + uint8_t lock; }; typedef struct M48t59ISAState { -- 1.7.2.5