From: Jay Estabrook <Jay.Estabrook@compaq.com>
To: axp-list@redhat.com
Subject: Re: Turning off 'unaligned trap' logging
Date: Wed, 8 Nov 2000 22:51:07 -0500 [thread overview]
Message-ID: <20001108225107.A3021@linux04.mro.cpqcorp.net> (raw)
In-Reply-To: <4.2.0.58.20001106095341.016c4c10@pop.Pppl.GOV>; from LRanderson@PPPL.Gov on Mon, Nov 06, 2000 at 10:10:04AM -0500
On Mon, Nov 06, 2000 at 10:10:04AM -0500, Lew Randerson wrote:
>
> How do we turn off printing of the unaligned trap messages to
> /var/log/messages? There's an implication in the kernel code
> that this is a user option. The alignment problem itself is
> probably in our 'mpich-1.2.0' package but until that is resolved
> we need to turn of the printing since particularly on our Red Hat
> 6.2 system it is causing a big load on syslogd.
Find attached to the end a posting by Michal last May that includes a
potentially useful code snippet (after modification) for controlling
the printing of those messages, along with some reasonable explication
re: cause/cure of unaligned accesses.
Sure, you can make the *messages* go away, but your program's
performance is going to continue to be terrible, as the traps into the
kernel to handle the unaligned access will still be happening.
Take Matt's suggestion and go for the fix as well.
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
-----------------------------------------------------------------------------
From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
Subject: Re: Fixing "unaligned trap" errors
To: axp-list@redhat.com
Date: Sat, 20 May 2000 11:41:42 -0600 (MDT)
In-Reply-To: <87g0re2zui.fsf@linuxcare.com> from "David Huggins-Daines" at May 19, 2000 01:51:01 PM
David Huggins-Daines posted a very informative archive on the "unaligned
trap" problem which explains what it is in a much greater detail than
FAQ entry on www.alphalinux.org. :-)
I still have some commments. First, it looks like that one again it is
a time for a "periodic posting" (it was posted on this list in the past
more than once) of a program which is of a great help if one is hunting
for troublesome spots. An advantage of it is that you will get a bomb
instead of a trap and a message so you can catch its location in a
debugger like gdb. Here it goes:
/****
From: "Christian Groessler" <cpg@aladdin.de>
To: axp-list@redhat.com
Date: Thu, 19 Aug 1999 10:52:55 +0100
Subject: Re: Unaligned traps et al
The following program creates a subshell and all programs
started from therein will SIGBUS on unaligned accesses.
***/
/* 28-May-98, chris */
#ifndef __linux__
#include <sys/sysinfo.h>
#else
#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);
}
#endif
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);
}
#include <stdio.h>
int main()
{
trap_unaligned();
printf("creating subshell with SIGBUS setting!\n");
execl("/bin/bash","/bin/bash",(char *)0);
return(0); /* not reached */
}
>
> /* sizeof(struct foo) == 12 */
^^^^^^^^^^^^^^^
Don't bet on it!!!
> struct foo {
> int a, b, c;
> };
A C compiler, by its definition, is free to allocate a structure with
"holes" so sizeof(struct foo) __may__ turn out to be, say, 24 even if
sum of sizes of this structure elements are 12. In this particular case
you can, probably, assume that a compiler is relatively "sane" and that
sizeof(struct foo) is indeed 12 even without checking but I have seen
problems caused by similar, if not so blatant, assumptions. The problem
is compounded by the fact that C does not really provide a good portable
way out of this bind (save, possibly, of making this into an array of
bytes). gcc has for such occasions , mentioned by David, '__attribute__
((packed))' construct but this is a compiler specific extension.
If you peek inside Linux kernel headers (NOT glibc headers) then
you will find multiple instances where '__attribute__ ((packed))'
was used as a layout of many structures has to be tightly controlled.
A code generated by gcc to access structure elements may not be the
same in an absence or presence of '__attribute__ ((packed))' - even
if a structure layout in memory happens to be identical. In the later
case you will not see "unaligned access" messages - if your code
was otherwise correct. :-) If a code is meant to be used with
some other compiler you may use a preprocessor to hide conditionally
such bits (define a macro which expands to __attribute__ ((packed))
or to nothing - depending on a compiler used) but what other compiler
will do with your structures and a code cannot be predicted in advance.
Last, but not least, I encountered cases when "unaligned accesses"
were side-effects of real bugs. For example, trying to store
long in a space which was allocated for int, or an attempt to
access a wrong location on a stack, __may__ end up with an
unaligned trap. OTOH it may not, so do not take that for a reliable
indicator, but problems of that sort are worth of an investigation
not only for a performance reasons.
Michal
--
prev parent reply other threads:[~2000-11-09 3:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-06 15:10 Turning off 'unaligned trap' logging Lew Randerson
2000-11-06 15:28 ` Matt Wilson
2000-11-06 16:12 ` SOCKSify my Services? SteveCraft
2000-11-09 3:51 ` Jay Estabrook [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox