From owner-svn-src-all@FreeBSD.ORG Thu Oct 25 02:07:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0CBF7AE1 for ; Thu, 25 Oct 2012 02:07:42 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 5AF408FC16 for ; Thu, 25 Oct 2012 02:07:40 +0000 (UTC) Received: (qmail 37904 invoked from network); 25 Oct 2012 03:45:24 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 25 Oct 2012 03:45:24 -0000 Message-ID: <50889EE0.8030105@freebsd.org> Date: Thu, 25 Oct 2012 04:07:28 +0200 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: attilio@FreeBSD.org Subject: Re: svn commit: r242014 - head/sys/kern References: <201210241836.q9OIafqo073002@svn.freebsd.org> <201210241443.25988.jhb@freebsd.org> <50884E9F.3090706@freebsd.org> <508855DA.1080903@freebsd.org> In-Reply-To: <508855DA.1080903@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Jim Harris , John Baldwin X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2012 02:07:42 -0000 On 24.10.2012 22:55, Andre Oppermann wrote: > On 24.10.2012 22:29, Attilio Rao wrote: >> On Wed, Oct 24, 2012 at 9:25 PM, Andre Oppermann wrote: >>> On 24.10.2012 21:06, Attilio Rao wrote: >>>> As I've already said in another thread __align() doesn't work on >>>> object declaration, so what that won't pad it either if it is global >>>> or part of a struct. >>>> It is just implemented as __attribute__((aligned(X))): >>>> http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Type-Attributes.html >>> >>> >>> Actually it seems gcc itself doesn't really care and it up to the >>> linker to honor that. >> >> Yes but the concept being that if you use __aligned() properly (when >> defining a struct) the object will be correctly sized, so you will get >> padding automatically. > > Yes. With __aligned() the start of the element/structure should > begin on an address evenly dividable by the align value *and* it > should pad out any remaining space up to the next evenly dividable > address. > > The problem we have is that is apparently doesn't work correctly > within gcc when creating structs nor within the linker when placing > such supposedly aligned structs in the .bss section (at least the > padding is missing). I spoke too soon. Attilio is completely right in his assessment. It does work when done on the struct definition: struct mtx { ... } __aligned(CACHE_LINE_SIZE); /* works including .bss alignment & padding */ When creating a struct (in globals at least) it doesn't work: struct mtx __aligned(CACHE_LINE_SIZE) foo_mtx; /* doesn't work */ > It seems to come down to either a) fixing gcc+ld; or b) hacking > around it by magically padding the structs that require it. The question now becomes of whether we can (should?) make the latter case above work or find another workaround. -- Andre