george anzinger wrote:
> First blush is HELL YES! The issue is accounting. When you
> ask how long a program ran, you are looking at the
> accounting that happens on a tick. This is where one of two
> counters gets bumped (one for system, the other for user,
> depending on what was interrupted). This information could,
> of course, be gathered every system call/ exit and every
> context switch, BUT, there are FAR more system calls and
> context switches than 1/HZ ticks. Thus collecting
> accounting info this way adds overhead as the system load
> increases, a VERY BAD thing IMHO.
In addition to syscall entries/exits and sched changes, you then
also need to keep track of interrupt and trap entries/exits in
order to have the complete picture. Even then, determining exactly
when you're going to return to user-space can be tricky. Your
statement is indeed accurate, exact accounting's cost increases
linearly with the number of events that occur.
Having exact accounting all the time is certainly not necessary,
but it is indeed sometimes useful. *shameless self-promotion*,
That's yet another reason why I think LTT's inclusion in the
mailing kernel would be helpful. In addition to the rest of
the capabilities it provides, it provides exact accounting for
whoever really needs it on the spot.
If you are looking for better accounting using clock ticks, then
have a look at McCanne and Torek's paper "A Randomized Sampling
Clock for CPU Utilization Estimation and Code Profiling"
presented at Usenix in '93. As the title implies, they vary
the clock to obtain random samples and therefore obtain very
accurate results about system accounting. The use of hardware
counters to obtain samples is also viable, although it's much
more arch dependent than random clock ticks.
Cheers,
Karim
===================================================
Karim Yaghmour
[email protected]
Embedded and Real-Time Linux Expert
===================================================