From owner-svn-src-head@FreeBSD.ORG Fri Jun 1 16:24:28 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74AF3106564A; Fri, 1 Jun 2012 16:24:28 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail18.syd.optusnet.com.au (mail18.syd.optusnet.com.au [211.29.132.199]) by mx1.freebsd.org (Postfix) with ESMTP id 00D768FC19; Fri, 1 Jun 2012 16:24:27 +0000 (UTC) Received: from c122-106-171-232.carlnfd1.nsw.optusnet.com.au (c122-106-171-232.carlnfd1.nsw.optusnet.com.au [122.106.171.232]) by mail18.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q51GOIWP017908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 2 Jun 2012 02:24:20 +1000 Date: Sat, 2 Jun 2012 02:24:18 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: mdf@FreeBSD.org In-Reply-To: Message-ID: <20120602021220.K3263@besplex.bde.org> References: <201206010442.q514gqqv084148@svn.freebsd.org> <20120601175403.H1865@besplex.bde.org> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-395233105-1338567858=:3263" Cc: src-committers@FreeBSD.org, Eitan Adler , svn-src-all@FreeBSD.org, Sergey Kandaurov , Bruce Evans , svn-src-head@FreeBSD.org Subject: Re: svn commit: r236380 - head/sys/vm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 01 Jun 2012 16:24:28 -0000 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 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--