From owner-freebsd-tinderbox@FreeBSD.ORG Wed Feb 18 18:19:36 2009 Return-Path: Delivered-To: tinderbox@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E73F31065686; Wed, 18 Feb 2009 18:19:36 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout021.mac.com (asmtpout021.mac.com [17.148.16.96]) by mx1.freebsd.org (Postfix) with ESMTP id CF3138FC23; Wed, 18 Feb 2009 18:19:36 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from dpham-t61.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp021.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0KF9006SNXKNQS10@asmtp021.mac.com>; Wed, 18 Feb 2009 10:19:36 -0800 (PST) Message-id: From: Marcel Moolenaar To: "M. Warner Losh" In-reply-to: <20090217.235826.-1697751865.imp@bsdimp.com> Date: Wed, 18 Feb 2009 10:19:34 -0800 References: <4CB77F1D-4235-47D8-B654-1C4F29B6C649@mac.com> <20090217.234216.1276682135.imp@bsdimp.com> <20090217.235826.-1697751865.imp@bsdimp.com> X-Mailer: Apple Mail (2.930.3) Cc: mips@FreeBSD.org, tinderbox@FreeBSD.org, current@FreeBSD.org Subject: Re: [head tinderbox] failure on mips/mips X-BeenThere: freebsd-tinderbox@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Tinderbox reports, responses, and meta-comments" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2009 18:19:38 -0000 On Feb 17, 2009, at 10:58 PM, M. Warner Losh wrote: > In message: > Marcel Moolenaar writes: > : > : On Feb 17, 2009, at 10:42 PM, M. Warner Losh wrote: > : > : > : A safer approach is to mark ifi_epoch as packed or put > differently, > : > : define time_t as a 64-bit integral with 32-bit alignment. This > can > : > : avoid a lot of unexpected internal padding as well (e.g. struct > : > : timeval). > : > > : > Marking it as packed won't help. If the elements aren't properly > : > aligned, gcc won't access multi-word entities properly. It might > : > eliminate the warning, but it will break at runtime. > : > : But GCC will use a pair of 32-bit loads and/or stores to > : access the 64-bit integral in that case. There should be > : no runtime breakage. You only do this for n32 of course. > > Why only n32? Registers are still 64-bit in n32. I think that's the problem. With registers still 64-bit, MIPS n32 isn't really behaving like a 32-bit machine in the case of 64-bit accesses. It's that aspect you want to tweak. So, if you give all 64-bit integrals an alignment of 4 bytes, then GCC will use a pair of 32-bit loads and stores (just like, say, powerpc) and you don't run into the alignment problems where all of a sudden a data structure gets 8-byte alignment, triggers warnings, and we try to correct it with kluges. For MIPS n64 things are like any other LP64 architecture, so you don't have to tweak anything. In other words: by tweaking the alignment of 64-bit types in n32, you prohibit GCC from using the 64-bit capabilities of the processor and MIPS isn't so weird anymore. NOTE: On ARM, GCC aligns structures to a 4-byte boundary by default. This has caused us problems and instead of fixing the default behaviour of the compiler, we slammed __packed onto structures. If we had changed the default behaviour of the compiler, then all structures would be naturally aligned and we would be able to use the half-word memory accesses that newer ARM processors have. No, we __packed the lot and created a big performance bottleneck because now we can only use byte-wise memory accesses. What was done for performance (default alignment of 4-bytes for structures), was turned into a huge pessimisation by us compensating with __packed. We have more optimal code if the compiler aligns structures on their natural boundary! The point being that programmers *do* code with certain assumptions and as soon as those assumptions don't hold on a platform, you end up worse off. My thoughts for MIPS n32 are to make it behave like any "normal" 32-bit strong- alignment platform to avoid 1) a large number of runtime alignment faults -- which are a bigger performance bottleneck than forcing 64-bit integrals to be accessed with 2 32-bit accesses and 2) avoid further abuse of __packed, which turns all accesses in a series of byte-wise accesses. At Juniper I changed the ARM compiler default by adding: -mstructure-size-boundary=8 That made life a *lot* simpler and performance hasn't been sacrificed. Just an explanation of where I'm coming from... -- Marcel Moolenaar xcllnt@mac.com