Re: [PATCH] CPU time clock support in clock_* syscalls

From: Nick Piggin
Date: Tue Oct 05 2004 - 18:25:11 EST


Roland McGrath wrote:

CPU. In which case you don't need to worry about timestamp_last_tick.


I don't really understand this comment. update_cpu_clock is called from
schedule and from scheduler_tick. When it was last called by schedule,
p->timestamp will mark this time. When it was last called by
p->scheduler_tick, rq->timestamp_last_tick will mark this time.
Hence the max of the two is the last time update_cpu_clock was called.


OK I see what its doing - ignore my comments then :P



It also seems to conveniently ignore locking when reading those values
off another CPU. Not a big deal for dynamic load calculations, but I'm
not so sure about your usage...?


Here again I don't know what you are talking about. Nothing is ever read
"off another CPU". A thread maintains its own sched_time counter while it
is running on a CPU.


It seemed like a syscall could read the values from a task currently
running on another CPU. If not, great.


Lastly, even when using timestamp_last_tick correctly, I think sched_clock
will still drift around slightly, especially if a task switches CPUs a lot
(but not restricted to moving CPUs).


Please explain.


As you pointed out, you are only measuring on-cpu time so this shouldn't
be a problem either.

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