Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Nov 1997 14:12:07 -0700 (MST)
From:      Charles Mott <cmott@srv.net>
To:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Reading kernel memory
Message-ID:  <Pine.BSF.3.96.971116140323.10522A-100000@darkstar.home>
In-Reply-To: <19971116205014.XN38067@uriah.heep.sax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Nov 1997, J Wunsch wrote:
> As Charles Mott wrote:
> 
> > So if one really wants to map a kernel variable to
> > user space, I am guessing something more sophisticated
> > than the kvm routines are needed.
> 
> Not sure, but perhaps it's possible to mmap() /dev/kmem?

Yes, mmap() to /dev/kmem works (I tested it), and so reading the kernel
time variable can be done very quickly.  I hadn't figured this out yet
when I made the earlier posting.  As mentioned below, though, the
granularity of this measurement (usually 10 msec)  is not nearly as good
as gettimeofday() because of microtime(). 

> 
> > Wandering through the kernel source code, I have also
> > discovered that gettimeofday() actaully invokes a
> > microtime() call which actually tries to determine the
> > time by reading a timer and using it to refine the
> > kernel time variable.
> 
> After ktracing X11 applications, and seeing how often gettimeofday()
> is actually called, i've been rather impressed that this entire
> process is still reasonably faster nevertheless.  The featuere is very
> useful for fine-granularity traces, be it ktrace or tcpdump (or simply
> the ping response time).

The high accuracy ping time is one thing I've always liked about FreeBSD
over Linux.

Does anyone know what the response time for gettimeofday() is on a
reasonably modern Pentium?  It is about 60 microseconds on my ancient 386. 

Although I originally though a non-privileged /dev/timeofday (Tony
Newfield's idea) combined with mmap() might be a good way to get quick
timestamps, I tend to think the existing system is good enough, especially
since processors are getting faster. 

Charles Mott




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971116140323.10522A-100000>