mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyle McMartin <kyle@mcmartin.ca>
To: Daniel Drake <dsd@gentoo.org>
Cc: linux-kernel@vger.kernel.org, avuton@gmail.com, hancockr@shaw.ca,
	alan@lxorguk.ukuu.org.uk, andi@firstfloor.org,
	mrmacman_g4@mac.com, dean@arctic.org, argggh@dolphinics.no,
	jengelh@computergmbh.de, shdl@zakalwe.fi, vlobanov@speakeasy.net,
	drzeus-list@drzeus.cx, strange@nsk.no-ip.org, dm.n9107@gmail.com,
	johannes@sipsolutions.net
Subject: Re: [RFC v2] Documentation about unaligned memory access
Date: Thu, 29 Nov 2007 12:04:36 -0500	[thread overview]
Message-ID: <20071129170436.GA2754@fattire.cabal.ca> (raw)
In-Reply-To: <20071129161523.E0C349D4B52@zog.reactivated.net>

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 <kyle@parisc-linux.org>

cheers,
	Kyle

  reply	other threads:[~2007-11-29 17:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-29 16:15 Daniel Drake
2007-11-29 17:04 ` Kyle McMartin [this message]
2007-11-29 18:00   ` Jan Engelhardt
2007-11-29 17:44 ` Randy Dunlap
2007-11-30  7:58 ` DM
2007-12-03  9:26 ` Johannes Berg
2007-12-05 11:41 ` Jan Kara

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=20071129170436.GA2754@fattire.cabal.ca \
    --to=kyle@mcmartin.ca \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andi@firstfloor.org \
    --cc=argggh@dolphinics.no \
    --cc=avuton@gmail.com \
    --cc=dean@arctic.org \
    --cc=dm.n9107@gmail.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=dsd@gentoo.org \
    --cc=hancockr@shaw.ca \
    --cc=jengelh@computergmbh.de \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrmacman_g4@mac.com \
    --cc=shdl@zakalwe.fi \
    --cc=strange@nsk.no-ip.org \
    --cc=vlobanov@speakeasy.net \
    /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

all inboxes | Powered by JetHome®