Re: Microstate Accounting for 2.6.11

From: Peter Chubb
Date: Fri Mar 11 2005 - 03:40:54 EST

>>>>> "Andi" == Andi Kleen <ak@xxxxxx> writes:

Andi> Andrew Morton <akpm@xxxxxxxx> writes:
>> Why does the kernel need this feature?
>> Have you any numbers on the overhead?

Andi> It does RDTSC and lots of complicated stuff twice for each
Andi> system call. On P4 this will be extremly slow (> 1000cycles
Andi> combined) It is pretty unlikely that whatever it does justifies
Andi> this extreme overhead in a critical fast path.

Not really `lots of complicated stuff'. Just swap a timer and set a
flag on entry:

msp->timers[msp->laststate] += now - msp->lastchange
msp->lastchange = now
msp->laststate = ONCPU_SYS
msp->cflags |= MSA_SYS

And swap timers and clear the flag on exit. The flag's needed to
force return to ONCPU_SYS rather than ONCPU_USR if the task preempted or
interrupted while in a system call.

If there's a simpler, cheaper, faster way to track time spent in
system calls (as opposed to time spent in interrupt handlers, or on
the run queue) thn I'd like to know what it is.

And I recognise there're are lots of people who don't want this ---
but there are some who do. I've maintained this patch since mid 2003,
and have seen a steady trickle of downloads --- one or two a week.

Dr Peter Chubb peterc AT
The technical we do immediately, the political takes *forever*
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at