From owner-freebsd-hackers@freebsd.org Wed Aug 5 06:36:50 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4752B9B4E86 for ; Wed, 5 Aug 2015 06:36:50 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0C6D2C7F for ; Wed, 5 Aug 2015 06:36:50 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 327941FE023; Wed, 5 Aug 2015 08:36:48 +0200 (CEST) Message-ID: <55C1AF5A.1080601@selasky.org> Date: Wed, 05 Aug 2015 08:38:18 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Garrett Cooper , freebsd-hackers Subject: Re: When and when not to use CTLFLAG_MPSAFE with the SYSCTL macros..? References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Aug 2015 06:36:50 -0000 On 08/05/15 00:47, Garrett Cooper wrote: > Hi, > I’ve been trying to figure out (because sysctl(9) is lacking) when to use CTLFLAG_MPSAFE. Is it strictly when dealing with SYSCTL_PROC handlers that do proper locking of shared resources, or are there other nuances that need to be handled? > I’m also asking because SYSCTL_UQUAD, for instance, explicitly uses CTLFLAG_MPSAFE in the handler, which is a bit confusing. > Thanks! > -NGie Hi, This flag decides if you have Giant automatically locked or not around the sysctl proc. Your functions should have their own locks basically. I believe it is a leftover from many years ago, when the FreeBSD kernel was going multi threaded. --HPS