Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Apr 2001 13:26:05 -0400 (EDT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        smp@FreeBSD.org
Subject:   RE: sysctl's and mutexes
Message-ID:  <Pine.NEB.3.96L.1010424131753.9817D-100000@fledge.watson.org>
In-Reply-To: <XFMail.010424101056.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 24 Apr 2001, John Baldwin wrote:

> > int     jail_set_hostname_allowed = 1;
> > SYSCTL_INT(_jail, OID_AUTO, set_hostname_allowed, CTLFLAG_RW|CTLFLAG_MTX,
> >     &jail_set_hostname_allowed, &jail_set_hostname_allowed_mtx, 0,
> >     "Processes in jail can set their hostnames");
> 
> It might very well be desirable to add a new parameter for each sysctl
> that is a pointer to a mutex.  However, an appropriate SYSINIT() or some
> such during startup needs to initialize that mutex before that sysctl is
> used.  If need be, we can also add a flag to determine if the sysctl
> should initialize the mutex itself or not.  Ideally then, we would
> create a new SYSINIT on the fly to initialize the mutex in question.  I
> think though, that requiring explicit initialization of each mutex
> shouldn't be too hard.

I don't have strong feelings on the exact nature of how mutices are bound
to sysctl's, as long as it's possible to do the following: 

1) It should be possible to use an existing initialized mutex, especially
   with regards to dynamically allocated sysctl's. 

2) It should be possible for several sysctl's to share the same mutex. 

Presumably if the SYSCTL code is initializing the mutex, there are
questions about the relative orderings of initialization of the mutex and
first use of the protected variable in kernel: the code in question needs
to know if SYSCTL stuff runs first so it can determine if the mutex should
be used to protect access to the variable or not...  (and all the other
general boot-time ordering issues).

Robert N M Watson             FreeBSD Core Team, TrustedBSD Project
robert@fledge.watson.org      NAI Labs, Safeport Network Services



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1010424131753.9817D-100000>