Linux-kernel mailing list archive 2000-06,: Re: keeping track of time spend in non-user space

# Re: keeping track of time spend in non-user space

Mikael Pettersson (mikpe@csd.uu.se)
Sat, 12 Feb 2000 20:58:40 +0100 (MET)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Jeff Garzik: "Re: supermount"
- Previous message: James Bottomley: "Re: Mirroring Root Disks"
- Maybe in reply to: Sjaak Koot: "keeping track of time spend in non-user space"

On Fri, 11 Feb 2000, Sjaak Koot wrote:
>I am using linux kernel 2.2.13 on a Pentium PC.
>
>I would like to keep track of the CPU time in user space of a process or
>task. The user/system time currently implemented is not accurate enough,
>its resolution is 10 ms.

If your processor supports performance-monitoring counters,
has a performance event which just counts cycles, and can
limit counters to user-mode (CPL 3), then you can achieve this
using the virtual per-process counters implemented by my
performance-monitoring counters driver.
(Available at http://www.csd.uu.se/~mikpe/linux/perfctr/.)

E.g., on a Pentium MMX, you'd set up the CESR register for a
given process to count cycles <ES0=0x30> at CPL 3 <CC0=0x2>.
The kernel and the driver cooperate to maintain per-process
state at scheduling points. The hardware setup will be different,
but Pentium Pro/II/III, Celeron, and Athlon processors are also
capable of counting user-space cycles.

/Mikael

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

- Next message: Jeff Garzik: "Re: supermount"
- Previous message: James Bottomley: "Re: Mirroring Root Disks"
- Maybe in reply to: Sjaak Koot: "keeping track of time spend in non-user space"