Results 1 to 7 of 7
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
08-16-2010 #1
- Join Date
- Aug 2009
- Posts
- 4
get CPU utilization in a kernel module
But i am not getting an exact api or way to calculate CPU load from kernel module.
/proc/loadavg and /proc/stat ae 2 options.. But not a good way if open this file from my module.
Which is the best option or way to calculate CPU load, so as my overload module will function correctly..
Thank you in advance...
-
08-19-2010 #2
I think you can use top command to do that. You can call thise with system("top").
-
08-21-2010 #3
- Join Date
- Aug 2009
- Posts
- 4
I need to get the CPU usage from a kernel module. top is a user space program.
-
08-22-2010 #4
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
- Posts
- 14,038
You can get that from /proc files, such as /proc/stat, etc.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
-
08-23-2010 #5
I think profiling tools like oprofile can also give usage by modules. Am I right?
-
08-23-2010 #6
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
- Posts
- 14,038
Perhaps - I'm not sure about from inside the kernel. However, you need to instrument the code being executed first. I think the poster wants something that can check system CPU utilization from within a kernel module at runtime, without needing to instrument anything, only needing to load the kernel module. I'm not sure what benefits that gives them, but that's another issue.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
-
08-25-2010 #7
- Join Date
- Aug 2009
- Posts
- 4
Using /proc/stat can give cpu usage from userspace. For that I need to use netlink sockets to hook with userspace. This may be slow.
by the way, my intention is to have some mechanism to detect cpu load in kernel. So based on that, overload situation can be detected.