On Mon, 25 Aug 2014 19:57:39 +0530, ravali pullela said: > I want process related information like rss.(we can get this by doing cat > /proc/<pid>status) Is there a way to get this from within a kernel module? > I checked out the sources on /proc filesystem. They all show how to create, > read, write a new proc file. But I want to read from an existing proc file > specifically /proc/<pid>/status Don't bother reading the file. It's a *lot* faster and less buggy to just go get the same data yourself. > I could not find rss info of a process from its task struct in kernel > version 3.10. > > I tried to look inside kernel to know how and where are these values (rss > and all) are calculated by kernel. But I could not track it. You apparently didn't look very hard: [/usr/src/linux-next] grep RSS fs/proc/*.c fs/proc/array.c: rsslim = ACCESS_ONCE(sig->rlim[RLIMIT_RSS].rlim_ cur); fs/proc/base.c: [RLIMIT_RSS] = {"Max resident set", "bytes"}, fs/proc/task_mmu.c: "VmRSS:\t%8lu kB\n" fs/proc/task_mmu.c: * Proportional Set Size(PSS): my share of RSS. And 30 seconds of checking shows the first two to be rlimits not actual values, so you're interested in the third. Look at the source of fs/proc/task_mmu.c at function task_mem(). Getting a valid pointer to a 'struct mm_struct *' is left as an exercise for the student. :) The bigger question is, of course, what you intend to try to *do* with that info from inside a kernel module. Practical experience with several years of kernel newbies shows that 90% of the time, the idea is misguided and there's a better way to achieve the actual goal...
Attachment:
pgpcjv6ZepMwJ.pgp
Description: PGP signature
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies