From owner-freebsd-current@FreeBSD.ORG Sat Mar 22 04:21:44 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97E47106566B for ; Sat, 22 Mar 2008 04:21:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outO.internet-mail-service.net (outo.internet-mail-service.net [216.240.47.238]) by mx1.freebsd.org (Postfix) with ESMTP id 8BF028FC1C for ; Sat, 22 Mar 2008 04:21:44 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Fri, 21 Mar 2008 21:23:10 -0700 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id E1D102D6011; Fri, 21 Mar 2008 21:21:43 -0700 (PDT) Message-ID: <47E48957.7040903@elischer.org> Date: Fri, 21 Mar 2008 21:21:43 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.12 (Macintosh/20080213) MIME-Version: 1.0 To: Barney Cordoba References: <494618.95957.qm@web63906.mail.re1.yahoo.com> In-Reply-To: <494618.95957.qm@web63906.mail.re1.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: current@freebsd.org Subject: Re: kvm_read() vs ioctl performance 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: Sat, 22 Mar 2008 04:21:44 -0000 Barney Cordoba wrote: > --- Julian Elischer wrote: > >> Barney Cordoba wrote: >>> --- Julian Elischer wrote: >>> >>>> Barney Cordoba wrote: >>>>> I have an app which reads stats from the kernel >>>>> periodically, and there can be a lot of >>>> iterations, >>>>> sometimes 20,000 or more. I'm thinking of >>>> converting >>>>> from an ioctl method to kvm_read(). KVM is >>>> certainly >>>>> simpler, but its not clear what overhead is >>>> involved, >>>>> since kvm_read() likely has to call the kernel >>>> also. >>>>> Does anyone have a handle on the difference in >>>>> overhead, assuming that the ioctl call is to a >>>> module >>>>> which does nothing more than copy the data and >>>> return? >>>> >>>> tried a shared memory page? >>> No, but I built a test and kvm_read is 70 times >>> faster, in >>> case anyone is interested. >> cool.. >> the only downside is that we are trying to get away >> from kvm direct >> access. (which is why a shared page might give the >> same result with a >> stable API which is not libkvm... BTW on an SMP >> machine you have >> no way to ensure that your stats are coherent if you >> use libkvm. > > The app is portable, and I'd prefer not to have > different methods for LINUX and FreeBSD. When you say > "coherent", what exactly do you mean? there is no synchronisation between your app and the device. I dont know what sized structure you are reading but how do you know that the device isn't half way through writing it? A mmapped page would be more portable, for example done in the way that a video frame buffer is done. All systems support that sort of semantic the same. Then you can use memory semaphores to make sure that the stuff is consistent, because you can write back. > > Barney > > > ____________________________________________________________________________________ > Never miss a thing. Make Yahoo your home page. > http://www.yahoo.com/r/hs