From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id 8640E2F06B for ; Wed, 8 Nov 2000 22:52:09 -0500 (EST) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id eA93q9r03813 for axp-list@listman.redhat.com; Wed, 8 Nov 2000 22:52:09 -0500 Received: from zmamail02.zma.compaq.com (zmamail02.zma.compaq.com [161.114.64.102]) by mail.redhat.com (8.11.0/8.8.7) with ESMTP id eA93q8D03809 for ; Wed, 8 Nov 2000 22:52:09 -0500 Received: by zmamail02.zma.compaq.com (Postfix, from userid 12345) id A9DBC4D2E; Wed, 8 Nov 2000 22:52:03 -0500 (EST) Received: from linux04.mro.cpqcorp.net (linux04.mro.cpqcorp.net [16.129.9.99]) by zmamail02.zma.compaq.com (Postfix) with ESMTP id 7AE384DF3 for ; Wed, 8 Nov 2000 22:52:03 -0500 (EST) Received: (from jestabro@localhost) by linux04.mro.cpqcorp.net (8.9.3/8.9.3) id WAA03086 for axp-list@redhat.com; Wed, 8 Nov 2000 22:51:07 -0500 Date: Wed, 8 Nov 2000 22:51:07 -0500 From: Jay Estabrook To: axp-list@redhat.com Subject: Re: Turning off 'unaligned trap' logging Message-ID: <20001108225107.A3021@linux04.mro.cpqcorp.net> Mail-Followup-To: axp-list@redhat.com References: <4.2.0.58.20001106095341.016c4c10@pop.Pppl.GOV> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i 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 X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors 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 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" 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 #else #include #include 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 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 --