qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 06/11] sun4m: avoid structure holes spotted by pahole
Date: Sun, 7 Aug 2011 20:59:43 +0000	[thread overview]
Message-ID: <CAAu8pHte9yMCCTLAC3DquYS1UARQfwLkJJ095PNYZpr6F-0b+w@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2713 bytes --]

Edited report from pahole on amd64 host:
struct sun4c_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   112     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 136, cachelines: 3 */
	/* sum members: 135, holes: 1, sum holes: 1 */
	/* last cacheline: 8 bytes */
};	/* definitions: 1 */

struct sun4d_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   128     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 152, cachelines: 3 */
	/* sum members: 151, holes: 1, sum holes: 1 */
	/* last cacheline: 24 bytes */
};	/* definitions: 1 */

struct sun4m_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   260     1 */

	/* XXX 1 byte hole, try to pack */

	uint16_t                   machine_id;           /*   262     2 */
	uint32_t                   iommu_version;        /*   264     4 */

	/* XXX 4 bytes hole, try to pack */
...
	/* size: 288, cachelines: 5 */
	/* sum members: 283, holes: 2, sum holes: 5 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

Fix by rearranging the structures to avoid padding.

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

diff --git a/hw/sun4m.c b/hw/sun4m.c
index df3aa32..5afb1b1 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -97,12 +97,12 @@ struct sun4m_hwdef {
         target_phys_addr_t reg_base, vram_base;
     } vsimm[MAX_VSIMMS];
     target_phys_addr_t ecc_base;
-    uint32_t ecc_version;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iommu_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t ecc_version;
+    uint32_t iommu_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };

 #define MAX_IOUNITS 5
@@ -115,11 +115,11 @@ struct sun4d_hwdef {
     target_phys_addr_t ledma_base, le_base;
     target_phys_addr_t tcx_base;
     target_phys_addr_t sbi_base;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iounit_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t iounit_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };

 struct sun4c_hwdef {
@@ -128,11 +128,11 @@ struct sun4c_hwdef {
     target_phys_addr_t serial_base, fd_base;
     target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
     target_phys_addr_t tcx_base, aux1_base;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iommu_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t iommu_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };

 int DMA_get_channel_mode (int nchan)
-- 
1.6.2.4

[-- Attachment #2: 0006-sun4m-avoid-structure-holes-spotted-by-pahole.patch --]
[-- Type: text/x-patch, Size: 3206 bytes --]

From dce5a7901b80ee038a6c28ee0520588531b8e5cb Mon Sep 17 00:00:00 2001
Message-Id: <dce5a7901b80ee038a6c28ee0520588531b8e5cb.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:22:46 +0000
Subject: [PATCH 06/11] sun4m: avoid structure holes spotted by pahole

Edited report from pahole on amd64 host:
struct sun4c_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   112     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 136, cachelines: 3 */
	/* sum members: 135, holes: 1, sum holes: 1 */
	/* last cacheline: 8 bytes */
};	/* definitions: 1 */

struct sun4d_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   128     1 */

	/* XXX 1 byte hole, try to pack */
...
	/* size: 152, cachelines: 3 */
	/* sum members: 151, holes: 1, sum holes: 1 */
	/* last cacheline: 24 bytes */
};	/* definitions: 1 */

struct sun4m_hwdef {
...
	uint8_t                    nvram_machine_id;     /*   260     1 */

	/* XXX 1 byte hole, try to pack */

	uint16_t                   machine_id;           /*   262     2 */
	uint32_t                   iommu_version;        /*   264     4 */

	/* XXX 4 bytes hole, try to pack */
...
	/* size: 288, cachelines: 5 */
	/* sum members: 283, holes: 2, sum holes: 5 */
	/* last cacheline: 32 bytes */
};	/* definitions: 1 */

Fix by rearranging structures to avoid padding.

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

diff --git a/hw/sun4m.c b/hw/sun4m.c
index df3aa32..5afb1b1 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -97,12 +97,12 @@ struct sun4m_hwdef {
         target_phys_addr_t reg_base, vram_base;
     } vsimm[MAX_VSIMMS];
     target_phys_addr_t ecc_base;
-    uint32_t ecc_version;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iommu_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t ecc_version;
+    uint32_t iommu_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };
 
 #define MAX_IOUNITS 5
@@ -115,11 +115,11 @@ struct sun4d_hwdef {
     target_phys_addr_t ledma_base, le_base;
     target_phys_addr_t tcx_base;
     target_phys_addr_t sbi_base;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iounit_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t iounit_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };
 
 struct sun4c_hwdef {
@@ -128,11 +128,11 @@ struct sun4c_hwdef {
     target_phys_addr_t serial_base, fd_base;
     target_phys_addr_t idreg_base, dma_base, esp_base, le_base;
     target_phys_addr_t tcx_base, aux1_base;
-    uint8_t nvram_machine_id;
-    uint16_t machine_id;
-    uint32_t iommu_version;
     uint64_t max_mem;
     const char * const default_cpu_model;
+    uint32_t iommu_version;
+    uint16_t machine_id;
+    uint8_t nvram_machine_id;
 };
 
 int DMA_get_channel_mode (int nchan)
-- 
1.7.2.5


                 reply	other threads:[~2011-08-07 21:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAu8pHte9yMCCTLAC3DquYS1UARQfwLkJJ095PNYZpr6F-0b+w@mail.gmail.com \
    --to=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).