[lkml]   [2008]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: /proc/data information
"Rafael C. de Almeida" <> writes:

> I'm interested in knowing how the cpu data from /proc/stat is gathered.
> Following my way from this function:
> I've figured that the time is probably gathered using those
> account_*_time on sched.c. I'm not sure where the times are read from,
> though.

They are normally (some architectures do it differently to cope with
virtualized environments) sampled by a regular timer interrupt, which
runs HZ times per second on each CPU. Common values for HZ is 250
(2.5ms interval), but you can compile with others too.

I suspect the effects you're seeing all come from sampling error.
The interval is also not fully stable because the kernel sometimes
disables interrupts and that will delay the timer interrupt of course.
How often this happens depends on the workload.

Then there are architectures like s390 who do "microstate accounting":
they keep track instead on every kernel entry/exit and every interrupt.
That can be more accurate, but is also more costly.


 \ /
  Last update: 2008-07-14 18:41    [W:0.032 / U:3.388 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site