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.
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.
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.