How to get cpu utilization through code with least overhead?

Raghu Udiyar raghusiddarth at gmail.com
Thu Jul 28 20:30:30 EDT 2011


On Fri, Jul 29, 2011 at 5:26 AM, Vaibhav Jain <vjoss197 at gmail.com> wrote:

> Hi,
>
> Is there any other way to do this? If I need to write a kernel module that
> needs to get cpu utilization
> should I still use proc/stat ? Is there a kernel function that can be used
> in a module ?
>
> Thanks
> Vaibhav Jain
>

The kernel writes all cpu metrics and more to /proc/stat. I/O data goes to
/proc/diskstat and memory to /proc/vmstat.  Top and other tools interpret
the counters written to these files.

You can also look at hardware performance counters, as used by the perf
utility.
--
Raghu S Udiyar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110729/31a1d71a/attachment.html 


More information about the Kernelnewbies mailing list