* 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
* Re: This may be a really dumb question
[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
0 siblings, 2 replies; 10+ messages in thread
From: Tom Linden @ 1997-09-24 1:10 UTC (permalink / raw)
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.
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
to create the object module, which when excuted causes the trap. These
are a pain in the ass but can usually be fixed (If you don't want to fix
the code generation phase of the compiler) but forcing alignment by one
means or another, such as, declaring a variable of appropriate size either
above or below the variable which is misaligned. If it is gcc, ask
Stallman or Cygnus to fix it once you have isolated the module and the
variable. Use nm sorted by address.
On Tue, 23 Sep 1997, 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 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-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
* Re: This may be a really dumb question
1997-09-24 1:10 ` Tom Linden
@ 1997-09-24 16:38 ` Volker Barthelmann
1997-09-28 3:39 ` Richard Henderson
1 sibling, 0 replies; 10+ messages in thread
From: Volker Barthelmann @ 1997-09-24 16:38 UTC (permalink / raw)
On Tue, 23 Sep 1997, Tom Linden wrote:
> This is not true with the Power PC, BTW The alpha design team didn't
> really know what they were doing.
Why?? Many CPUs don't allow misaligned accesses and the ones that do will
usually suffer a pretty big performance penalty.
It's not the CPU's job to fix broken programs.
> 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.
I _very_ _very_ much doubt that. If a compiler really fails to properly
align objects this is almost impossible to overlook. It's also not the
kind of bug that is likely to appear only under rare circumstances.
Usually it's just broken software. Plain and simple.
Volker
--
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 16:39 Przemek Klosowski
@ 1997-09-24 17:12 ` Tom Linden
1997-09-28 4:23 ` Richard Henderson
1 sibling, 0 replies; 10+ messages in thread
From: Tom Linden @ 1997-09-24 17:12 UTC (permalink / raw)
I think you missed my point. The mission statement of the design team
was flawed as evidenced by the fact that later revisions have added new
features such as byte load and store, and I am happy to hear unaligned
loads and assume stores. There are really two problems, (1) there is
about a couple of hundred billion lines of code in production most of
which is unaligned and (2) most languages provide for some type of
aliasing of data types which could lead to unaligned code. Even if the
compiler did a better job of detecting aliasing it doesn't mean that you
could align things (e.g. fortran named common). IBM new this when they
designed their chip so that unaligned access cost is only one clock tick.
On the first alphas, 16bit assignment of the form c = a + b; took 19
ticks, but 32bit only 4 ticks (if I remember correctly) that in my
view is a design flaw.
So you really have to live with unaligned acces, of course you always
have the option when writing new code that you can more carefully align
things.
On Wed, 24 Sep 1997, Przemek Klosowski wrote:
> 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
>
>
--
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 1:10 ` Tom Linden
1997-09-24 16:38 ` Volker Barthelmann
@ 1997-09-28 3:39 ` Richard Henderson
1 sibling, 0 replies; 10+ messages in thread
From: Richard Henderson @ 1997-09-28 3:39 UTC (permalink / raw)
> 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.
Nope. The compiler only takes care that structures are properly
padded and that on-stack variables are properly aligned. It is
the case that the program can muck about with things and create
unaligned pointers.
r~
--
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
1 sibling, 0 replies; 10+ messages in thread
From: Richard Henderson @ 1997-09-28 4:23 UTC (permalink / raw)
> that is why initial Alpha architecture
> simply dropped unaligned loads (BTW, they were added in a recent
> revision).
I don't think so; only byte/word load/store.
> 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.
Actually it is IPX not Ethernet itself that is the culprit
here, I beleive. Certainly IP does not have this problem.
When the subject came up sometime back about putting in explicit
unaligned load sequences (which, btw, don't require a separate
buffer) to handle this, it was vetoed by On High.
The rationale? "I won't slow down the important case (IP) for
the unimportant case (IPX)."
r~
--
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