From owner-svn-src-all@FreeBSD.ORG Fri Apr 24 11:46:25 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 704693A5; Fri, 24 Apr 2015 11:46:25 +0000 (UTC) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B3A71EBB; Fri, 24 Apr 2015 11:46:24 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::dd55:8565:6cfd:c136] (unknown [IPv6:2001:7b8:3a7:0:dd55:8565:6cfd:c136]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 959A65C37; Fri, 24 Apr 2015 13:46:13 +0200 (CEST) Subject: Re: svn commit: r281451 - head/sys/vm Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/signed; boundary="Apple-Mail=_8DD2A96B-B49A-4354-B6F8-DA5E952FE9B0"; protocol="application/pgp-signature"; micalg=pgp-sha1 X-Pgp-Agent: GPGMail 2.5b6 From: Dimitry Andric In-Reply-To: <201504241101.t3OB1O8Z029626@elf.torek.net> Date: Fri, 24 Apr 2015 13:46:10 +0200 Cc: Adrian Chadd , scott4long@yahoo.com, dchagin@freebsd.org, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-Id: <695B6002-002A-406C-B843-0DCFE24F81BD@FreeBSD.org> References: <201504241101.t3OB1O8Z029626@elf.torek.net> To: Chris Torek X-Mailer: Apple Mail (2.2098) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Fri, 24 Apr 2015 11:46:25 -0000 --Apple-Mail=_8DD2A96B-B49A-4354-B6F8-DA5E952FE9B0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 24 Apr 2015, at 13:01, Chris Torek wrote: > > The problem seems likely to be related to odd compiler handling of > alignment. Consider this code bit, which extracts the essentials: > > struct x { > int x; > } __attribute__((__aligned__(32))); > > struct s1 { > int a; > struct x b[1]; > }; > > struct s2 { > int a; > struct x b[]; > }; > > extern void test2(int); > void test(void) { > test2(sizeof(struct s1)); > test2(sizeof(struct s2)); > } > > Compiled, here are the two sizeof values (this particular compiler > output is from clang but gcc and clang both agree on sizeof here): > > movl $64, %edi > callq test2 > movl $32, %edi > popq %rbp > jmp test2 # TAILCALL > > With the flexible array, (sizeof(struct uma_cache)) is going to be > 32 bytes smaller than without it. > > (I have not looked closely enough to determine what the size should be.) I'm not sure I would consider this odd. For purposes of sizeof(), the flexible array member declaration can be thought of as: struct x b[0]; so while both struct s1 and s2 have members that must be aligned at 32 bytes, the former has one extra, while the latter doesn't. Ergo, 2x32 bytes and 1x32 bytes. -Dimitry --Apple-Mail=_8DD2A96B-B49A-4354-B6F8-DA5E952FE9B0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.27 iEYEARECAAYFAlU6LQUACgkQsF6jCi4glqNeDACgyo1jXpFzVxfNg/zHVgEuBuZf xjEAoLKT7Ltnjr0YIk7QQvawoQxwA808 =9NxY -----END PGP SIGNATURE----- --Apple-Mail=_8DD2A96B-B49A-4354-B6F8-DA5E952FE9B0--