From: Andi Kleen <andi@firstfloor.org>
To: "Rafael C. de Almeida" <almeidaraf@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: /proc/data information
Date: Mon, 14 Jul 2008 18:38:58 +0200 [thread overview]
Message-ID: <87ej5wzahp.fsf@basil.nowhere.org> (raw)
In-Reply-To: <487A606E.5040202@gmail.com> (Rafael C. de Almeida's message of "Sun, 13 Jul 2008 17:07:10 -0300")
"Rafael C. de Almeida" <almeidaraf@gmail.com> writes:
> I'm interested in knowing how the cpu data from /proc/stat is gathered.
> Following my way from this function:
>
> http://lxr.linux.no/linux+v2.6.25.10/fs/proc/proc_misc.c#L459
>
> 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.
-Andi
next prev parent reply other threads:[~2008-07-14 16:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-13 20:07 /proc/data information Rafael C. de Almeida
2008-07-14 16:38 ` Andi Kleen [this message]
2008-07-14 19:47 ` Rafael C. de Almeida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ej5wzahp.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=almeidaraf@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox