From owner-freebsd-arch Wed Aug 16 2:47:39 2000 Delivered-To: freebsd-arch@freebsd.org Received: from netplex.com.au (adsl-63-207-30-186.dsl.snfc21.pacbell.net [63.207.30.186]) by hub.freebsd.org (Postfix) with ESMTP id 2FF0337C084 for ; Wed, 16 Aug 2000 02:46:58 -0700 (PDT) (envelope-from peter@netplex.com.au) Received: from netplex.com.au (peter@localhost [127.0.0.1]) by netplex.com.au (8.9.3/8.9.3) with ESMTP id CAA44281; Wed, 16 Aug 2000 02:46:47 -0700 (PDT) (envelope-from peter@netplex.com.au) Message-Id: <200008160946.CAA44281@netplex.com.au> X-Mailer: exmh version 2.1.1 10/15/1999 To: Peter Jeremy Cc: Alfred Perlstein , arch@FreeBSD.ORG Subject: Re: would like to make cp_time a sysctl In-Reply-To: <00Aug16.144112est.115253@border.alcanet.com.au> Date: Wed, 16 Aug 2000 02:46:47 -0700 From: Peter Wemm Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Peter Jeremy wrote: > On 2000-Aug-15 20:56:43 -0700, Alfred Perlstein wrote: > >I would like to have a sysctl that returns a string of the cpu states: > >kern.cpustates.names: user nice sys intr idle > >kern.cpustates.values: values > > I'd like a bit of clarification here. I presume you mean that > kern.cpustates.names will return CTLTYPE_STRING with a value > "user nice sys intr idle". Does the second line mean there will > be a set of sysctls kern.cpustates.{user,nice,sys,intr,idle}, each > returning a CTLTYPE_INT containing the relevant entry from cp_time[]? > > In this case, the kern.cpustates.names is not really necessary since a > userland program can either search the namespace under kern.cpustates > (see /usr/src/sbin/sysctl/sysctl.c:sysctl_all() for details) or just > query the states in knows about (or wants information on). > > >I've been told that netbsd has thier own way of doing it, I don't > >like it because they use SYSCTL_STRUCT which isn't very useful unless > >you can include the C headers to parse it. > > There is lots of precedent for returning CTLTYPE_STRUCT in the FreeBSD > kernel and I don't see any particular reason for not just copying what > NetBSD have done. Why expend the extra effort of implementing the > same functionality differently, just to be different? > > The other (slight) downsize is that your approach needs 5 system calls > to return all the values, compared to one system call that returns > 5 times as much data. > > My feeling is that your suggestion is slightly cleaner than using a > CTLTYPE_STRUCT (though I'm not certain about kern.cpustates.names), > but that is outweighed by the lack of compatibility with other > implementations. On FreeBSD right now, we have a few structs: kern.clockrate: { hz = 100, tick = 10000, tickadj = 5, profhz = 1024, stathz = 128 } kern.boottime: { sec = 966386120, usec = 228217 } Tue Aug 15 17:35:20 2000 vm.loadavg: { 0.48 0.61 1.11 } machdep.consdev: { major = 12, minor = 255 } Since it is one sysctl vs five, and doing name2oid translation requires an *extra* syscall, I'd suggest NOT using OID_AUTO, and using a single struct and define the format strings for sysctl to "present" it to the user... > Peter Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message