From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 19 17:54:01 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FE10106566B for ; Wed, 19 Sep 2012 17:54:01 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6278D8FC08 for ; Wed, 19 Sep 2012 17:53:59 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q8JHs6QF067387; Wed, 19 Sep 2012 20:54:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5) with ESMTP id q8JHrsd2045052; Wed, 19 Sep 2012 20:53:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q8JHrs6T045051; Wed, 19 Sep 2012 20:53:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 19 Sep 2012 20:53:54 +0300 From: Konstantin Belousov To: Dag-Erling Sm??rgrav Message-ID: <20120919175354.GV37286@deviant.kiev.zoral.com.ua> References: <86wqzr8hbk.fsf@ds4.des.no> <20120919061005.GR37286@deviant.kiev.zoral.com.ua> <86lig6map1.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EAxp3f1s+pEXSACT" Content-Disposition: inline In-Reply-To: <86lig6map1.fsf@ds4.des.no> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: hackers@freebsd.org Subject: Re: fdgrowtable() cleanup X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2012 17:54:01 -0000 --EAxp3f1s+pEXSACT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 19, 2012 at 02:58:02PM +0200, Dag-Erling Sm??rgrav wrote: > Konstantin Belousov writes: > > "Dag-Erling Sm??rgrav" writes: > > > + otable =3D fdp->fd_ofiles; > > > + ofileflags =3D fdp->fd_ofileflags; > > These two new calculations could be unused if the function return early. >=20 > I assume you mean assignments, not calculations. I trust the compiler > to move them to where they are needed - a trivial optimization with SSA. It is a dereference before the assignment, so I perceive it as the calculation. No, I do not think that compiler can move the dereference, because there are many sequential points between the calculation and use of the result. >=20 > > > + ntable =3D malloc(nnfiles * sizeof(*ntable) + > > > + nnfiles * sizeof(*nfileflags) + > > > + sizeof(struct freetable), > > > M_FILEDESC, M_ZERO | M_WAITOK); > > Please use the horizontal space less lavishly. >=20 > I was aiming for readability, not compatibility with equipment that went > out of use before I was born. Well, my eyes can only see so many lines in the emacs window. So if you referenced older equipment meaning me being born before you, so be it. :) >=20 > > I think that this calculation, as well as fo calculation below, does > > not take a required alignment of struct freetable into consideration. >=20 > Correct, thanks for pointing it out. The easiest solution is to place > the struct freetable between the file array and the flag array. As I know, for all ABIs FreeBSD run on, the structure alignment is the alignment of the most requiring member. You would introduce very tacit dependency between struct file and struct freetable. --EAxp3f1s+pEXSACT Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAlBaBrIACgkQC3+MBN1Mb4hjtgCgmNUya61J4VWgGSllJn1dbHeL KT0An2hj2M6XWopB1+Ak/w6eDtAz76mE =rNl1 -----END PGP SIGNATURE----- --EAxp3f1s+pEXSACT--