Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Oct 2017 18:30:50 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Svatopluk Kraus <skra@freebsd.org>, Mateusz Guzik <mjg@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r324609 - head/sys/sys
Message-ID:  <1507941050.8386.88.camel@freebsd.org>
In-Reply-To: <CAFHCsPUzYewo1AaaKFE9LKVdUEw3Tr7c=Qpb=ah9XpwZ-OEEtg@mail.gmail.com>
References:  <201710132031.v9DKVueS089009@repo.freebsd.org> <CAFHCsPUzYewo1AaaKFE9LKVdUEw3Tr7c=Qpb=ah9XpwZ-OEEtg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2017-10-13 at 23:38 +0200, Svatopluk Kraus wrote:
> MTX_UNOWNED is a flag. You did not change its value from 4 to 0, you
> removed it actually. I have very bad feeling about it. But maybe, it's
> really possible and in that case, a very good explanation should be
> provided.
> 
> Svata
> 

The part that scares me is that DESTROYED may have been defined as
CONTESTED|UNOWNED for subtle and clever reasons lost in the mists of
time.  Any of the places that are testing the MTX_CONTESTED bit may
have been relying somehow on the fact that a destroyed mutex has that
bit set.

Then again, maybe Mateusz has carefully analyzed all this stuff, and we
should just relax. :)

-- Ian

> 
> On Fri, Oct 13, 2017 at 10:31 PM, Mateusz Guzik <mjg@freebsd.org>
> wrote:
> > 
> > Author: mjg
> > Date: Fri Oct 13 20:31:56 2017
> > New Revision: 324609
> > URL: https://svnweb.freebsd.org/changeset/base/324609
> > 
> > Log:
> >   mtx: change MTX_UNOWNED from 4 to 0
> > 
> >   The value is spread all over the kernel and zeroing a register is
> >   cheaper/shorter than setting it up to an arbitrary value.
> > 
> >   Reduces amd64 GENERIC-NODEBUG .text size by 0.4%.
> > 
> >   MFC after:    1 week
> > 
> > Modified:
> >   head/sys/sys/mutex.h
> > 
> > Modified: head/sys/sys/mutex.h
> > ===================================================================
> > ===========
> > --- head/sys/sys/mutex.h        Fri Oct 13 20:29:35
> > 2017        (r324608)
> > +++ head/sys/sys/mutex.h        Fri Oct 13 20:31:56
> > 2017        (r324609)
> > @@ -65,15 +65,11 @@
> >   * State bits kept in mutex->mtx_lock, for the DEFAULT lock type.
> > None of this,
> >   * with the exception of MTX_UNOWNED, applies to spin locks.
> >   */
> > +#define        MTX_UNOWNED     0x00000000      /* Cookie for free
> > mutex */
> >  #define        MTX_RECURSED    0x00000001      /* lock recursed
> > (for MTX_DEF only) */
> >  #define        MTX_CONTESTED   0x00000002      /* lock contested
> > (for MTX_DEF only) */
> > -#define MTX_UNOWNED    0x00000004      /* Cookie for free mutex */
> > -#define        MTX_FLAGMASK    (MTX_RECURSED | MTX_CONTESTED |
> > MTX_UNOWNED)
> > -
> > -/*
> > - * Value stored in mutex->mtx_lock to denote a destroyed mutex.
> > - */
> > -#define        MTX_DESTROYED   (MTX_CONTESTED | MTX_UNOWNED)
> > +#define        MTX_DESTROYED   0x00000004      /* lock destroyed
> > */
> > +#define        MTX_FLAGMASK    (MTX_RECURSED | MTX_CONTESTED |
> > MTX_DESTROYED)
> > 
> >  /*
> >   * Prototypes
> > 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1507941050.8386.88.camel>