* Unaligned accesses
@ 1997-09-23 9:39 Sheer Panic
0 siblings, 0 replies; 13+ messages in thread
From: Sheer Panic @ 1997-09-23 9:39 UTC (permalink / raw)
I have an interesting case of the scrolling unaligned access problem. I
have three identical multias, with 64megs of ram, Ether100TX cards as well
as the standerd onboard ether, and after they h ave booted, the
continuously scroll unaligned trap error messages. Has anyone else had
this problem? I am using the kernel-2.0.30 source with the pre-patch #9
and the alpha patches.
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] 13+ messages in thread
* Unaligned accesses
@ 1998-07-05 0:54 B. James Phillippe
0 siblings, 0 replies; 13+ messages in thread
From: B. James Phillippe @ 1998-07-05 0:54 UTC (permalink / raw)
To: RedHat AXP list
Hello,
I'm wondering if someone can better educate me on unaligned
accesses under Alpha. I am aware of the basics (that Alpha, like all RISC
CPU's, requires memory accesses to be on naturally aligned boundaries), but
there are some other questions I have. First, can someone post a snippet
of code demonstrating aligned and unaligned memory access? Second, how do
I interpret the fields in /proc/cpuinfo pertaining to kernel unaligned
access and user unaligned access?
kernel unaligned acc : 0 (pc=0,va=0)
user unaligned acc : 11385 (pc=1201d1648,va=15555eb2428)
thanks,
-bp
--
B. James Phillippe <bryan@terran.org>
Linux Software Engineer, WGT Inc.
http://earth.terran.org/~bryan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Unaligned accesses
2001-07-25 0:02 Archives on www.lib.uaa.alaska.edu Mike Tibor
@ 2001-07-25 0:57 ` alvin
2001-07-25 15:47 ` Jay Estabrook
0 siblings, 1 reply; 13+ messages in thread
From: alvin @ 2001-07-25 0:57 UTC (permalink / raw)
To: axp-list
I have noticed some problem with accessing unaligned data.
I have an application that has a bunch of accesses to shorts in a byte
array. Not seeing any more alignment errors from the kernel I assumed
that all was ok due to the fact that althought it is a byte array it
seemed to be short aligned...
Well this turns out to be wrong. forcing alignment and doing memcpy's
made my problems go away.
I was under the impression that the:
1) OS/Palcode handled unaligned accessed as a fault and although there
is a performance
penalty that is all.
2) The kernel generated an error message for unaligned accesses.
--
Alvin Starr || voice: (416)785-4051
Interlink Connectivity || fax: (416)785-3668
alvin@iplink.net ||
^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: Unaligned accesses
@ 2001-07-25 11:56 Rick Gorton
0 siblings, 0 replies; 13+ messages in thread
From: Rick Gorton @ 2001-07-25 11:56 UTC (permalink / raw)
To: 'axp-list@redhat.com'
The Kernel does have code which does:
print out unaligned access errors
does the 'right' thing (albeit a bit slowly)
In the event that a ldwu instruction is accessing a misaligned
address. The 'gotcha':
- Unless the code in the application is explicitly using the
ldwu instructions, the code executed will read the content
correctly from a misaligned address. The only way to get
those instructions is to compile with -mcpu=ev56 (or later)
If your machine supports ev56 instructions, you _really_ want
to use them. Your code size will shrink (good for performance)
and your code will automatically speed up - I've seen speedups
ranging from 10%-20% by just using the new instructions.
I hope this helps,
Rick
-----Original Message-----
From: alvin [mailto:alvin@iplink.net]
Sent: Tuesday, July 24, 2001 8:58 PM
To: axp-list@redhat.com
Subject: Unaligned accesses
I have noticed some problem with accessing unaligned data.
I have an application that has a bunch of accesses to shorts in a byte
array. Not seeing any more alignment errors from the kernel I assumed
that all was ok due to the fact that althought it is a byte array it
seemed to be short aligned...
Well this turns out to be wrong. forcing alignment and doing memcpy's
made my problems go away.
I was under the impression that the:
1) OS/Palcode handled unaligned accessed as a fault and although there
is a performance
penalty that is all.
2) The kernel generated an error message for unaligned accesses.
--
Alvin Starr || voice: (416)785-4051
Interlink Connectivity || fax: (416)785-3668
alvin@iplink.net ||
_______________________________________________
Axp-list mailing list
Axp-list@redhat.com
https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 0:57 ` Unaligned accesses alvin
@ 2001-07-25 15:47 ` Jay Estabrook
2001-07-25 20:41 ` alvin
0 siblings, 1 reply; 13+ messages in thread
From: Jay Estabrook @ 2001-07-25 15:47 UTC (permalink / raw)
To: axp-list
On Tue, Jul 24, 2001 at 08:57:31PM -0400, alvin wrote:
>
> I have noticed some problem with accessing unaligned data.
>
> I have an application that has a bunch of accesses to shorts in a byte
> array. Not seeing any more alignment errors from the kernel I assumed
> that all was ok due to the fact that althought it is a byte array it
> seemed to be short aligned...
>
> Well this turns out to be wrong. forcing alignment and doing memcpy's
> made my problems go away.
You didn't describe the problem you were having...
> I was under the impression that the:
> 1) OS/Palcode handled unaligned accessed as a fault and although there
> is a performance penalty, that is all.
That should be right.
> 2) The kernel generated an error message for unaligned accesses.
It generates some informational messages, but not one for every
unaligned access (if it did, there'd be a flood for the more serious
transgressors).
So, a little more about the problem you saw, and the machine you are
running on, please...
--Jay++
-----------------------------------------------------------------------------
Jay A Estabrook Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20 (508) 467-2080
200 Forest Street, Marlboro MA 01752 Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 15:47 ` Jay Estabrook
@ 2001-07-25 20:41 ` alvin
2001-07-25 21:08 ` Christopher C. Chimelis
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: alvin @ 2001-07-25 20:41 UTC (permalink / raw)
To: axp-list
Jay Estabrook wrote:
>
> On Tue, Jul 24, 2001 at 08:57:31PM -0400, alvin wrote:
> >
> > I have noticed some problem with accessing unaligned data.
> >
> > I have an application that has a bunch of accesses to shorts in a byte
> > array. Not seeing any more alignment errors from the kernel I assumed
> > that all was ok due to the fact that althought it is a byte array it
> > seemed to be short aligned...
> >
> > Well this turns out to be wrong. forcing alignment and doing memcpy's
> > made my problems go away.
>
> You didn't describe the problem you were having...
I have a network application (l2tpd) that uses a lot of htons and ntohs
conversions back to back and on buffers that seem not to be naturally
aligned.
I am running out of time before my holidays so I will not be able to
verify this but my feeling is that if there are a number of unaligned
accesses that are back to back that is when the code breaks.
The effect that I am seeing is that a 2 byte variable is not getting
both bytes updated reliably. This problem appears or goes away depending
on the alignment of the data.
> > I was under the impression that the:
> > 1) OS/Palcode handled unaligned accessed as a fault and although there
> > is a performance penalty, that is all.
>
> That should be right.
>
> > 2) The kernel generated an error message for unaligned accesses.
>
> It generates some informational messages, but not one for every
> unaligned access (if it did, there'd be a flood for the more serious
> transgressors).
Ahhhhhhhh the light goes on. Silly me I thought that since I have seen
messages and fixing the code makes them go away that all the problems
were tagged. Any quick pointer to the rule that is used for deciding
what to flag and not?
> So, a little more about the problem you saw, and the machine you are
> running on, please...
I am running this on 2 systems a UP1100(last to show the problem) and a
noname.
They are running serial consoles with RedHat 6.2 and kernel version:
Linux version 2.2.19-6.2.1 (root@sws1) (gcc version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)) #6 Thu Jul 5 02:22:34 EDT 2001
This has a number of small patches for VLAN support and autodetect raid
support otherwise they are clean.
--
Alvin Starr || voice: (416)585-9971
Interlink Connectivity || fax: (416)585-9974
alvin@iplink.net ||
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 20:41 ` alvin
@ 2001-07-25 21:08 ` Christopher C. Chimelis
2001-07-25 21:15 ` Michal Jaegermann
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Christopher C. Chimelis @ 2001-07-25 21:08 UTC (permalink / raw)
To: axp-list
On Wed, 25 Jul 2001, alvin wrote:
> Ahhhhhhhh the light goes on. Silly me I thought that since I have seen
> messages and fixing the code makes them go away that all the problems
> were tagged. Any quick pointer to the rule that is used for deciding
> what to flag and not?
The relevant code is in arch/alpha/kernel/traps.c in the linux kernel
tree. It should be easy to modify, if you want to try that. Expect the
logging flood gates to open, though. I've crippled a few systems by
enabling the printing of every unaligned access (driver debugging...no
fun).
C
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 20:41 ` alvin
2001-07-25 21:08 ` Christopher C. Chimelis
@ 2001-07-25 21:15 ` Michal Jaegermann
2001-07-26 12:39 ` Ivan Kokshaysky
2001-07-26 12:40 ` Ivan Kokshaysky
2001-07-26 13:29 ` Jay Estabrook
3 siblings, 1 reply; 13+ messages in thread
From: Michal Jaegermann @ 2001-07-25 21:15 UTC (permalink / raw)
To: axp-list
On Wed, Jul 25, 2001 at 03:41:33PM -0500, alvin wrote:
>
> I am running out of time before my holidays so I will not be able to
> verify this but my feeling is that if there are a number of unaligned
> accesses that are back to back that is when the code breaks.
If you are compiling that only with gcc then '__attribute__ ((packed))'
on various structures will force gcc to generate a much more
careful access code - for a price, of course. Try '-S' flag and
see for yourself. :-) OTOH I really never tried that with arrays.
Michal
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 21:15 ` Michal Jaegermann
@ 2001-07-26 12:39 ` Ivan Kokshaysky
0 siblings, 0 replies; 13+ messages in thread
From: Ivan Kokshaysky @ 2001-07-26 12:39 UTC (permalink / raw)
To: axp-list
On Wed, Jul 25, 2001 at 03:15:09PM -0600, Michal Jaegermann wrote:
> If you are compiling that only with gcc then '__attribute__ ((packed))'
> on various structures will force gcc to generate a much more
> careful access code - for a price, of course.
Using memcpy() with constant size is fine as well, and is portable.
Modern GCC (>= 2.95) generates quite a good inline code for this.
Ivan.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 20:41 ` alvin
2001-07-25 21:08 ` Christopher C. Chimelis
2001-07-25 21:15 ` Michal Jaegermann
@ 2001-07-26 12:40 ` Ivan Kokshaysky
2001-07-26 13:29 ` Jay Estabrook
3 siblings, 0 replies; 13+ messages in thread
From: Ivan Kokshaysky @ 2001-07-26 12:40 UTC (permalink / raw)
To: axp-list
On Wed, Jul 25, 2001 at 03:41:33PM -0500, alvin wrote:
> > It generates some informational messages, but not one for every
> > unaligned access (if it did, there'd be a flood for the more serious
> > transgressors).
>
> Ahhhhhhhh the light goes on. Silly me I thought that since I have seen
> messages and fixing the code makes them go away that all the problems
> were tagged. Any quick pointer to the rule that is used for deciding
> what to flag and not?
To prevent a flood, the rate of "unaligned trap" messages is limited
to 4 messages in 5 ms.
Good place to look for unaligned traps is /proc/cpuinfo. There are
counts for kernel/user unaligned accesses and address of the
instruction caused last trap.
> > So, a little more about the problem you saw, and the machine you are
> > running on, please...
>
> I am running this on 2 systems a UP1100(last to show the problem) and a
> noname.
Note that unaligned "short int" accesses are special. In the code
compiled for ev4/ev5 (i.e. without byte/word extensions) they do not
generate unaligned traps and hence cannot be fixed by kernel. So if
the short int falls into the adjacent quadwords (addr & 7 == 7),
you'll have silent data corruption.
Ivan.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-25 20:41 ` alvin
` (2 preceding siblings ...)
2001-07-26 12:40 ` Ivan Kokshaysky
@ 2001-07-26 13:29 ` Jay Estabrook
2001-07-26 17:21 ` alvin
3 siblings, 1 reply; 13+ messages in thread
From: Jay Estabrook @ 2001-07-26 13:29 UTC (permalink / raw)
To: axp-list
On Wed, Jul 25, 2001 at 03:41:33PM -0500, alvin wrote:
>
> Any quick pointer to the rule that is used for deciding
> what to flag and not?
I think it is more of a "print max of 4 every so many seconds", rather
than a decision... ;-}
As Chris said, the pertinent code is in arch/alpha/kernel/traps.c
> but my feeling is that if there are a number of unaligned
> accesses that are back to back that is when the code breaks.
>
> The effect that I am seeing is that a 2 byte variable is not getting
> both bytes updated reliably. This problem appears or goes away depending
> on the alignment of the data.
>
>
> > So, a little more about the problem you saw, and the machine you are
> > running on, please...
>
> I am running this on 2 systems a UP1100(last to show the problem) and a
> noname.
> They are running serial consoles with RedHat 6.2 and kernel version:
>
> Linux version 2.2.19-6.2.1 (root@sws1) (gcc version egcs-2.91.66
> 19990314/Linux (egcs-1.1.2 release)) #6 Thu Jul 5 02:22:34 EDT 2001
OK; first off, you'll not get the EGCS 1.1.2 compiler fixed for this, if
it turns out to be the compiler's fault.
Second, if you can make a small test program that shows the problem under
EGCS, then we can do two things:
1. suggest work-around code for EGCS
2. test the latest compilers to make sure that it is fixed in them
Good luck.
--Jay++
-----------------------------------------------------------------------------
Jay A Estabrook Alpha Engineering - LINUX Project
Compaq Computer Corp. - MRO1-2/K20 (508) 467-2080
200 Forest Street, Marlboro MA 01752 Jay.Estabrook@compaq.com
-----------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-26 13:29 ` Jay Estabrook
@ 2001-07-26 17:21 ` alvin
2001-07-26 18:45 ` Frank Palmieri
0 siblings, 1 reply; 13+ messages in thread
From: alvin @ 2001-07-26 17:21 UTC (permalink / raw)
To: axp-list
Jay Estabrook wrote:
>
> On Wed, Jul 25, 2001 at 03:41:33PM -0500, alvin wrote:
[snip]
>
> OK; first off, you'll not get the EGCS 1.1.2 compiler fixed for this, if
> it turns out to be the compiler's fault.
>
> Second, if you can make a small test program that shows the problem under
> EGCS, then we can do two things:
>
> 1. suggest work-around code for EGCS
> 2. test the latest compilers to make sure that it is fixed in them
I am not wedded to egcs-1.1.2. I guess I will have to look for the
latest release of egcs/gcc.
> Good luck.
>
> --Jay++
>
> -----------------------------------------------------------------------------
> Jay A Estabrook Alpha Engineering - LINUX Project
> Compaq Computer Corp. - MRO1-2/K20 (508) 467-2080
> 200 Forest Street, Marlboro MA 01752 Jay.Estabrook@compaq.com
> -----------------------------------------------------------------------------
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
--
Alvin Starr || voice: (416)785-4051
Interlink Connectivity || fax: (416)785-3668
alvin@iplink.net ||
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Unaligned accesses
2001-07-26 17:21 ` alvin
@ 2001-07-26 18:45 ` Frank Palmieri
0 siblings, 0 replies; 13+ messages in thread
From: Frank Palmieri @ 2001-07-26 18:45 UTC (permalink / raw)
To: axp-list
Alvin:
There was a uac utility with Digital Unix that could control how unaligned
accesses were handled. Here's a little program that spawns a shell with the
fixup's disabled. When you run your program it will halt instead of doing
the fixups and you can then eliminate them. Note this can be "tedious" and
some programs such as emacs spew out unaligned accesses so be careful what
you run. Note also this code is old and I haven't used it in a while so it
may need a bit of rework but gives a place to start.
Frank
--------------------------------------------------
#include <asm/sysinfo.h>
#include <asm/unistd.h>
static int setsysinfo( unsigned long op, void *buffer, unsigned long size,
int *
start, void *arg, unsigned long flag )
{
syscall( __NR_osf_setsysinfo, op, buffer, size, start, arg, flag );
}
void trap_unaligned(void)
{
unsigned int buf[2];
buf[0] = SSIN_UACPROC;
buf[1] = UAC_SIGBUS | UAC_NOPRINT;
setsysinfo( SSI_NVPAIRS, buf, 1, 0, 0, 0 );
}
int main( int ac )
{
trap_unaligned();
printf("Creating a subshell with SIGBUS setting!\n" );
execl("/bin/bash", "/bin/bash", (char *)0);
return(0);
}
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2001-07-26 18:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-25 11:56 Unaligned accesses Rick Gorton
-- strict thread matches above, loose matches on Subject: below --
2001-07-25 0:02 Archives on www.lib.uaa.alaska.edu Mike Tibor
2001-07-25 0:57 ` Unaligned accesses alvin
2001-07-25 15:47 ` Jay Estabrook
2001-07-25 20:41 ` alvin
2001-07-25 21:08 ` Christopher C. Chimelis
2001-07-25 21:15 ` Michal Jaegermann
2001-07-26 12:39 ` Ivan Kokshaysky
2001-07-26 12:40 ` Ivan Kokshaysky
2001-07-26 13:29 ` Jay Estabrook
2001-07-26 17:21 ` alvin
2001-07-26 18:45 ` Frank Palmieri
1998-07-05 0:54 B. James Phillippe
1997-09-23 9:39 Sheer Panic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox