[vortex] How to use gettimeofday inside 3c59x.c ?

Fred Maciel fred-m@crl.hitachi.co.jp
Fri, 23 Mar 2001 08:50:09 +0900


Hi Marcus,

> gettimeofday is a libc function, IIRC. You can use it from
user-level
> programs, but not from inside the kernel.
> You might want to use the value of 'jiffies' which is incremented
every 10
> ms on x86, if you can live with this resolution.

You can also use the time-stamp counter available in many CPUs (P5,
P6, etc.). It is a register inside the CPU that increments by one at
each clock cycle. It's the most fine-grained time reference that you
can have in such computers.

There are many Linux projects that allow you to access the time-stamp
counter (or, more generally, the x86 machine-specific registers
(MSRs) -- the time-stamp counter is one of them). I included under the
signature a list from the perfctr
 http://www.csd.uu.se/~mikpe/linux/perfctr/ ) package. There is also
support for the MSRs added to the kernel in 2.2.18 (it's in 2.4 also,
I guess).

If you want more information, feel free to e-mail me directly (and to
write in Portuguese... :-)

Hope that helps,

                         Fred Maciel
                         E-mail  fred-m@crl.hitachi.co.jp

Disclaimer:
I don't speak for Hitachi,
I don't know who speaks for Hitachi,
I don't want to know who speaks for Hitachi.


  RELATED PACKAGES
  ================

[Note: this list is incomplete and not actively maintained.]

msr (by Stephan.Meyer@pobox.com)
 http://pobox.com/~smeyer/msr.html [page seems dead now]
 Supports kernels up to 2.2.6. No longer actively developed.
 Adds /dev/msr as a raw interface to the CPUs MSRs.
 No virtual PMCs.

proc_sr (by bosch@lri.fr)
 Patch for kernel 2.0.27.
 Adds a bunch of files under /proc/Intel/, which allow
 global access to MSRs and control registers.
 No virtual PMCs.

vtimer (by dadkins@mit.edu and bsong@supertech.lcs.mit.edu)
 Patch for kernel 2.3.6.
 Adds per-process virtual TSC support.

msr_patch-2.1.126 (by Harald Hoyer, HarryH@Royal.Net)
 Patch for kernel 2.1.126.
 Adds /proc/<pid>/msr text file with read/write
 access to per-process PMC MSRs
 Only supports the Intel P5MMX.
 Does not handle counter overflow.

hardcntr-2 (by David.Mentre@irisa.fr)
 http://www.irisa.fr/prive/mentre/linux-counters/hardctr-2.patch
 Patch for kernel 2.1.65.
 Adds some text files under /proc/<pid>/hardcntr/, which
 allow read/write access for per-process PMC MSRs.
 Only supports the Intel P6.
 Does not handle counter overflow.
 Deprecated by author.

perf-0.7 (by Erik Hendriks, hendriks@cesdis.gsfc.nasa.gov)
 Patches for kernels 2.0.36, 2.2.2, and 2.2.9.
 Does support both per-process and global PMCs.
 Does handle counter overflow.
 No virtual TSC.
 Only supports Intel P6.

msr-patch-2.3.1 (by Richard Gooch,
http://www.atnf.csiro.au/~rgooch/linux/)
 Adds /dev/<cpu>/perfmon with access to per-CPU PMCs.
 Does not implement virtual-mode PMCs.
 Does not handle counter overflow.
 Part of bigger package (MSRs, requires devfs).

pperf/libpperf (by M. Patrick Goda,
http://qso.lanl.gov/~mpg/pperf.html)
 Based on Stephan Meyer's msr patch, and shares its limitations.
 Emphasis on user-space tools.

pcl (by Rudolf Berrendorf and Heinz Ziegler,
  http://www.fz-juelich.de/zam/PCL/)
 User-space tools, based on libpperf.

PAPI (http://icl.cs.utk.edu/projects/papi/)
 "Portable Interface to Hardware Performance Counters"
 Common interface to the perfctr facilities on several
 operating systems and processor architectures.
 On Linux, uses Hendriks' "perf" patch for Intel P6 processor.
 User-space tools. Implements both overflow signals and
 event multiplexing.

pmc-1.02 (by Don Heller, dheller@scl.ameslab.gov)
 http://www.scl.ameslab.gov/Projects/Rabbit/index.html
 Derived from pperf by M. Patrick Goda and Michael S. Warren.
 Global-mode counters access via /dev/pmc.
 Supports Intel P5 and P6 via compiler option.
 No virtual counters.
 Emphasis on user-space tools.

Using hardware performance counters with Linux (by David Mentre
 http://www.irisa.fr/prive/mentre/linux-counters/
 A page with info and links.

Compaq Continuous Profiling Infrastructure Project
 http://www.research.digital.com/SRC/dcpi/