Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: This may be a really dumb question
@ 1997-09-24  1:28 Jim Paradis
  0 siblings, 0 replies; 10+ messages in thread
From: Jim Paradis @ 1997-09-24  1:28 UTC (permalink / raw)


Sheer Panic wrote:
> 
> But what _exactly_ causes an unaligned trap on the kernel?

Unaligned accesses 8-)

The Alpha architecture requires that memory operations take place on
"natural" boundaries; e.g. the effective address of a longword
load/store must be 0 MOD 4, the effective address of a quadword
load/store must be 0 MOD 8, etc.  Accesses that violate these rules
are called "unaligned" accesses; they are not supported by the
processor, and they cause an exception when they occur.  Imposing the
requirement of aligned accesses saves a *lot* of silicon that can
be put to other uses (reduces the amount of shift logic required to
line up the appropriate byte lanes with the register file, and streamlines
the cache address logic, among other things).

Every sane operating system for Alpha includes an "unaligned access"
handler which intercepts these exceptions and performs the desired
memory access in software.  Needless to say, this is *VERY* inefficient;
instead of executing one memory access instruction, you've just executed
several hundred in the act of taking the exception, simulating the unaligned
access, and returning to the main code.  You also may have messed up your
I-cache and branch-prediction stacks too.

This is why the kernel prints a message when an unaligned access occurs;
it's to encourage you VERY STRONGLY to root them out in the source and
avoid the massive performance penalty.

-- 
Jim Paradis   jrp@jrp.tiac.net   http://www.tiac.net/users/jrp/index.html
"It's not procrastination, it's my new Just-In-Time Workload Management System!"

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: This may be a really dumb question
@ 1997-09-25  0:57 Uncle George
  0 siblings, 0 replies; 10+ messages in thread
From: Uncle George @ 1997-09-25  0:57 UTC (permalink / raw)


fetching or storing an int( 32 bits) long (64 bits ) with an address
that is not  mod(sizeof (int or long )) == 0. it can happen in kern or
user space, but u really like to fix it in kern space bec of the umungus
overhead in fixing the unalignment prob

Sheer Panic wrote:

> But what _exactly_ causes an unaligned trap on the kernel?
>
> Sheer
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: This may be a really dumb question
@ 1997-09-24 16:39 Przemek Klosowski
  1997-09-24 17:12 ` Tom Linden
  1997-09-28  4:23 ` Richard Henderson
  0 siblings, 2 replies; 10+ messages in thread
From: Przemek Klosowski @ 1997-09-24 16:39 UTC (permalink / raw)


Tom Linden wrote
   Most risc machines can only accept a datum on a natural boundary,
   thus a 32 bit integer's address has to be evenely divisible by 4.

Correct so far...

   This is not true with the Power PC, BTW The alpha design team didn't
   really know what they were doing.  In any event to answer your question,
   its the job of the compiler to properly align things.  If you get this 
   message then its really a compiler bug, i.e. the compiler that was used

but it is is no longer so in this paragraph. The Alpha team knew well
what they were doing. Any modern memory is organized in words (often 4
or 8 bytes, sometimes even 16 bytes), so non-aligned access is a bad
match, and, if the loaded item crosses memory word boundary, requires
two memory cycles. There are ways of handling this (caches/prefetching), 
but they complicate things; that is why initial Alpha architecture
simply dropped unaligned loads (BTW, they were added in a recent
revision).

Sometimes, however, unaligned loads are necessary. In particular,
the Ethernet packets, which are delivered by hardware as a binary block,
have internal parts that aren't aligned. If one just grabs them,
one ends up with an unaligned load. Of course it is possible to copy
them byte by byte to an aligned buffer and access it there, but this
requires special-case code in the driver, which wasn't done.

In any case, the compiler doesn't figure here.

	p

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: This may be a really dumb question
@ 1997-09-24  5:32 Jim Paradis
  0 siblings, 0 replies; 10+ messages in thread
From: Jim Paradis @ 1997-09-24  5:32 UTC (permalink / raw)


Tom Linden wrote:

> This is not true with the Power PC, BTW The alpha design team didn't
> really know what they were doing.  

I wouldn't go so far as to say *that*!  The Alpha design team made a
particular set of design decisions, all of which were focused on making
the core CPU as fast as possible.  Sometimes this resulted in pushing
boundary cases off onto the programmer.  Other architectures decided to
make things more convenient for the programmer.  What may surprise you
is that nearly *ALL* architectures exact a penalty for unaligned data
access.  They don't always *tell* you about it (i.e. they silently take
extra cycles to do the unaligned access).  Alpha merely makes this
explicit.

> In any event to answer your question,
> its the job of the compiler to properly align things.  If you get this
> message then its really a compiler bug, i.e. the compiler that was used
> to create the object module, which when excuted causes the trap.  

Unfortunately, a C compiler cannot always detect this... especially
if you're doing things like pointer arithmetic.  And there's a LOT of
that in kernel code!

-- 
Jim Paradis   jrp@jrp.tiac.net  
http://www.tiac.net/users/jrp/index.html
"It's not procrastination, it's my new Just-In-Time Workload Management
System!"

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <Pine.LNX.3.95.970923051536.527L-100000@sheerx.eni.net>]
* This may be a really dumb question
@ 1997-09-23 12:15 Sheer Panic
  0 siblings, 0 replies; 10+ messages in thread
From: Sheer Panic @ 1997-09-23 12:15 UTC (permalink / raw)


But what _exactly_ causes an unaligned trap on the kernel?

Sheer

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1997-09-28  4:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-24  1:28 This may be a really dumb question Jim Paradis
  -- strict thread matches above, loose matches on Subject: below --
1997-09-25  0:57 Uncle George
1997-09-24 16:39 Przemek Klosowski
1997-09-24 17:12 ` Tom Linden
1997-09-28  4:23 ` Richard Henderson
1997-09-24  5:32 Jim Paradis
     [not found] <Pine.LNX.3.95.970923051536.527L-100000@sheerx.eni.net>
1997-09-24  1:10 ` Tom Linden
1997-09-24 16:38   ` Volker Barthelmann
1997-09-28  3:39   ` Richard Henderson
1997-09-23 12:15 Sheer Panic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox