From owner-p4-projects@FreeBSD.ORG Wed Sep 26 19:23:38 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4DE7816A41B; Wed, 26 Sep 2007 19:23:38 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24A5F16A417; Wed, 26 Sep 2007 19:23:38 +0000 (UTC) (envelope-from cnst@FreeBSD.org) Received: from mojo.ru (mojo.ru [84.252.152.63]) by mx1.freebsd.org (Postfix) with ESMTP id 07CA113C45D; Wed, 26 Sep 2007 19:23:36 +0000 (UTC) (envelope-from cnst@FreeBSD.org) Received: from [192.168.0.16] (nc-76-4-28-21.dhcp.embarqhsd.net [76.4.28.21]) (authenticated bits=0) by mojo.ru (8.12.11.20060308/8.12.10) with ESMTP id l8QJNg4A022370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 Sep 2007 23:23:45 +0400 Message-ID: <46FAB1A4.3030001@FreeBSD.org> Date: Wed, 26 Sep 2007 15:23:16 -0400 From: "Constantine A. Murenin" Organization: Google Summer of Code 2007 Student @ The FreeBSD Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-gb, en-gb-oed, en, en-us, ru, ru-ru, ru-su MIME-Version: 1.0 To: John Baldwin References: <200709091800.l89I0aM5060616@repoman.freebsd.org> <200709261121.58419.jhb@freebsd.org> <46FA8845.9080208@FreeBSD.org> <200709261325.55901.jhb@freebsd.org> In-Reply-To: <200709261325.55901.jhb@freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: Perforce Change Reviews , "Constantine A. Murenin" Subject: Re: PERFORCE change 126230 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2007 19:23:38 -0000 On 26/09/2007 13:25, John Baldwin wrote: > On Wednesday 26 September 2007 12:26:45 pm Constantine A. Murenin wrote: > >>On 26/09/2007 11:21, John Baldwin wrote: >> >>>On Sunday 09 September 2007 02:00:36 pm Constantine A. Murenin wrote: >>> >>> >>>>http://perforce.freebsd.org/chv.cgi?CH=126230 >>>> >>>>Change 126230 by cnst@dale on 2007/09/09 18:00:16 >>>> >>>> put in a hack for supporting "Sysctl internal magic", >>>> and now hw.sensors tree magically works in sysctl(8)! >>>> >>>> dale# sysctl hw.sensors.{lm0.volt{0,1,2,3},cpu{0,1}} >>>> hw.sensors.lm0.volt0: 1.23 VDC (VCore) >>>> hw.sensors.lm0.volt1: 12.30 VDC (+12V) >>>> hw.sensors.lm0.volt2: 3.33 VDC (+3.3V) >>>> hw.sensors.lm0.volt3: 3.31 VDC (+3.3V) >>>> hw.sensors.cpu0.temp0: 28.00 degC >>>> hw.sensors.cpu1.temp0: 28.00 degC >>>> dale# >>>> >>>> (All other utilities continue working using a cross-platform >>>> sysctl(3) interface, compatible with OpenBSD.) >>>> >>>>+#endif /* !NOSYSCTL8HACK */ >>>>+ >>>>+ >>>>+#ifndef NOSYSCTL8HACK >>>>+ >>>>+/* >>>>+ * XXX: >>>>+ * FreeBSD's sysctl(9) .oid_handler functionality is not accustomed >>>>+ * for the CTLTYPE_NODE handler to handle the undocumented sysctl >>>>+ * magic calls. As soon as such functionality is developed, >>>>+ * sysctl_sensors_handler() should be converted to handle all such >>>>+ * calls, and these sysctl_add_oid(9) calls should be removed >>>>+ * "with a big axe". This whole sysctl_add_oid(9) business is solely >>>>+ * to please sysctl(8). >>> >>> >>>Actually, sysctl_add_oid(9) is how you should add a tree of sysctl's on > > the > >>>fly to FreeBSD. It frees you from having to manually simulate a sysctl >>>tree yourself and instead focus on just handling the functionality for the >>>leaf nodes. If you just gave each sensor its own sysctl ctx and tree most >>>of your in-kernel code for dealing with 'hw.sensors' would go away as it >>>would just be a normal node ala 'dev'. >> >>If you take a closer look, the code for manually keeping track of >>sensors is very straightforward -- mostly a linked list. sysctl(9) >>interface is much more complicated than that. >> >>This manual accounting of the sensors is a requirement for the sensors >>framework -- it is the basis for the concept of sensor device, which >>stores information about individual sensors each device has (similarly >>to a sysctl_ctx). It is also required to generate and keep track of the >>numt of each sensor. >> >>Using FreeBSD's internal magic does not make the userland applications >>portable, because there is no documented userland interface for listing >>all leaves of a given sysctl tree. (If you believe otherwise, a link to >>the manual page is welcome. :) > > > See device_t's. Each one has an associated sysctl ctx (and tree) while still > having its own internal hierarchy of devices that is used to provide > enumeration APIs to userland. It's fine to use a separate interface other > than sysctl to tell userland which sensors exist (or you could have a sysctl > whose value was a list of the sensor names, etc.), but sysctl_add_oid(9) > means you don't need an actual 'hw.sensors' sysctl proc routine to manage the > sysctl namespace for you. But I why would I have a separate interface for showing sensor hierarchy if the sysctl interface can accomplish this purpose with FreeBSD's sysctl(9) .oid_handler and the sensordev structure, making the userland part of the framework entirely source-code compatible between OpenBSD and FreeBSD at the same time? Also, what is wrong with having a sysctl .oid_handler for managing the sysctl namespace? The .oid_handler functionality has been in the FreeBSD tree for ages -- why is it there if not for me to use it as it was designed for? :-) C.