mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* kernel space: finding cpu usage of individual process/thread
@ 2022-03-23 15:45 Pintu Agarwal
  2022-03-24  7:16 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Pintu Agarwal @ 2022-03-23 15:45 UTC (permalink / raw)
  To: open list, Kernelnewbies, Johannes Weiner, mingo, peterz, juri.lelli

Hi,

For one of my requirements I need to find cpu usage or load_avg of an
individual process or thread using "for_each_process_thread(process,
thread)" where process/thread is a pointer to "task_struct".

But, currently I am not able to figure out which is the right field
from task_struct to get this value, or how to manipulate it.

I see some fields there but I'm not sure if these values are correct.
a) sched_entity -> sched_avg -> load/load_avg/load_sum/util_avg/etc.
b) stime + utime : What time I get from here ?
c) prev_cputime
d) vtime
e) acct_timexpd
f) ???

It will be good if I can get some references in kernel space.

When I use (a) above (load_avg) I get this value:
pid=2 , comm=kthread, load=51
pid=96, comm=cat , load=1024
etc...

When I use (stime + utime) I get:
pid=2 , comm=kthread, load=3978848
pid=96, comm=cat , load=11786176

So, not sure which one is correct ?


Thanks,
Pintu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-24  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 15:45 kernel space: finding cpu usage of individual process/thread Pintu Agarwal
2022-03-24  7:16 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®