From owner-svn-src-head@FreeBSD.ORG Sun Jul 13 13:27:03 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 53C00506; Sun, 13 Jul 2014 13:27:03 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE98B269B; Sun, 13 Jul 2014 13:27:02 +0000 (UTC) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s6DDQqqG093348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 13 Jul 2014 16:26:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s6DDQqqG093348 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s6DDQqNV093347; Sun, 13 Jul 2014 16:26:52 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 13 Jul 2014 16:26:52 +0300 From: Konstantin Belousov To: Mateusz Guzik Subject: Re: svn commit: r267760 - head/sys/kern Message-ID: <20140713132652.GZ93733@kib.kiev.ua> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6oyQcS9tDCFX8NZZ" Content-Disposition: inline In-Reply-To: <20140711111925.GB18214@dft-labs.eu> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Mateusz Guzik X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jul 2014 13:27:03 -0000 --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 --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--