Thread (4 messages) 4 messages, 2 authors, 2014-08-29

How to get the information from /proc/files from within a kernel module?

From: ravali pullela <hidden>
Date: 2014-08-29 19:51:12

Hi,

I tried to do the following. Calculate rss using virtual address to
physical page mappings. But *the value calculated using this method is
greater than the value reported by get_mm_rss*, the api which reports the
process rss in /proc/pis/status.

The way I tried to calculate rss is to count pages whose virtual to
physical mappings are valid and for which page is present. I am doing this
on the entire va space so that I can check every page if it is present and
increment a counter.

The problem is that when i looked inside get_mm_rss function, it returns
                get_mm_counter(mm, MM_FILEPAGES) +
                get_mm_counter(mm, MM_ANONPAGES);

I thought that anonymous and file pages cover all vm areas like stack,
heap, code, data etc., but it does not look like. So, what is it that I am
missing.

Note: The value calculated by my module is approximately same as the sum of
rss reported by /proc/pid/smaps for all vmas.

Thanks


On Mon, Aug 25, 2014 at 11:07 PM, ravali pullela [off-list ref]
wrote:
Thank you so much Valdis and Aruna. Probably, the problem was I tried to
search more on internet rather than kernel source and after 3 hours(I know
it is long), I understood that I am nowhere going in the right direction.

I have the mm_struct * with me. grepping is more useful.

Thanks again to all the people who are supporting kernel newbies :)


On Mon, Aug 25, 2014 at 10:12 PM, Aruna Hewapathirane <
aruna.hewapathirane at gmail.com> wrote:
quoted
quoted
quoted
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
quoted
proc file. But I want to read from an existing proc file specifically
/proc/<pid>/status
Have a look here: https://gist.github.com/Aruna-Hewapathirane
/f41e7291e15bae6062a1 does exactly what your trying to do.
quoted
quoted
Can anyone please point me to either resources or guide me to
accomplish the task of reading information from
quoted
/proc/files...
I would suggest you go through the source code for PS : http://procps.
sourceforge.net/ and carefully study how things are done.

This will also help: https://www.kernel.org/doc/Documentation/filesystems
/proc.txt

That being said I have to agree fully with Valdis the best way is always
to grep through the kernel that way you get to see code that is being used
and how things are done.

With all due respect to all the more experienced and knowledgeable folks
on the list I had great difficulty when I first started out accessing
information and I have no wish to see anyone who is fascinated by the
kernel and wants to mess with the internals be it for fun as a hobby to
learn or for serious patching and contributing to the kernel walk away
frustrated like I did so many times. ( I always walked right back though...
:)

Yes Valdis you can give me a hard time on IRC when I next show up :)

Aruna ( Ravali, please heed Valdis's advice that is the best way. I just
pointed you in the right direction with a bit more code to play with but
try to do your own digging first through the kernel and good luck ! )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140830/20ef9d13/attachment.html 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help