From owner-freebsd-smp Tue Apr 24 11:45:59 2001 Delivered-To: freebsd-smp@freebsd.org Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88]) by hub.freebsd.org (Postfix) with ESMTP id DD88437B43C; Tue, 24 Apr 2001 11:45:51 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by meow.osd.bsdi.com (8.11.2/8.11.2) with ESMTP id f3OIjjG70725; Tue, 24 Apr 2001 11:45:45 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Tue, 24 Apr 2001 11:45:07 -0700 (PDT) From: John Baldwin To: Robert Watson Subject: RE: sysctl's and mutexes Cc: smp@FreeBSD.org Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On 24-Apr-01 Robert Watson wrote: > 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. Exactly. > 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). Right, which is why I think requriring explicit initialization will probably prove to be saner in the long run for most sysctl's. -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message