Is there an equivalent api like getloadavg() that can be used within the kernel i.e. for my own driver ?
I have a driver that is thrashing and I would like to throttle it, and i am looking for a kernel-api to find about the cpu usage.
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re probably looking for the
get_avenrun()function inkernel/sched.c. An example of how to use it is infs/proc/loadavg.c:Though I’m a little skeptical of how you can use the load average to modify a driver — the load average is best treated as a heuristic for system administrators to gauge how their system changes over time, not necessarily how “healthy” it might be at any given moment — what specifically in the driver is causing troubles? There’s probably a better mechanism to make it play nicely with the rest of the system.