Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Sep 2012 20:53:54 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Dag-Erling Sm??rgrav <des@des.no>
Cc:        hackers@freebsd.org
Subject:   Re: fdgrowtable() cleanup
Message-ID:  <20120919175354.GV37286@deviant.kiev.zoral.com.ua>
In-Reply-To: <86lig6map1.fsf@ds4.des.no>
References:  <86wqzr8hbk.fsf@ds4.des.no> <20120919061005.GR37286@deviant.kiev.zoral.com.ua> <86lig6map1.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <kostikbel@gmail.com> writes:
> > "Dag-Erling Sm??rgrav" <des@des.no> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120919175354.GV37286>