Date: Sat, 2 Jun 2012 02:24:18 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: mdf@FreeBSD.org Cc: src-committers@FreeBSD.org, Eitan Adler <eadler@FreeBSD.org>, svn-src-all@FreeBSD.org, Sergey Kandaurov <pluknet@FreeBSD.org>, Bruce Evans <brde@optusnet.com.au>, svn-src-head@FreeBSD.org Subject: Re: svn commit: r236380 - head/sys/vm Message-ID: <20120602021220.K3263@besplex.bde.org> In-Reply-To: <CAMBSHm9O5Z5HLX-FaOT=e_4ot2JHiZD2mRuXLCgSm=68SRLA2g@mail.gmail.com> References: <201206010442.q514gqqv084148@svn.freebsd.org> <CAE-mSOK=qyKbTwnKx_y5VmDNdYJG_K7R4j6565hWy09gEu_wZQ@mail.gmail.com> <20120601175403.H1865@besplex.bde.org> <CAMBSHm9O5Z5HLX-FaOT=e_4ot2JHiZD2mRuXLCgSm=68SRLA2g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-395233105-1338567858=:3263 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 1 Jun 2012 mdf@FreeBSD.org wrote: > On Fri, Jun 1, 2012 at 2:14 AM, Bruce Evans <brde@optusnet.com.au> wrote: >>>> +SYSCTL_OID(_vm, OID_AUTO, swap_free, >>>> CTLTYPE_INT|CTLFLAG_RD|CTLFLAG_MPSAFE, >>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 NULL, 0, sysctl_vm_swap_free, "Q", >>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "Blocks of free swap storage."); >> >> Bug 9 is a style bug. =A0I didn't even know that the raw SYSCTL_OID() co= uld >> be misused like this. =A0The normal SYSCTL_PROC() is identical with >> SYSCTL_OID() except it checks that the access flags are not 0. =A0Few or= no >> SYSCTL_FOO()s have no access flags, and this is not one. =A0It has rathe= r >> excessive access flags (I think CTLFLAG_MPSAFE is unnecessary. > > I wanted to correct this one point. CTLFLAG_MPSAFE is helpful, > because its use prevents kern_sysctl from taking Giant before calling > the sysctl handler. It's probably nearing the case, now, that any > sysctl *without* CTLFLAG_MPSAFE is incorrect, except perhaps for a few > that set/get text strings that don't want to roll their own > serialization. The magic is that SYSCTL_FOO() adds CTFLAG_MPSAFE for most or all simple integer SYSCTL_FOO()s like SYSCTL_INT(), but it doesn't do this for any non-integer SYSCTL_FOO(). Not for SYSCTL_PROC(), and especially not for the raw SYSCTL_OID(). There must be a lot of SYSCTL_PROC()s that don't bother with this, although many return an integer after calculating it. Perhaps the calculation isn't properly locked, but Giant will rarely help and no locking helps much for read-only sysctls of dynamic data (the value may change before it is returned). In kern, there are 113 lines matching SYSCTL_PROC, and only 4 of these match CTLFLAG_MPSAFE. Bruce --0-395233105-1338567858=:3263--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120602021220.K3263>