Hi Daniel, On Thu, Nov 29, 2007 at 04:15:23PM +0000, Daniel Drake wrote: > Unaligned memory accesses occur when you try to read N bytes of data starting > from an address that is not evenly divisible by N (i.e. addr % N != 0). > For example, reading 4 bytes of data from address 0x10004 is fine, but > reading 4 bytes of data from address 0x10005 would be an unaligned memory > access. >
This is rather ambiguous, while most people know what you mean, clarifying it a bit might be nice. How about something like, Unaligned memory accesses occur when trying to read more than a byte (i.e. u16, u32, u64) in a single instruction from an address that is not evenly divisible by the width of the type (i.e. addr % width != 0). For example, if you had 4GB of virtual memory, picture it as an array of bytes, u8 memory[4096 * (1024 * 1024)]; /* 4G bytes */ Aligned accesses would be accessing this array in this manner, u16 memory[(4096 * (1024 * 1024)) / sizeof(u16)] /* 2G bytes */ u32 memory[(4096 * (1024 * 1024)) / sizeof(u32)] /* 1G bytes */ u64 memory[(4096 * (1024 * 1024)) / sizeof(u64)] /* 512M bytes */ And an unaligned access would be accessing on a non-integer multiple boundary. Ok, that kind of sucked too. But you get the idea. > > Why unaligned access is bad > =========================== > The rest of this looks good. Acked-by: Kyle McMartin <[EMAIL PROTECTED]> cheers, Kyle - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/