Date: Sun, 13 Jul 2014 16:26:52 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Mateusz Guzik <mjguzik@gmail.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Mateusz Guzik <mjg@FreeBSD.org> Subject: Re: svn commit: r267760 - head/sys/kern Message-ID: <20140713132652.GZ93733@kib.kiev.ua> In-Reply-To: <20140711111925.GB18214@dft-labs.eu> References: <20140623064044.GD93733@kib.kiev.ua> <20140623070652.GA27040@dft-labs.eu> <20140623072519.GE93733@kib.kiev.ua> <20140623080501.GB27040@dft-labs.eu> <20140623081823.GG93733@kib.kiev.ua> <20140623131653.GC27040@dft-labs.eu> <20140623163523.GK93733@kib.kiev.ua> <20140711024351.GA18214@dft-labs.eu> <20140711095551.GA93733@kib.kiev.ua> <20140711111925.GB18214@dft-labs.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
--6oyQcS9tDCFX8NZZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 11, 2014 at 01:19:25PM +0200, Mateusz Guzik wrote: > On Fri, Jul 11, 2014 at 12:55:51PM +0300, Konstantin Belousov wrote: > > On Fri, Jul 11, 2014 at 04:43:51AM +0200, Mateusz Guzik wrote: > > > In both cases the same mechanism blocks both exec and exit, this can = be > > > split if needed (p_lock would still cover exit, p_something would cov= er > > > exec). > > >=20 > > > Here is a version with sx lock: > > >=20 > > > http://people.freebsd.org/~mjg/patches/exec-exit-hold-wait.patch > > >=20 > > > I'm not really happy with this. Reading foreign fdt is very rare and > > > this adds lock + unlock for every exec and exit. > > >=20 > > > On the other hand mere counter version is rather simple: > > >=20 > > > http://people.freebsd.org/~mjg/patches/exec-exit-hold-nolock.patch > > >=20 > > > I don't have strong opinion here, but prefer the latter. > >=20 > > I suggest the name 'imagelock' for the beast. > >=20 >=20 > Sounds good. >=20 > > The nolock version requires two atomics on both entry and leave from the > > protected region, while sx-locked variant requires only one atomic for > > entry and leave. > >=20 > > I am not sure why you decided to acquire p->p_keeplock in after the > > proc lock in pget(), which indeed causes the complications of dropping > > the proc_lock and rechecking to avoid LOR. Did you tried to add a flag > > to pfind*() functions to indicate that p_keeplock should be acquired, > > instead ? >=20 > Lock is taken later to avoid waiting for finished exec/exit of processes > we cannot return, so that e.g. procstat -fa does not trip over that > much. >=20 > Right now only PROC_LOCK guarantees stability of p->p_ucred across pget > operation. Without that the code would have to crget() and various > functions modified to accept cred instead of proc, or 'imagelock' > mechanism would have to be extended to also protect against cred > changes. No, you could get both locks, imagelock first, proc_lock next. >=20 > That said, the code could be indeed changed to sx requiring one atomic > on entry and leave, but that would still leave us with such atomics in > exit and exec and the last 2 are way more common than the first one, > thus I prefer counter case which only adds lock + unlock on leave. >=20 > --=20 > Mateusz Guzik <mjguzik gmail.com> --6oyQcS9tDCFX8NZZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJTwokcAAoJEJDCuSvBvK1B9uYP/3qVVRVnC4nQqctDRFAzmZFJ sMgfkHF9sCDmUgWWuwBUYlLj0PIjjFGdyxdckf7MFsaNrE1jfMoK1PMmWePgmOOa 3J5+kej8zqgxLNxxOzlQ08JiVykYmfaMco41Zl34l5b3MyTgTISpg8X5lwVMs1e+ 0xsOmbgm5691xDGoS/hz0tr3MUzC9Us36yh7CWe9eFPtMliZpHdOdD9dMJr2+rDe MpTMCtYW+A6edi18ylSNO8caeijj7Ef9pidWpd+Z+9uP6r1Aqnmz+5toSzGqEQEs dgT9B3GQvvX6VSc/cYcu/TeZODQ3VLp4G2A8q8FiwDsZs+Bn1Wx3AGIubApyYLgR ev6n3qkwVoJA4TeoybS9i9V3nzlqHADrKrRcKPKh6hAZzRIIaK1LwXm5Cry8ep3E U8f0ryP7wzttJwuPQ/mXLZXzPsyFPmYRgZ9Vn90+TZqNa69wPqbDYAFivXD3Cuif kJ6hRIByebP5/n0NE+3yllSqj2r71wVwX1ZsgbJrqQCqiaQY/LHcnuKkdwkl6HKe a8ryUoXEJ9NTWa5WLFEINwOSz5n93r3mpNySNXW+3Tglllh6i+LZzcf4DKonShwq //X1C0XpF5gvCts1/UPPiLGFubDN8IVT5nLnm+on0yGwTcjHo7r7r/95Sq+Ti8l5 4hXXwXKMawvQa8pyvOyk =G9+G -----END PGP SIGNATURE----- --6oyQcS9tDCFX8NZZ--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140713132652.GZ93733>