Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Jul 2014 16:25:21 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Getting rid of atomic_load_acq_int(&fdp->fd_nfiles)) from fget_unlocked
Message-ID:  <20140713132521.GY93733@kib.kiev.ua>
In-Reply-To: <20140713035500.GC16884@dft-labs.eu>
References:  <20140713035500.GC16884@dft-labs.eu>

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

--pDmaGFxwxkQ3NNKB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jul 13, 2014 at 05:55:00AM +0200, Mateusz Guzik wrote:
> Currently:
>         /*
>          * Avoid reads reordering and then a first access to the
>          * fdp->fd_ofiles table which could result in OOB operation.
>          */
>         if (fd < 0 || fd >=3D atomic_load_acq_int(&fdp->fd_nfiles))
>                 return (EBADF);
>=20
> However, if we put fd_nfiles and fd_otable into one atomically replaced
> structure the only need to:
> 1. make sure the pointer is read once
> 2. issue a data dependency barrier - this is a noop on all supported
> architectures and we don't even have approprate macro, so doing nothing
> seems fine
>=20
> The motivation is to boost performance to amortize for seqlock cost, in
> case it hits the tree.
>=20
> This has no impact on races with capability lookup.
>=20
> In a microbenchmark of 16 threads reading from the same pipe fd
> immediately returning EAGAIN the numbers are:
> x vanilla-readpipe-run-sum            =20
> + noacq-readpipe-run-sum
> [..]
>     N           Min           Max        Median           Avg        Stdd=
ev
> x  20      13133671      14900364      13893331      13827075     471500.=
82
> +  20      59479718      59527286      59496714      59499504     13752.9=
68
> Difference at 95.0% confidence
> 	4.56724e+07 +/- 213483
> 	330.312% +/- 1.54395%
>=20
> There are 3 steps:
> 1. tidy up capsicum to accept fde:
> http://people.freebsd.org/~mjg/patches/single-fdtable-read-capsicum.patch
> 2. add __READ_ONCE:
> http://people.freebsd.org/~mjg/patches/read-once.patch
> 3. put stuff into one structure:
> http://people.freebsd.org/~mjg/patches/filedescenttable.patch
>=20
> Comments?

We use 4-space indent for the continuation lines.  Look at the malloc(9)
call in the patch 3.

The filedescenttable is really long name.  Could it be, for instance,
fdescenttbl ?

Other than that, I think that the patches 2 and 3 are fine.  I did not
looked at the patch 1.

--pDmaGFxwxkQ3NNKB
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJTwojAAAoJEJDCuSvBvK1BtIsP/3zuyAmdtT1PqaKnkriAsFQX
ZAfDbBn61QpeaGLH2Diz4Cpa+Hq2W8BACL5RlWWbiYBgZhjMzSwv4tc/boORQQUn
ObBbmNbCvjvUsxKgD3TfZR6XX0zuPiYnKZymhL3v/25ZyR9iTgWitGywQPVPOvgr
G8NiONimPIQT8Mn70f57YwLFdnqThmuLFAXGfKOVH9+1dtBsIqEfQ8r8dasd6rDK
iozaCjXDeAtpqNCDJ3xuA4ZxErZHptqaL9oz0kdOOXHLKm++WKvcaGJD8JPfHWHq
2BsQ8HKAxKeipxMT1lTR1fpq6Jabjawed6mSrhZmFBYn37FcXSu5IFN86MiyR3sy
cXCysNoa9jLnzmQirvzgTYs0l1H28nIE8YCHAWdOtWsOkGWr/0LhFXXAkMagrhum
tC/+8IUMiK8STTPVSD34ejuylP7KpLrCsTWMbjgqisRiHBC+F7Mcw3XvCuv7cd8k
vjR0JQ2kOFe1vctHd2PmtKG3Pzc8egARmIAfRcHSIYoB3d4yVLldJ+9OqWjyTIJA
GhKJ4LV1PLQz/uI7ZxVQ7UBOlVfQUn/qIidoJ7+2QULAsbRSUmucoDEvJT1CsqsN
6zItQLo87f4S5VjREbT/86euGaoiThwDbdaXeDLkoWKksVQiLud8qmHhJPg4tNZj
rN23tB0N9qoHWLrSFwY4
=nHRc
-----END PGP SIGNATURE-----

--pDmaGFxwxkQ3NNKB--



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