[TEST/REVIEW] cpu time accounting patch, step 2

Poul-Henning Kamp phk at phk.freebsd.dk
Thu Feb 9 14:32:20 PST 2006


	http://phk.freebsd.dk/patch/cputime.patch 

This patch enables the new cpu time accounting method for i386 with
TSC, all amd64 and sparc64 (?) and i386 with Geode cpu.

The overall objective is to trade a minor amount of precision in
cpu time accounting for a significant speedup in context switch.

On my amd64 machine, I get 27+/-5 % improvement on unixbench/context1.

Basically the patch uses the TSC or other (per-CPU) hardware device
to keep track of CPU utilization and only converts to microseconds
when necessary.  If no "special" hardware is available the code
falls back to the timecounter hardware, whatever it is.

If the "special hardware" counter is marked as variable, a function
runs every 16 seconds and (tries to) calibrate the max frequency
we have ever seen.  (If you boot verbose it will say what it does).
This code is supposed to cope with laptops and other power-managed
hardware.  Only the "boot CPU" is calibrated, the other CPUs are
supposed to run at the same rate (but they may have an offset).

Tests, reviews etc please.

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-current mailing list