* Re: Turning off 'unaligned trap' logging
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 ` Turning off 'unaligned trap' logging Jay Estabrook
1 sibling, 1 reply; 4+ messages in thread
From: Matt Wilson @ 2000-11-06 15:28 UTC (permalink / raw)
To: axp-list
That bit of code looks at the per-thread flags set by the OSF/1
getsysinfo/setsysinfo syscalls. AFAIK you would have to rebuild the
program to set the flags anyway, so why not just fix the unaligned
access...
Matt
On Mon, Nov 06, 2000 at 10:10:04AM -0500, Lew Randerson wrote:
> To all,
>
> 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.
>
> We are running Red Hat 6.1 and Red Hat 6.2 on ALPHA machines. The
> kernel is 2.2.16-3. The FORTRAN compiler is Compaq Fortran V1.0-920.
> The C compiler is egcs-2.91.66.
>
> Here's what the messages look like in /var/log/messages
> ====================================================================
> Jul 15 08:10:23 loki kernel: gotsc(1416): unaligned trap at
> 000000012010ad44: 0000000120188ba4 23 0
> Jul 15 08:10:23 loki kernel: gotsc(1416): unaligned trap at
> 000000012010ad54: 0000000120188ba4 23 1
> Jul 15 08:10:23 loki kernel: gotsc(1416): unaligned trap at
> 000000012010ad44: 0000000120188ba4 23 0
> Jul 15 08:10:23 loki kernel: gotsc(1416): unaligned trap at
> 000000012010ad54: 0000000120188ba4 23 1
> ====================================================================
>
>
> Here's an excerpt from arch/alpha/kernel/traps.c talking about this.
> ====================================================================
> do_entUnaUser(void * va, unsigned long opcode,
> unsigned long reg, struct pt_regs *regs)
> {
> static int cnt = 0;
> static long last_time = 0;
>
> unsigned long tmp1, tmp2, tmp3, tmp4;
> unsigned long fake_reg, *reg_addr = &fake_reg;
> unsigned long uac_bits;
> long error;
>
> /* Check the UAC bits to decide what the user wants us to do
> with the unaliged access. */
>
> uac_bits = (current->tss.flags >> UAC_SHIFT) & UAC_BITMASK;
> if (!(uac_bits & UAC_NOPRINT)) {
> if (cnt >= 5 && jiffies - last_time > 5*HZ) {
> cnt = 0;
> }
> if (++cnt < 5) {
> printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
> current->comm, current->pid,
> regs->pc - 4, va, opcode, reg);
> }
> last_time = jiffies;
> }
> ====================================================================
>
> As an aside. On our Red Hat 6.1 systems, we get two to four messages
> about every four minutes. On our only Red Hat 6.2 system with the
> same code, we get over 40 per minute.
>
> Thanks for any help, --Lew
>
>
>
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Turning off 'unaligned trap' logging
2000-11-06 15:10 Turning off 'unaligned trap' logging Lew Randerson
2000-11-06 15:28 ` Matt Wilson
@ 2000-11-09 3:51 ` Jay Estabrook
1 sibling, 0 replies; 4+ messages in thread
From: Jay Estabrook @ 2000-11-09 3:51 UTC (permalink / raw)
To: axp-list
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
--
^ permalink raw reply [flat|nested] 4+ messages in thread