[Top] [All Lists]

Re: [PATCH] fix dir2 shortform structures on ARM old ABI

To: "Josef 'Jeff' Sipek" <jeffpc@xxxxxxxxxxxxxx>
Subject: Re: [PATCH] fix dir2 shortform structures on ARM old ABI
From: Timothy Shimmin <tes@xxxxxxx>
Date: Tue, 18 Mar 2008 15:31:00 +1100
Cc: Eric Sandeen <sandeen@xxxxxxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <20080317234219.GD16500@xxxxxxxxxxxxxx>
References: <47DB4181.7040603@xxxxxxxxxxx> <20080315041722.GA25621@xxxxxxxxxxxxxx> <47DB4F4F.8030407@xxxxxxxxxxx> <20080315042703.GA28242@xxxxxxxxxxxxxx> <47DB51A3.70200@xxxxxxxxxxx> <20080315045147.GB28242@xxxxxxxxxxxxxx> <47DEB930.7020108@xxxxxxxxxxx> <47DF0044.6080704@xxxxxxx> <20080317234219.GD16500@xxxxxxxxxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Thunderbird (Macintosh/20071031)
Josef 'Jeff' Sipek wrote:
On Tue, Mar 18, 2008 at 10:35:32AM +1100, Timothy Shimmin wrote:
Eric Sandeen wrote:
Josef 'Jeff' Sipek wrote:
Josef 'Jeff' Sipek, wondering exactly how passionate one can get about
structure member alignment :)
Very.  ;)
Tossing packed at all the ondisk stuctures bloats things badly on ia64.
cvs/linux-2.6-xfs> wc -l before.dis
166688 before.dis
cvs/linux-2.6-xfs> wc -l after.dis
182294 after.dis
That's +15606 lines.
So the problem there is that gcc is doing the wrong thing
on some arches (the example being ia64, sparc64).

Actually, it's not doing the wrong thing...

__attribute__((packed)) means:

1) condense the members of the struct leaving NO padding bytes

2) do NOT assume the entire structure is aligned on any boundary

Okay I only knew about (1) - cause that sounds more like "pack"ing to me.
So you can't assume alignment for the start of the variable
without aligned() if you use packed - Ok.


This means, that even if you have a member that'd be nicely aligned without
the packed attribute (see below), the compiler will generate worst case
alignment code.

struct foo {
        u64 a;
} __attribute__((packed));

You can put struct foo anywhere in memory, and the code accessing ->a will
_always_ work.

Using __attribute((packed,aligned(4))), tells it that the structure as a
whole will be aligned on a 4-byte boundary, but there should be no padding
bytes inserted.

Josef 'Jeff' Sipek.

<Prev in Thread] Current Thread [Next in Thread>