Re: packing structures and numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avi Kivity <avi@xxxxxxxxxx> writes:

> Zach Brown wrote:
>> Avi Kivity wrote:
>>
>>> I've been reading btrfs's on-disk format, and two things caught my eye
>>>
>>> - attribute((packed)) structures everywhere, often with misaligned
>>> fields.  This conserves space, but can be harmful to in-memory
>>> performance on some archs.
>>>
>>
>> How harmful?  Do you have any profiles that can even pick this out of
>> the noise?
>>
>
> On those archs that take faults on unaligned accesses it's unlikely to
> be in the noise.  But we could (and should) stick a get_unaligned() in
> the accessor functions.

Normally the compiler on such architectures generates special load/store code
for known unaligned types that does not actually fault, but just uses multiple
instructions. That is slower than a normal memory access, but still much
faster than a exception.

You only really get the full exception fault penalty when the compiler
cannot figure out at compile time that a given variable is unaligned.
But with packed it normally assumes that (I think).

-Andi

-- 
ak@xxxxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux