Subject: Re: Squid on Alpha blows up..
To: Andrew Brown <>
From: Jason Thorpe <>
List: netbsd-ports
Date: 03/02/1999 15:18:22
[ follow-ups to port-alpha, please ]

On Tue, 2 Mar 1999 17:55:39 -0500 
 Andrew Brown <> wrote:

 > in reference to unaligned accesses of multibyte fields on the alpha,
 > stephen a. thomas says (in ipng and the tcp/ip procotols on page 111)
 > in both cases, the processor is able to access the value, but when the
 > value is aligned, the alpha can read or write it 30 times faster than
 > when it is not.


The processor _ITSELF_ is not able to!  It does, in fact, generate an
unaligned access fault.  The _KERNEL_ fixes up the access.  This is
VERY slow:

	(1) Overhead of taking an unaligned access fault.

	(2) Overhead of fixup.

	(3) Additional overhead for (2) because access must be across
	    a protection boundary.'d still be VERY slow (just slightly less so :-) if the compiler did
the fixup at compile time.  But, see below...

 > [alpha architecture handbook, dec 1992, p a-6]

In my copy (Alpha AXP Architecture Reference Manual, Second Edition, 1995,
order number EY-T132E-DP), the paragraph is written as follows:

	Items within aggregates that are forced to be unaligned (records,
	common blocks) should generate compile-time warning messages and
	inline byte extract/insert code.  Users must be educated that the
	warning message means that they are taking a factor of 30 performance

Note the text "inline byte extact/insert code".  This implies (assuming you
understand precisely what that phrase means :-) that, in fact, the processor
is unable to do unaligned access, and that the compiler must emit code to
do the fixup on the fly.

Our compiler does not do it.  Indeed, it's difficult for the compiler to
know if access is unaligned at compile time, if its being passed a pointer
in a function.

For this reason, we trap the unaligned access fault, and do one of 4
things, depending on sysctl variables:

	(1) Silently fixup the unaligned access.

	(2) Print out a message and fixup the unaligned access.

	(3) Silently send the process a SIGBUS.

	(4) Print out a message and send the process a SIGBUS.

I think VxWorks for the Alpha does NOT do unaligned access fixups at all.

Also note that the NetBSD kernel will panic if unaligned access is
performed by the kernel, rather than by a user process.

        -- Jason R. Thorpe <>