When and when not to use CTLFLAG_MPSAFE with the SYSCTL macros..?

Hans Petter Selasky hps at selasky.org
Wed Aug 5 06:36:50 UTC 2015


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



More information about the freebsd-hackers mailing list