From owner-freebsd-current@FreeBSD.ORG Tue Jun 28 23:30:49 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DF3D916A41C for ; Tue, 28 Jun 2005 23:30:49 +0000 (GMT) (envelope-from gilham@csl.sri.com) Received: from mailgate-internal1.sri.com (mailgate-internal1.SRI.COM [128.18.84.103]) by mx1.FreeBSD.org (Postfix) with SMTP id A46BE43D48 for ; Tue, 28 Jun 2005 23:30:49 +0000 (GMT) (envelope-from gilham@csl.sri.com) Received: from localhost (HELO mailgate-internal1.SRI.COM) (127.0.0.1) by mailgate-internal1.sri.com with SMTP; 28 Jun 2005 23:30:48 -0000 Received: from mx1.csl.sri.com ([130.107.1.29]) by mailgate-internal1.SRI.COM (SMSSMTP 4.0.5.66) with SMTP id M2005062816304830328 for ; Tue, 28 Jun 2005 16:30:48 -0700 Received: from quarter.csl.sri.com (mx0.csl.sri.com [130.107.1.30]) by mx1.csl.sri.com (8.12.11/8.12.11) with ESMTP id j5SNUmgP056795 for ; Tue, 28 Jun 2005 16:30:48 -0700 (PDT) (envelope-from gilham@csl.sri.com) Received: from snapdragon (snapdragon.csl.sri.com [130.107.19.20]) by quarter.csl.sri.com (8.12.9/8.12.10) with ESMTP id j5SNUmlr024539 for ; Tue, 28 Jun 2005 16:30:48 -0700 Message-Id: <200506282330.j5SNUmlr024539@quarter.csl.sri.com> To: freebsd-current@freebsd.org In-Reply-To: Message from "Poul-Henning Kamp" of "Tue, 28 Jun 2005 21:53:42 +0200." <17008.1119988422@critter.freebsd.dk> X-Mailer: MH-E 7.82; nmh 1.0.4; GNU Emacs 21.3.1 Date: Tue, 28 Jun 2005 16:30:48 -0700 From: Fred Gilham Subject: Re: Weird problem with devstat interface X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2005 23:30:50 -0000 Poul-Henning Kamp wrote: > In message <200506281749.j5SHnPlr017616@quarter.csl.sri.com>, Fred > Gilham writes: > > >I have been able to get the program to stop doing this by changing > >the calls to > > > >devstat_checkversion() > >devstat_getnumdevs() > >devstat_getdevs() > > > >so they don't use the kvm interface but the sysctl interface > >(i.e. passing NULL instead of a file descriptor to /dev/kvm). > > You shouldn't be using the kvm interface in the first place. That seems reasonable, but the documentation doesn't give any indication that this is the case. From the devstat(3) man page: DESCRIPTION The devstat library is a library of helper functions for dealing with the kernel devstat(9) interface, which is accessible to users via sysctl(3) and kvm(3). All functions that take a kvm_t * as first argument can be passed NULL instead of a kvm handle as this argument, which causes the data to be read via sysctl(3). Otherwise, it is read via kvm(3) using the supplied handle. devstat_checkversion() should be called with each kvm handle that is going to be used (or with NULL if sysctl(3) is going to be used). >From this I got the impression that the sysctl interface was a kind of secondary alternative to the kvm interface. The /usr/sbin/iostat program also uses the kvm version (see /usr/src/usr.sbin/iostat/iostat.c). That's what whoever maintained the xsysinfo program used as an example. Also, if the kvm interface is broken it should probably be disabled or something. Actually I doubt that it's broken, but certainly the xsysinfo code doesn't interact well with it. -- Fred Gilham gilham@csl.sri.com The PTPL (People's Trotskyist Programming League) believes that hackers are elitist and that all software should be created by the masses flailing away at millions of keyboards. I didn't have the heart to tell them that this has already been tried and the result is called Linux.