pahole - Finding holes in kernel structs
Marcel Moolenaar
xcllnt at mac.com
Thu Feb 12 13:22:10 PST 2009
On Feb 12, 2009, at 8:34 AM, Jille Timmermans wrote:
> Julian Stacey schreef:
>>> 1) Is it worth my time trying to rearrange structs?
>> I wondered whether as a sensitivity test, some version of gcc (or
>> its competitor ?) might have capability to automatically re-order
>> variables ? but found nothing in man gcc "Optimization Options".
> There is a __packed attribute, I don't know what it exactly does and
> whether it is an improvement.
>
__packed is always a gross pessimization. The side-effect of
packing a structure is that the alignment of the structure
drops to 1. That means that any field will be read 1 byte at
a time and reconstructed by logical operations.
For best results, __packed should be used with __aligned(X),
in case __packed is needed of course to address the side-
effect. Of course multi-byte fields that are unaligned in
the structure as the result of packing, will still be read
in parts.
In other words: don't use __packed when you don't have to.
--
Marcel Moolenaar
xcllnt at mac.com
More information about the freebsd-hackers
mailing list