Date: Sat, 13 Dec 2014 22:50:11 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Chagin Dmitry <dchagin@freebsd.org> Cc: Benjamin Kaduk <bjkfbsd@gmail.com>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org> Subject: Re: svn commit: r275751 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20141213215011.GA17746@dft-labs.eu> In-Reply-To: <20141213213111.GA2070@dchagin.static.corbina.net> References: <201412132100.sBDL0BvR094009@svn.freebsd.org> <CAJ5_RoCnMNEEa86besbhfKTxf-wOhwBy%2BjktLB7%2Bod=zkSQ6Aw@mail.gmail.com> <20141213213111.GA2070@dchagin.static.corbina.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <dchagin@freebsd.org> 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 <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141213215011.GA17746>