From owner-svn-src-all@FreeBSD.ORG Sat Dec 13 21:50:17 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4EEDDAB7; Sat, 13 Dec 2014 21:50:17 +0000 (UTC) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CDEB7BB6; Sat, 13 Dec 2014 21:50:16 +0000 (UTC) Received: by mail-wi0-f174.google.com with SMTP id h11so5578546wiw.7; Sat, 13 Dec 2014 13:50:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=753+Ol4TPlz+3KGRaNeiqn+NUzcB02WKKSLaN6E9bow=; b=kBn1Xwh4jj5GM8gn6zhHshg2F619qPlUxL2XOwWaa/5eyCJwSjur7r6YtCK80fMxDu 2+ol4H0jbJei5lfHzXxGyfELZR99gC75MiChVx5RB9iFXt0ofPTPttvSR0Qi8zZLdi27 jq+iLgAGxeBahji7Jvnpc5NIV0LSn/i5gKWot5LdFsTKYFrfCf6291OmXDd86MKaneEX M4GIkoxek3DBxoXSB5RirKPPbgMoJMtNWEAwv080GLKdEhSVjUWqTQfNIB+a4cdDjPiR vR3vd9/zbskwJU4mUTW9dcuNbRaODvpflZld05hKdN4khA1ktE/iO9wpfrgyamqPxFca TYLg== X-Received: by 10.194.71.45 with SMTP id r13mr37885157wju.128.1418507415140; Sat, 13 Dec 2014 13:50:15 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id u9sm6904363wjy.37.2014.12.13.13.50.13 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 13 Dec 2014 13:50:14 -0800 (PST) Date: Sat, 13 Dec 2014 22:50:11 +0100 From: Mateusz Guzik To: Chagin Dmitry Subject: Re: svn commit: r275751 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20141213215011.GA17746@dft-labs.eu> References: <201412132100.sBDL0BvR094009@svn.freebsd.org> <20141213213111.GA2070@dchagin.static.corbina.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20141213213111.GA2070@dchagin.static.corbina.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Benjamin Kaduk , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Dec 2014 21:50:17 -0000 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-init. > > > > > > > > Can you please say a bit more about why this is desired and what it will be > > used for? > > > If the kernel has been compiled with INVARIANTS _init() will assert that the > lock has not been initialized multiple times. _NEW flag is needed to skip 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 > 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. 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). Chains locked separately of course. I didn't try that, should be totally fine for invariants. -- Mateusz Guzik