From owner-svn-src-head@FreeBSD.ORG Sun Dec 14 06:33:52 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F558B03; Sun, 14 Dec 2014 06:33:52 +0000 (UTC) Received: from dchagin.static.corbina.net (dchagin.static.corbina.ru [78.107.232.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "dchagin.static.corbina.net", Issuer "dchagin.static.corbina.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A90C13D; Sun, 14 Dec 2014 06:33:50 +0000 (UTC) Received: from dchagin.static.corbina.net (localhost [127.0.0.1]) by dchagin.static.corbina.net (8.14.9/8.14.9) with ESMTP id sBE6Xl9O002987 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 14 Dec 2014 09:33:47 +0300 (MSK) (envelope-from dchagin@dchagin.static.corbina.net) Received: (from dchagin@localhost) by dchagin.static.corbina.net (8.14.9/8.14.9/Submit) id sBE6XlIb002986; Sun, 14 Dec 2014 09:33:47 +0300 (MSK) (envelope-from dchagin) Date: Sun, 14 Dec 2014 09:33:47 +0300 From: Chagin Dmitry To: Mateusz Guzik Subject: Re: svn commit: r275751 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20141214063346.GA2966@dchagin.static.corbina.net> References: <201412132100.sBDL0BvR094009@svn.freebsd.org> <20141213213111.GA2070@dchagin.static.corbina.net> <20141213215011.GA17746@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20141213215011.GA17746@dft-labs.eu> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Benjamin Kaduk , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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, 14 Dec 2014 06:33:52 -0000 On Sat, Dec 13, 2014 at 10:50:11PM +0100, Mateusz Guzik wrote: > On Sun, Dec 14, 2014 at 12:31:11AM +0300, Chagin Dmitry wrote: > > On Sat, Dec 13, 2014 at 04:03:47PM -0500, Benjamin Kaduk wrote: > > > On Sat, Dec 13, 2014 at 4:00 PM, Dmitry Chagin = wrote: > > > > > > > > Author: dchagin > > > > Date: Sat Dec 13 21:00:10 2014 > > > > New Revision: 275751 > > > > URL: https://svnweb.freebsd.org/changeset/base/275751 > > > > > > > > Log: > > > > Add _NEW flag to mtx(9), sx(9), rmlock(9) and rwlock(9). > > > > A _NEW flag passed to _init_flags() to avoid check for double-ini= t. > > > > > > > > > > > Can you please say a bit more about why this is desired and what it w= ill be > > > used for? > > >=20 > > If the kernel has been compiled with INVARIANTS _init() will assert tha= t the > > lock has not been initialized multiple times. _NEW flag is needed to sk= ip this. > > as _init() does expect you to zero lock first. > > it should be used carefully, when you are sure its safe, > > to avoid bzero'ing lock struct. ugh > >=20 >=20 > I think the actual question was when would you call _init_flags and not > want _NEW and it would have a potential to detect double init. >=20 > I think a better approach would be to have a hash with addresses of all > locks in use. Then _init/_destroy would add/remove it respectively and > we would not be dependent on the state of the lock (e.g. struct could be > zeroed by unrelated code and then double init is not detected). >=20 > Chains locked separately of course. >=20 > I didn't try that, should be totally fine for invariants. >=20 maybe you're right, I think it would be overkill --=20 Have fun! chd